Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Ross Paterson <ross-YRriatAoArbQzY9nttDBhA <at> public.gmane.org>
Subject: terminating instances
Newsgroups: gmane.comp.lang.haskell.prime
Date: Monday 3rd April 2006 10:53:05 UTC (over 11 years ago)
GHC 6.4 has rather conservative constraints on instances to guarantee
termination.  GHC 6.5 has more liberal constraints; see

http://haskell.galois.com/cgi-bin/haskell-prime/trac.cgi/wiki/FlexibleInstances

Unfortunately instances generated by newtype-deriving need not satisfy
either of these constraints (but the newtypes are required to be
non-recursive).  I can't construct a problem example for the 6.4 rules
(but nor is there an obvious termination ordering).  However the following
is non-terminating (caught by the depth limit) for GHC 6.5:

class C a where foo :: a -> Bool

-- instance C (f (Maybe a) a a) => C (Bar f a)
newtype Bar f a = Bar (f (Maybe a) a a) deriving C

instance C (Bar (,,) a) => C (a,b,c) where
        foo (a,b,c) = foo (Bar (Just a,a,a))

f = foo ('a', 'b', 'c')
 
CD: 4ms