| > | newtype Show (f (Fix f)) => Fix f = In (f (Fix f))
| > |   deriving Show
| > | 
| > | newtype Nat = MkNat (Fix Maybe)
| > |   deriving Show
| ...
| To be honest, I don't see why there should be a problem here. In order to
| show data of type Fix Maybe we need the instance Show (Maybe (Fix Maybe)).
| But that already exists since we have the instance Show (Maybe a).

You have to look at the instances that would be used in this case.  To start
with, we're assuming the instance for Show on Maybe:

    Show a => Show (Maybe a),

which is needed here in the case where a = Fix Maybe:

    Show (Fix f) => Show (Maybe (Fix Maybe).

And then there's the instance that we derive for Show on Fix:

    Show (f (Fix f)) => Show (Fix f),

which is needed here in the case where f = Fix Maybe:

    Show (Maybe (Fix Maybe)) => Show (Fix Maybe).

You'll notice here that we now have a pair of instances of the form P => Q
and Q => P.  We start with a goal P, which we can reduce to Q, which we can
reduce to P, which we can reduce to Q, ...

In this case, we could actually avoid the infinite loop by memoizing/using
a cyclic proof.  There's a two character tweak that you can make to my
`Typing Haskell in Haskell' type checker to support this kind of thing,
but I'm afraid it's a lot more difficult to do in the current Hugs
implementation.  But there are examples where this won't be enough; I
posted one in an earlier message.

| This is a relief. But then, why do you need the iterating stuff in hugs?

Iteration is the easiest way that I know to calculate a fixed point.  So
that's what Hugs uses.  Because of a bug in earlier distributions, Hugs
sometimes cut off those iterations more quickly than it should have.  It
would have been possible to modify Hugs to disable to iteration cutoff
mechanism when it was running in Haskell 98 mode; syntactic restrictions
in Haskell would have ensured that this did not lead to nontermination.
But, morally, this would have been the wrong approach.  Instead, we fixed
the bug, which should mean that, even with fairly modest cutoff values (-c),
you should only normally see the error in cases where there is a genuine
problem, regardless of whether you're running in Haskell 98 or Hugs mode.

| Well, perhaps this is a storm in a teacup but I feel that it's important
| to sort these issues out.

Well I hope this has helped, and that we can now put this discussion to rest!
But if there is any further discussion, I suggest that we move over to private
email; we're not really in hugs-users territory anymore.  If anyone else
reading this wants to be involved, make sure you let Josef and me know!

All the best,
Mark

----------------------------------------------------------------------------
[EMAIL PROTECTED]  Pacific Software Research Center, Oregon Graduate Institute
Looking for a PhD or PostDoc?  Interested in joining PacSoft?  Let us know!

Reply via email to