OK, I yield!

The HEAD now runs this program.  It turned out to be a case of
interchanging two lines of code, which is the kind of fix I like.

Simon


| -----Original Message-----
| From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Ashley Yakeley
| Sent: 07 September 2003 06:57
| To: [EMAIL PROTECTED]
| Subject: Circular Instance Declarations
| 
| When -fallow-undecidable-instances is switched on, is there any reason
| why circular instances are forbidden? For instance:
| 
|  module CircularInsts where
|     {
|     data D r = ZeroD | SuccD (r (D r));
| 
|     instance (Eq (r (D r))) => Eq (D r) where
|         {
|         ZeroD == ZeroD = True;
|         (SuccD a) == (SuccD b) = a == b;
|         _ == _ = False;
|         };
| 
|     newtype C a = MkC a deriving Eq;
| 
|     equalDC :: D C -> D C -> Bool;
|     equalDC = (==);
|     }
| 
| When I compile this, I get this:
| 
|  $ ghc -fglasgow-exts -fallow-undecidable-instances -c
CircularInsts.hs
|  CircularInsts.hs:2:
|     Context reduction stack overflow; size = 21
|     Use -fcontext-stack20 to increase stack size to (e.g.) 20
|         `Eq (C (D C))' arising from use of `==' at CircularInsts.hs:16
|         `Eq (D C)' arising from use of `==' at CircularInsts.hs:16
|         `Eq (C (D C))' arising from use of `==' at CircularInsts.hs:16
|         `Eq (D C)' arising from use of `==' at CircularInsts.hs:16
| 
| Would it be reasonable for the compiler to check back through the
stack
| and allow the circularity? It will just create an ordinary recursive
| function.
| 
| --
| Ashley Yakeley, Seattle WA
| 
| _______________________________________________
| Haskell mailing list
| [EMAIL PROTECTED]
| http://www.haskell.org/mailman/listinfo/haskell


_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to