Skip to content

Conversation

@LSLeary
Copy link
Contributor

@LSLeary LSLeary commented Feb 6, 2026

The parameters to Builder and NamedBuilder in Data.Csv.Incremental are phantom, so GHC infers the same for their roles. This allows them to be coerced willy nilly, defeating their purpose of using the type system to avoid building malformed CSV.

Declaring the parameters nominal fixes this issue by ensuring that a given builder uses the same record construction instance throughout.

It's also good practice to give such phantoms explicit kind signatures to avoid troubles due to accidental kind polymorphism. It doesn't look like the module is using PolyKinds at this time, but it's the sort of extension that really should be on by default, so I've added the signatures anyway—consider it future proofing.

@mchav
Copy link
Collaborator

mchav commented Feb 9, 2026

Hey. Sorry I didn't get to this earlier. Was traveling for AmeriHac. This is a minor but potentially breaking change, right?

@LSLeary
Copy link
Contributor Author

LSLeary commented Feb 9, 2026

@mchav No worries, but the answer to that depends somewhat on your philosophy.

I consider this a bug fix; it won't break proper uses of the typed interface, but it will "break" abuses of the hole in it.

@mchav
Copy link
Collaborator

mchav commented Feb 10, 2026

@LSLeary fair enough. Please bump the minor version and add a change log entry then I'll merge.

The parameters to `Builder` and `NamedBuilder` in `Data.Csv.Incremental`
are phantom, so GHC infers the same for their roles.
This allows them to be `coerce`d willy nilly, defeating their purpose of
using the type system to avoid building malformed CSV.

Declaring the parameters `nominal` fixes this issue by ensuring that a
given builder uses the same record construction instance throughout.
@LSLeary
Copy link
Contributor Author

LSLeary commented Feb 10, 2026

@mchav Done.

@mchav mchav merged commit b942f08 into haskell-hvr:master Feb 10, 2026
24 checks passed
@LSLeary LSLeary deleted the builder-roles branch February 10, 2026 16:38
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