[Haskell-cafe] Help to write type-level function

oleg at okmij.org oleg at okmij.org
Wed Feb 27 09:28:09 CET 2013


Dmitry Kulagin wrote:
> I try to implement typed C-like structures in my little dsl.

HList essentially had those
        http://code.haskell.org/HList/

> I was unable to implement required type function:
> type family Find (s :: Symbol) (xs :: [(Symbol,Ty)]) :: Ty
> Which just finds a type in a associative list.

HList also implemented records with named fields. Indeed, you need a
type-level lookup in an associative list, and for that you need type
equality. (The ordinary List.lookup has the Eq constraint, doesn't
it?) 

Type equality can be implemented with type functions, right now.
        http://okmij.org/ftp/Haskell/typeEQ.html#TTypeable

(That page also defined a type-level list membership function).








More information about the Haskell-Cafe mailing list