[Haskell-cafe] Equality constraints in type families

Hugo Pacheco hpacheco at gmail.com
Mon Mar 10 19:51:56 EDT 2008

Hi all,
I have encoded a type family such that:

type family F a :: * -> *

and a function (I know it is complicated, but I think the problem is self

hyloPara :: (Functor (F a), Functor (F d), F d a ~ F a (a,a), F d c ~ F a
(c,a)) => d -> (F d c -> c) -> (a -> F d a) -> a -> c
hyloPara d g h = g . fmap (hyloPara d g h) . h

it all works fine.

However, if I change the declaration to (changed F d c for the
"supposedly equivalent" F a (c,a)):

hyloPara :: (Functor (F a), Functor (F d), F d a ~ F a (a,a), F d c ~ F a
(c,a)) => d -> (F a (c,a) -> c) -> (a -> F d a) -> a -> c

and I get

    Occurs check: cannot construct the infinite type: c = (c, a)
    When generalising the type(s) for `hyloPara'

This really messes up my notions on equality constraints, is it the expected
behavior? It would be essential for me to provide this definition.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080310/3f7844e7/attachment-0001.htm

More information about the Haskell-Cafe mailing list