On Thu, 11 Nov 1999, Mark P Jones wrote:

> | The program that didn't work with hugs (hugs98 septemeber, -98 or +98
> | doesn't matter) but worked with ghc was this:
> | 
> | newtype Show (f (Fix f)) => Fix f = In (f (Fix f))
> |   deriving Show
> | 
> | newtype Nat = MkNat (Fix Maybe)
> |   deriving Show
> 
> Ok, this is a different program to the one I tried because it includes
> the Nat definition; your previous message mentioned only Fix, so I left
> out Nat.  The behavior of this program with Hugs surprises me not; I
> wouldn't expect it to work.  The behavior of ghc is a mystery, however.
> And in fact on my machine, with the very latest ghc 4.045, the example
> doesn't work, delivering an error instead:
> 
>     No instance for `Show (f (Fix f))'
>     When deriving classes for `Fix'
> 
> This seems like the correct behavior to me and I don't know why you are
> seeing different results.  If you can get it to compile, have you tried
> actually using the derived show functions?  Do they work?
> 
Yes, it compiles alright (if I add 'module Foo where' in the beginning of
the program ofcourse).
But actually using the instance proved more difficult. I tried to add the
following line to my program above:

main = putStr $ show (In (Just (In Nothing)))

When I compile with ghc-4.04 I get:

    No instance for `Show (Fix Maybe)'
        arising from use of `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).

> | So this means that there are actually undecidable stuff in the haskell
> | language, right?
> 
> If Haskell allowed definitions like the above, then you would be correct.
> But it doesn't: with my interpretation of the report, those definitions
> are not legal in Haskell 98, and so a Haskell system should reject them.
> ... which is precisely what happens in my experiments with Hugs and ghc!
> 
This is a relief. But then, why do you need the iterating stuff in hugs?

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

        /Josef

----------------------------------------------------------
|Josef Svenningsson|http://www.dtek.chalmers.se/~d95josef|
|Rubingatan 39     |  email: [EMAIL PROTECTED]   |
|421 62 G�teborg   |          tel: 031-7090774           |
----------------------------------------------------------
What is a magician but a practising theorist?
                -- Obi-Wan Kenobi

Reply via email to