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: haskell-admin@haskell.org [mailto:haskell-admin@haskell.org] On Behalf Of Ashley Yakeley | Sent: 07 September 2003 06:57 | To: haskell@haskell.org | 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 | Haskell@haskell.org | http://www.haskell.org/mailman/listinfo/haskell
In article <4B93206CA3C55D4F96A61C9B1DC80DE343920D@EUR-MSG-03.europe.corp.microsoft .com>, "Simon Peyton-Jones" <simonpj@microsoft.com> wrote:
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.
Cool, thanks. -- Ashley Yakeley, Seattle WA
On Thu, 11 Sep 2003, Simon Peyton-Jones wrote:
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
Cool! Yet another domain where haskell handles infinities quite happily. Thanks. Hopefully I'll have some code to contribute soon. Brandon
| -----Original Message----- | From: haskell-admin@haskell.org [mailto:haskell-admin@haskell.org] On Behalf Of Ashley Yakeley | Sent: 07 September 2003 06:57 | To: haskell@haskell.org | 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 | Haskell@haskell.org | http://www.haskell.org/mailman/listinfo/haskell
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
participants (3)
-
Ashley Yakeley -
Brandon Michael Moore -
Simon Peyton-Jones