--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
shapeDecoder =field "@type" string|> andThen toShapetoShape str =case str of"Circle" ->map CircleAsShape circleDecoder"Rectangle" ->map RectangleAsShape rectangleDecoder_ ->fail ("unknown shape: " ++ str)
A previous version of the `andThen` documentation actually used circles and rectangles as the motivating example. It's since switched to versioned objects, which are maybe a little more realistic. Did you choose circles and rectangles as your example here for that reason, or are you really working with shapes? (I also wrote a blog post about `andThen` that explains that example, but beware the 0.17 syntax.)If you don't have any reason to separate your `Circle` and `Rectangle` types, you might also consider defining them in `Shape` directly. That way `CircleAsShape` would become `Circle`.
In the simpler cases you can use oneOf with the subtypes first, but I get your point. Plus, andThen will be much faster. ;)
--
You received this message because you are subscribed to a topic in the Google Groups "Elm Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elm-discuss/0I25pg51rK8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elm-discuss...@googlegroups.com.