dhall-haskell icon indicating copy to clipboard operation
dhall-haskell copied to clipboard

confusing documentation for the Union type decoder with empty tags

Open amkhlv opened this issue 11 months ago • 2 comments

Suppose that I have a union type in Dhall : let MBText = < Noth | Smth Text>

To decode it, I use:

data MBText  = Smth Text | Noth ()
mbtextDecoder = union ( 
    (Smth <$> constructor "Smth" strictText) 
    <> (Noth <$> constructor "Noth" unit)
   )

First reading of the documentation I got confused into thinking that the appropriate Dhall code would be:

let MBText = < Noth {} | Smth Text>

while in fact it is <Noth | Smth Text>

Is it true that the existing documentation is not sufficiently clear, or is it my fault ?

Merry Christmas, and thank you for this beautiful work !

amkhlv avatar Dec 24 '24 22:12 amkhlv

Yeah, I'd accept a pull request to clarify this

Gabriella439 avatar Jan 04 '25 03:01 Gabriella439

Done. Please, double check. To be honest, I was not able to compile it, so my patch is a guesswork. And I still don't quite understand the logic.

amkhlv avatar Jan 04 '25 17:01 amkhlv