5 Jul 22:35 2013

## same function's type accepted in top level, but rejected in where clause

Ömer Sinan Ağacan <omeragacan <at> gmail.com>

2013-07-05 20:35:01 GMT

2013-07-05 20:35:01 GMT

Hi all, I came across an interesting type checker error, a function is accepted in top level, but rejected by type checker when moved to `where ...` clause. I moved required code to a new module for demonstration purposes: module Bug where fix :: (a -> a) -> a fix f = let x = f x in x data Fix f = Fix (f (Fix f)) unFix :: Fix f -> f (Fix f) unFix (Fix a) = a data ListF a l = NilF | ConsF a l instance Functor (ListF a) where fmap _ NilF = NilF fmap f (ConsF a l) = ConsF a (f l) fold :: Functor f => (f a -> a) -> Fix f -> a fold f a = f (fmap (fold f) (unFix a {- f (Fix f) -})) unfold :: Functor f => (a -> f a) -> a -> Fix f unfold f a = Fix (fmap (unfold f) (f a))(Continue reading)