mthom / scryer-prolog

A modern Prolog implementation written mostly in Rust.
BSD 3-Clause "New" or "Revised" License
2k stars 117 forks source link

Small issue with CSV module output? #2486

Open jjtolton opened 1 month ago

jjtolton commented 1 month ago

While researching for the I/O tutorial for Scryer, I hit a roadbump with the csv module. The example provided:

?- use_module(library(csv)).
?- write_csv('./test.csv', frame(["col1","col2","col3","col4"], [["one",2,[],"three"]])).

generates this file on my machine:

[o,n,e];2;\N;[t,h,r,e,e]

Changing the query to:

?- write_csv('./test.csv', frame(['col1','col2','col3','col4'], [['one',2,[],'three']])).

generates:

col1,col2,col3,col4
one,2,,three

I believe the issue lies with the usage of ~w vs ~s in the inner call to the format predicate, but I was unable to get a full diagnostic completed.

I'm not sure if this is a platform specific issue?

$ cat /etc/os-release 
NAME="Linux Mint"
VERSION="21.2 (Victoria)"
ID=linuxmint
ID_LIKE="ubuntu debian"
PRETTY_NAME="Linux Mint 21.2"
VERSION_ID="21.2"
HOME_URL="https://www.linuxmint.com/"
SUPPORT_URL="https://forums.linuxmint.com/"
BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
PRIVACY_POLICY_URL="https://www.linuxmint.com/"
VERSION_CODENAME=victoria
UBUNTU_CODENAME=jammy
bakaq commented 1 month ago

I can reproduce this. Doesn't seem that hard to fix, but I also think that the whole interface may benefit from a DCG overhaul and delegation of IO to the phrase_(from|to)_(stream|file) predicates from library(pio), similarly to library(serialization/json). And tests, at least some.