
Hi Gautier,
So, you mean that there is no way to fit a (* -> * -> *) or so when a (* -> *) is required?
No.If you decide on a kind signature ([k], [k]), you have to use '(,) not (,) when making types for that kind. Similarly if you have a type [xs], the kind of that is * which doesn't match the kind [k] you specify.
For example, this week I worked on a zipWith ($) version for HList, I have this code: data HApL :: [*] -> [*] -> * where Nil2 :: HApL '[] '[] (:**) :: (a -> b) -> HApL as bs -> HApL (a ': as) (b ': bs)
infixr 5 :**
zipWithHApL :: HApL xs ys -> HList xs -> HList ys zipWithHApL Nil2 HNil = HNil zipWithHApL (x :** xs) (HCons y ys) = x y `HCons` zipWithHApL xs ys
It doesn't satisfy me because: 1. I had to create an ad hoc data-type to manage it, instead of [] deal with it out-of-the-box 2. There no easy way to convert HList to HApL
There is no way to get HList closer than List?
I'm not sure. With the HList library on hackage, you can do the equivalent of zipWithDollar xs ys = map ($) (zip xs ys) by defining: data Dollar = Dollar instance (fx ~ (x -> y, x)) => ApplyAB Dollar fx y where applyAB _ (f,x) = f x hZipWithDollar xs ys = hMap Dollar (hZip xs ys) It works like:
hZipWithDollar (hBuild (+1) tail) (hBuild 3 "ab") H[4, "b"]
But in more complicated cases there is a tendency to need -XAllowAmbiguousTypes, which means writing type signatures (with -XScopedTypeVariables) that should be unnecessary. Regards, Adam