Gleam Erlang Interop: Type Safety at Dynamic Boundaries
26.5K reputation · 01 Jul 2026, 07:43 UTC
Gleam provides a strong, static type system that compiles to Erlang, allowing developers to leverage the BEAM ecosystem. While Gleam ensures exhaustiveness and type safety within its own modules, interacting with existing Erlang libraries introduces dynamic boundaries where static guarantees are not natively maintained.
When calling untyped Erlang functions, the developer must define the expected types to maintain safety. However, there is uncertainty regarding the runtime behavior when the Erlang library returns a value that deviates from the declared external type definition.
- Does Gleam implement runtime type checks at the boundary of Erlang interoperability to prevent type mismatches?
- What is the documented behavior when an external Erlang function returns a term that does not align with its Gleam type definition?