> > > (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.
Are you sure about this ? In my opinion the behaviour of Hugs is correct.
It is clear that the use of "f" in the definition of "x" is monomorphic but
that doesn't make true that "f" is monomorphic. I might import this module
and use
"f" at different types. In general I can only tell if a certain function is
used at only one
type if I either can see all the program code or if the scope of "f" is
restricted
to for example the current module.
-- Daan.