Re: [Haskell-cafe] Using promoted lists

2012-06-08 Thread Erik Hesselink
Hi Yves, The type level numbers have kind Nat, not Int (and so also can't be negative). They have to be imported from GHC.TypeLits (I'm not sure if this will change). So the following code works for me in HEAD: {-# LANGUAGE TypeFamilies, DataKinds #-} import GHC.TypeLits type family Something a

[Haskell-cafe] Using promoted lists

2012-06-07 Thread oleg
Yves Pare`s wrote: > So I'm trying to make a type level function to test if a type list contains > a type. Unless I'm wrong, that calls to the use of a type family. More crucially, list membership also calls for an equality predicate. Recall, List.elem has the Eq constraint; so the type-level mem

Re: [Haskell-cafe] Using promoted lists

2012-06-07 Thread Yves Parès
Thanks for your answers, Anthony and Erik. I'll try with fundeps. I know about HList, but back at the time when I looked at it I found quite complex. Anthony, the link you gave me [1] tends to show that actually Bool type is promoted. type family Member x (l :: [*]) :: Bool type instance Member

Re: [Haskell-cafe] Using promoted lists

2012-06-07 Thread Erik Hesselink
If you want to get rid of the overlap in your type families, you have to add an extra argument indicating if the two types are equal. For this, you need a type family to indicate equality of types. Sadly, the naive implementation (TEQ x x = True, TEQ x y = False) overlaps and isn't allowed. I'm not

Re: [Haskell-cafe] Using promoted lists

2012-06-07 Thread AntC
Yves Parès gmail.com> writes: > > The doc page http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/kind- polymorphism-and-promotion.html#promotion show that lists are now usable as types.So I'm trying to make a type level function to test if a type list contains a type. Unless I'm wrong, th

[Haskell-cafe] Using promoted lists

2012-06-07 Thread Yves Parès
The doc page http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/kind-polymorphism-and-promotion.html#promotionshow that lists are now usable as types. So I'm trying to make a type level function to test if a type list contains a type. Unless I'm wrong, that calls to the use of a type family.