Type-Level Programming
The Prim module has sub modules that are not imported by default. Within these modules, Prim defines a few more things for type-level programming. These type classes' instances are derived by the compiler
Type-Level Types, Values, and Proxies
In the below table, "ValueTypeN" was abbreviated to VTN
Value-Level Type | Value-Level Value(s) | Kind Name (Corresponding Type‑Level Type) | Kind Values |
---|---|---|---|
Ordering | LT GT EQ | Ordering | LT GT EQ |
String | "literal string" | Symbol | "literal symbol" |
Record (closest idea) | Record (keyN :: VTN, ...) | Row | (keyN :: VTN, ...) |
Boolean | true /false | Boolean | True /False |
List ( keyN :: VTN, ... ) (analogy; not real type) | Nil Cons a (ListR a) | RowList | Nil Cons :: Symbol -> Type -> RowList |
Real-World examples
- purescript-alphasucc
- purescript-trout - Type-Level Routing. Used in purescript-hypertrout.
- purescript-kushikatsu - Simple type-level routing
- purescript-chirashi - An easy way to work with Errors by inserting a Variant, and reading it out later.
- purescript-variant
- purescript-typelevel-eval
Ideas
- Type-Safe Versioned APIs. This idea could be combined with the onion architecture and
Run