🐋 The API is quite big, so expect lots of changes! 🔨
There are many use-cases for generating elm code:
{|}
record field helpers, lenses: hayleigh's elm-record-helpers, ...[n]
data structures of different sizes: bburdette's toop, Chadtech's elm-vector, lue-bird's elm-bounded-nat Nats, typesafe-array ArraySized.to-/l2-16, ...{,}
json (, bytes?, xml?, yaml?, ...) decoders, encoders, codecs: dkodaj's decgen with a CLI: FranzSkuffka's elm-coder-generator, alexkorban's json2elm & its review rule, wscherphof's json-to-elm, spkerkela's elm-decoder-generator, miniBill's elm-codec-generator, ...- 🧪 tests from elm documentation examples: stoeffel's elm-verify-examples, ...
</>
html (, other html libs?): dillonkearns's elm-review-html-to-elm, korban's elmstatic, CodeTownOfficial's html-to-elm & rubymaniac's vscode-html-to-elm, pzavolinsky's elmx, necinc's elmmet...- 🖼️ svg (, typed-svg?, ...): jackfranklin's svg-to-elm, ChristophP's parcel-transformer-elm-svg-modules, massimo-zaniboni's svg-to-elm, pinata-llc's svg2elm, janwirth's svg-folder-to-elm-module ...
- 💨 tailwind utilities: matheus23's elm-tailwind-modules
- ☊ graphql: dillonkearns's elm-graphql, harmboschloo's graphql-to-elm, ...
- ☁️ aws services: the-sett's elm-aws-codegen
- 📃 protobuf: feral-dot-io's protoc-gen-elmer
- ...
Elm code generation can be simplified! elm-review-codegen
🤜🤛 elm-review
🤜🤛 elm-codegen
:
- run without separate command line tools or IDE plugins
- one simple way to configure, customize and create all code generators
- adding necessary imports, reporting failed/successful code generation etc. is handled automatically by
elm-codegen
module ReviewConfig exposing (config)
import Review.Generate
import Elm.Generator.RecordFieldHelper as RecordFieldHelper
import Elm.Generator.Svg as Svg
import Review.Rule exposing (Rule)
config : List Rule
config =
[ Review.Generate.inModule
( "Accessors", [ "Library", "Fields" ] )
RecordFieldHelper.accessors
|> Review.Generate.rule
, Review.Generate.replaceStub "svgToGenerate"
Svg.generator
|> Review.Generate.rule
]
limits of elm-review
😢
- can't make new modules or directories (yet)
- can't access online resources
To overcome these limitations,
you can build a tool that generates an elm module with the necessary information
and run elm-review
with generate-elm
as a second step.
→ contributing.