Files
lux/examples/generics.lux
Brandon Lucas 3734a17e5c feat: implement generic type parameters
Add full support for user-defined generic types and functions:

- Add type_params field to TypeChecker to track type parameters in scope
- Update resolve_type() to resolve type parameters to their bound variables
- Update function_type() to bind type parameters and return polymorphic TypeScheme
- Update type declaration handling for generic ADTs (e.g., Pair<A, B>)

Generic functions and types now work:
  fn identity<T>(x: T): T = x
  type Pair<A, B> = | MkPair(A, B)
  fn first<A, B>(p: Pair<A, B>): A = ...

Add examples/generics.lux demonstrating:
- Generic identity function
- Generic Pair type with first/second accessors
- Generic mapOption function

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-13 09:20:36 -05:00

1.4 KiB