Typle
Expression-level compile-time type query and introspection library.
provides expression-level type queries and introspection mechanisms at compile time in Elixir.
The Pitch
Elixir's dynamic typing allows rapid iteration, but complex macro metaprogramming and library DSLs often need to inspect and assert types of AST expressions before runtime code generation.
Typle enables compile-time type querying and type assertion directly on AST expressions. Query types, validate struct fields, and check function argument types during macro expansionโcatching shape mismatches before code is compiled into BEAM bytecode.
Why Typle?
Expression-Level Type Queries
Inspect structural types of Elixir AST expressions directly inside macro bodies.
Zero Runtime Overhead
Type checks and resolution happen entirely at compile time during macro expansion.
Enhanced Guard & Pattern Assertions
Construct stricter macro expansions based on verified input expression shapes.
Metaprogramming Primitive
Integrates cleanly with domain-specific languages, AST generators, and compiler extensions.
The Tech
| Language | Elixir |
| Stage | Compile-Time Macro Expansion |
| Feature | AST Type Introspection |
| Hex Package |
typle
|
Who It's For
- Elixir Macro Authors building complex code generation pipelines or DSLs.
- Library Developers requiring compile-time type verification on macro inputs.
- Metaprogramming Engineers exploring static type capabilities within Elixir AST.
Bottom Line
Query and assert expression types at compile time within Elixir macros using Typle.