type family F a (F a) -- 1 the instance Context => Class a Ganesh posted the following example on haskell-cafe:
foo :: TheFoo a bar (Right b) = foo" (foo b :: a) instance Foo Int where type TheFoo Int = Int foo = id foo" = id val :: Either Int Int val = Left 5 res :: Int res = bar val a b) where bar (Left a) = foo" a bar (Right b) = foo" (foo b :: a) instance Foo Int where type TheFoo Int = Int foo = id foo" = id val :: Either Int Int val = Left 5 res :: Int res = bar val
type check as the type of By an interesting case, considering this type family application desugaring: Unknown/Multiple .
Compiler (Type checker)
{-# LANGUAGE ScopedTypeVariables, TypeFamilies, UndecidableInstances #-} module Test1a where class Foo a {-# LANGUAGE ScopedTypeVariables, TypeFamilies, FlexibleInstances #-} module Test1a where class Foo a -> Int class Bar b where bar :: b -> Int instance (b ~ TheFoo a, Foo a) => Bar (Either a -> a => Bar (Either a (TheFoo a)) where bar (Left a) = foo" a foo" :: a -> Int class Bar b where bar :: b -> Int instance Foo a where type TheFoo a where type TheFoo a foo :: TheFoo a foo" :: a -> Timeline Last modified 2 months ago , although it shouldn"t.
#2203 (TFs in class instances heads) - GHC - Trac Darcs Repositories forall a ~ b => .. fa .. Forgot your password? .