Skip to content

Conversation

@mcoady
Copy link

@mcoady mcoady commented Jan 21, 2026

Description

writeCsv was outputting optional (non-Text) values as text including Just/Nothing in the file. You can see this behaviour doing a read/write/read cycle (see below). On Windows btw.

Example

Input

dataframe> df <- D.readCsv "input.csv"
dataframe> df
--------------------------------------
id  | fld_a  |    fld_b    |   fld_c
----|--------|-------------|----------
Int | Double | Maybe Text  | Maybe Int
----|--------|-------------|----------
0   | 0.0    | Nothing     | Nothing
1   | 0.5    | Just "base" | Just 10

Behaviour before

dataframe> D.writeCsv "before.csv" df >> D.readCsv "before.csv" >>= print
-------------------------------------------
id  | fld_a  |    fld_b    |     fld_c
----|--------|-------------|---------------
Int | Double | Maybe Text  |   Maybe Text
----|--------|-------------|---------------
0   | 0.0    | Nothing     | Nothing
1   | 0.5    | Just "base" | Just "Just 10"

Behaviour after

dataframe> D.writeCsv "after.csv" df >> D.readCsv "after.csv" >>= print
--------------------------------------
id  | fld_a  |    fld_b    |   fld_c
----|--------|-------------|----------
Int | Double | Maybe Text  | Maybe Int
----|--------|-------------|----------
0   | 0.0    | Nothing     | Nothing
1   | 0.5    | Just "base" | Just 10

@mchav
Copy link
Owner

mchav commented Jan 21, 2026

Great catch and fix. I'll include some round trip tests in a follow up.

@mchav
Copy link
Owner

mchav commented Jan 21, 2026

@mcoady text show doesn't seem to work for older ghcs. Can we in the mean time add another case statement matching Maybe Text?

@mcoady
Copy link
Author

mcoady commented Jan 21, 2026

Ah, my bad - I see show was added in text-2.1.2. Yes, I can see the need to handle Maybe Text separately as I can see quoted strings in the output. I'll take a look. Apologies for a basic question, how are you managing the running of tests for different compiler versions? Is there a standard or preferred tool?

As an aside - excellent project btw! I'm looking to replace some python/polars with this so happy to provide feedback if I stumble across anything else, but liking it so far!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants