> > (3) OK with GHC, error with Hugs:
> > 
> > f = \x -> m x
> > x = f()
> ...
> > - Is GHC's treatment of (3) a bug?
> 
> At first glance it looks a bit that way to me, but
> I will leave it for the more knowledgable Haskell experts
> to give you a definitive answer on that one.

IIRC it's a known bug in Hugs, and fixing it would be difficult as it is an artifact 
of the typechecking algorithm used.

GHC is correct, because f *is* monomorphic: the only use is at type ().  Thus f is 
given the type () -> (), rather than C a => a -> (), and thus no sharing is lost.  
However, detecting that f is only used at the one type involves sneaky look-ahead.

The monomorphism restriction is described in the Haskell Report (at www.haskell.org) 
in section 4.5.5.  I was going to give a reference to the relevant message on the 
Hugs-bugs or Hugs-users list, but I can't find it because the archive page has been 
split into 51 pages and I'm not going to search all of them! [hugs-bugs moderator 
please take note!]

HTH.

--KW 8-)

-- 
: Keith Wansbrough, MSc, BSc(Hons) (Auckland) ------------------------:
: PhD Student, Computer Laboratory, University of Cambridge, England. :
:  (and recently of the University of Glasgow, Scotland. [><] )       :
: Native of Antipodean Auckland, New Zealand: 174d47' E, 36d55' S.    :
: http://www.cl.cam.ac.uk/users/kw217/  mailto:[EMAIL PROTECTED]     :
:---------------------------------------------------------------------:




Reply via email to