Tune in to the tools and techniques in the Elm ecosystem.
007: Extending Elm
June 29, 2020
0:58:54
56.75 MB
Downloads: 0
What can you do with Elm?
- Html
- Http
- Ports
- Web Components
Different techniques for extending elm
Codegen
Macros
Wrapper elm apps
Can emulate effect managers
Platform.worker
Introspection
Ports and flags
Web Components
Code transformation
Elm asset loader webpack
Hacking JS to get FFI
Depending on internal details could end up with broken code
elm-hot and elm-hot-webpack-loader
Pitfalls and considerations
Codegen
- Have a single clear source of truth for codegen
- Prevent bad states with airtight abstractions, rather than having lots of caveats
- Make sure public APIs for generated code look nice
- Use doc comments
Macros
- Elm code that doesn’t look like elm code
- Tooling doesn’t work then - see Babel ecosystem
- Violates Open close principle - you’re modifying the language, not extending it
Provide a platform with extensions in mind when you build tools so you don’t require users to hack
When you build a tool, think about the mental model for uses, let that guide you. Avoid leaky abstractions
Be opinionated about the core things, and unopionated about what’s not essential to the tool
[elm-spa](https://github.com/ryannhg/elm-spa)