ghc hung by FunctionalDependencies/UndecidableInstances
Simon PeytonJones
simonpj at microsoft.com
Thu Oct 29 05:53:59 EDT 2009
No, it's behaving exactly as expected. If you omit UndecidableInstances the program is rejected. If you add that flag you are saying "you are allowed to diverge if I screw up". And indeed you wrote a looping type problem.
I added some comments below that may help explain.
Simon
{# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, UndecidableInstances #}
module X() where
class C a b  a > b where f :: a > b
newtype T a = T a
instance (C a b, Eq b) => Eq (T a) where (==) = undefined
g x = (undefined :: d > d > d > ()) (T x) (f x) (undefined :: Eq e => e)
 f :: C a b => a > b
 x :: a
 b ~ T a
 C a b
 b ~ e
 Eq e
{
Hence need (C a (T a), Eq (T a))
Apply instance for Eq
= (C a (T a), C a g, Eq g)
Apply functional dependency: g ~ T a
= (C a (T a), C a (T a), Eq (T a))
And now we are back where we started
}
 Original Message
 From: glasgowhaskellusersbounces at haskell.org [mailto:glasgowhaskell
 usersbounces at haskell.org] On Behalf Of Roland Zumkeller
 Sent: 29 October 2009 04:55
 To: glasgowhaskellusers at haskell.org
 Subject: ghc hung by FunctionalDependencies/UndecidableInstances

 Hi,

 ghc seems to hang and eat memory when fed the following code:

 {# LANGUAGE MultiParamTypeClasses, FunctionalDependencies,
 UndecidableInstances #}
 class C a b  a > b where f :: a > b
 newtype T a = T a
 instance (C a b, Eq b) => Eq (T a) where (==) = undefined
 g x = (undefined :: a > a > a > ()) (T x) (f x) (undefined :: Eq a => a)

 Is this a bug?

 Best,

 Roland

 
 http://alacave.net/~roland/
 _______________________________________________
 Glasgowhaskellusers mailing list
 Glasgowhaskellusers at haskell.org
 http://www.haskell.org/mailman/listinfo/glasgowhaskellusers
More information about the Glasgowhaskellusers
mailing list