
007: Extending Elm
We discuss what Elm is intended for, techniques for going beyond that, and how to make tools nice to use when you do.
Audio is streamed directly from the publisher (cdn.simplecast.com) as published in their RSS feed. Play Podcasts does not host this file. Rights-holders can request removal through the copyright & takedown page.
Show Notes
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)