Elminator: Generate ELM types/encoders/decoders from Haskell types

If you are using Haskell on back end with an Elm front end, then tools that can generate Elm data types along with JSON encoders/decoders from Haskell data types, are probably an important part of your infra. There are a bunch of Haskell packages that address this issue. But from my own experience, if you try to use one of these, you very quickly run into some limitation regarding the type of Haskell data definitions they can handle, or the number of encoding options they support. This often causes you to limit yourself while defining data types on the Haskell side or use awkward workarounds so that they can be shared with Elm. This package is something I wrote as an attempt to solve these issues.

Some of the distinguishing features are

  1. Supports generation of polymorphic types (as well as concrete ones) in Elm from possibly polymorphic Haskell types, including types with phantom type variables.
  2. Supports generation of recursively defined types.
  3. Generates code that does not depend on external Elm libraries.
  4. Does not have limits on the number of fields that the constructors of your type can have.
  5. Supports JSON encoding options exported by the Aeson library comprehensively (The tests exhaustively check the Elm/Haskell round tripping of values for all possible configurations of Aeson.options)
  6. Supports generation of code that can depend on pre defined types and encoders/decoders in Elm.

Feedback and suggestion are welcome!

1 Like

Great work! I just finished porting servant-elm to elm-bridge to support Elm 0.19, but if elminator will be a better-supported lib, it’d probably be a good candidate for future switch.

Thank you.

if Elminator will be a better-supported lib

Sure that is the plan. One of my targets was to end up with a clean implementation and a bunch of comprehensive end-to-end tests, so that the whole thing would be amiable to future maintenance.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.