
I am reading the article from Monad Reader issue #8 called Type-Level Instant Insanity by Conrad Parker and I don't understand the part on recursive types. data Nil data Cons x xs data x ::: xs infixr 5 ::: class ListConcat a1 a2 a | a1 a2 -> a where listConcat :: a1 -> a2 -> a instance ListConcat Nil a a where listConcat = _|_ instance (ListConcat xs ys zs) => ListConcat (x ::: xs) ys (x ::: zs) where listConcat = _|_ 1. How does the last function becomes recursive? 2. Why do we need constraint '(ListConcat xs ys zs) =>' ? 3. I assume that listConcat function takes three arguments but from example provided, it takes two (see below): 4. Does the functional dependency sign (->) implies that the last argument is the return type? Main> :type listConcat (u:: R ::: G ::: B ::: Nil) (u:: W ::: Nil) listConcat (u::R:::G:::B:::Nil) (u::W:::Nil)::(:::) R ((:::) G ((:::) B ((:::) W Nil))) Thanks a lot. Malik