krisajenkins / elm-export

Create Elm types and JSON decoders from Haskell source.
Eclipse Public License 1.0
116 stars 47 forks source link

Fix the tests on rework-adt #13

Closed mattjbray closed 8 years ago

mattjbray commented 8 years ago

Before these changes, we had:

*> toElmType (Proxy :: Proxy Timing)
ElmDatatype "Timing"
    (MultipleConstructors
        [ NamedConstructor "Start" (ElmPrimitiveRef EUnit)
        , MultipleConstructors [ NamedConstructor "Continue" (ElmField "" (ElmPrimitiveRef EFloat))
                               , NamedConstructor "Stop" (ElmPrimitiveRef EUnit)
                               ]])
*> toElmTypeSource (Proxy :: Proxy Timing)
"type Timing\n    = Start ()\n    | Continue  : Float\n    | Stop ()"

After this change:

*> toElmType (Proxy :: Proxy Timing)
ElmDatatype "Timing"
    (MultipleConstructors
        [ NamedEmptyConstructor "Start"
        , MultipleConstructors [ NamedConstructor "Continue" (ElmPrimitiveRef EFloat)
                               , NamedEmptyConstructor "Stop"
                               ]])
*> toElmTypeSource (Proxy :: Proxy Timing)
"type Timing\n    = Start\n    | Continue Float\n    | Stop"

Any pointers for how to achieve this without overlapping instances would be much appreciated :)

mattjbray commented 8 years ago

I see you've now fixed this in a different way.