Tutorial by Examples

Type synonym families are just type-level functions: they associate parameter types with result types. These come in three different varieties. Closed type-synonym families These work much like ordinary value-level Haskell functions: you specify some clauses, mapping certain types to others: {-# ...
Data families can be used to build datatypes that have different implementations based on their type arguments. Standalone data families {-# LANGUAGE TypeFamilies #-} data family List a data instance List Char = Nil | Cons Char (List Char) data instance List () = UnitList Int In the above de...
Type Families are not necessarily injective. Therefore, we cannot infer the parameter from an application. For example, in servant, given a type Server a we cannot infer the type a. To solve this problem, we can use Proxy. For example, in servant, the serve function has type ... Proxy a -> Server...

Page 1 of 1