Hi, I can't figure out why the following program compiles with this instance declaration
instance Size (Maybe [a]) => Size [a] where size x = size (foo x)
but has GHC loop forever with this one:
instance (Foo a b, Size b) => Size a where size x = size (foo x)
Anybody here know? Thanks, - Benja
{-# OPTIONS_GHC -fglasgow-exts -fallow-overlapping-instances -fallow-undecidable-instances #-} class Foo a b | a -> b where foo :: a -> b instance Foo [a] (Maybe [a]) where foo (x:xs) = Just xs; foo [] = Nothing class Size a where size :: a -> Int instance Size a => Size (Maybe a) where size (Just x) = 1 + size x; size Nothing = 0 --instance (Foo a b, Size b) => Size a where size x = size (foo x) -- OR --instance Size (Maybe [a]) => Size [a] where size x = size (foo x) main = print $ size "foo"
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe