That looks a bit clumsy to use from JS land though... if you want to read numberOfDoors you'll have to loop through all the fields to find the correct one? The format has to be both correct and easy to work with.
fredag 3. mars 2017 19.42.52 UTC+1 skrev Rupert Smith følgende: > > On Friday, March 3, 2017 at 4:35:00 PM UTC, Eirik Sletteberg wrote: >> >> type alias Car = >> { numberOfDoors: Int >> } >> >> type alias Plane = >> { maxSpeed: Int >> } >> >> type Transport = Walk >> | Ride Car >> | Fly Plane >> > > Or could be mapped to something that can be described with a json-schema > enum for each 'tag' in the union type: > > { _type: "Walk" } > > { _type: "Ride" > , fields : [ {numberOfDoors: 1} ] > } > > { _type: "Fly" > , fields: [ { maxSpeed: 100 } ] > } > > Where 'fields' is a list of the constructor arguments. Would be nice if I > could always find a 1:1 mapping between the Elm type and a json-schema. > > > -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.