#1775: type families: poor error massages when lacking instances
-----------------------+----------------------------------------------------
Reporter: guest | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.8
Severity: normal | Keywords:
Difficulty: Unknown | Os: Unknown
Testcase: | Architecture: Unknown
-----------------------+----------------------------------------------------
The following code:
{{{
{-# LANGUAGE TypeFamilies #-}
type family Elem a
class Collection a where
cons :: Elem a -> a -> a
-- type instance Elem [a] = a
instance Collection [a] where
cons = (:)
}}}
clearly should not compile, as I have commented out the instance
declaration for 'Elem [a]'.
The error message provided is less than helpful:
{{{
GHCi, version 6.8.0.20071012: http://www.haskell.org/ghc/ :? for help
Loading package base ... linking ... done.
[1 of 1] Compiling Main ( Test.hs, interpreted )
Test.hs:10:0:
Occurs check: cannot construct the infinite type: a = Elem [a]
When trying to generalise the type inferred for `cons'
Signature type: forall a. Elem [a] -> [a] -> [a]
Type to generalise: Elem [a] -> [a] -> [a]
In the instance declaration for `Collection [a]'
Failed, modules loaded: none.
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1775>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs