Re: Ambiguity

1998-02-25 Thread Simon L Peyton Jones


 Except that this isn't actually allowed because happyReduce_1 appears
 in a restricted binding group, and hence can't have any context in its
 type.  So, at this point, Hugs complains.  GHC, I assume, just assigns
 hugsReduce_1 a monomorphic type, only to find at some later point that
 the list instance of Functor (and only that instance) are required to
 make things type check.
 
 Hugs is perhaps too eager in complaining, but it can't assign anything
 other than a fully polymorphic type to top-level terms, so it doesn't
 really have much choice.  For now, the simplest fix would seem to be to
 use a non-overloaded map function.

... or to give an argument to happyReduce_1, which would
mean it wasn't restricted any more...

I think that's an accurate diagnosis. The interesting questions are:

a) which compiler is implementing the language definition?
b) is the langauge definition "right"?

A quick look at 4.5.5 of the 1.4 report suggests that GHC
is implementing the language definition and Hugs is not.
The monomorphism restriction simply says you can't generalise
that type variable.  The report gives examples that make
it clear that you are expected to be able to use the monomorphic
definition at any one type in the module.

Whether this "monomorphism restriction" is the "right" language spec is hotly
debated. But it seems fine to me.

Simon





is this a bug?

1998-02-25 Thread Marko Schuetz

ghc-3.01 complains about a syntax error in the following cut down
program:

 module Fehler where

 data Constr 
  = (:-:) { expr :: LambdaCExpr, context :: ContextTerm }

kinetic% ghc Fehler.hs
Fehler.hs:4:12: parse error on input: "{"

Hugs 1.4 accepts the module and seems to do what was intended.

Marko

P.S. I would like to see my ghc use shared libraries. Is there any
information/documentation on the subject? I am running FreeBSD 2.2.5.