Bug? [was: Implicit params]

Jorge Adriano jadrian@mat.uc.pt
Thu, 14 Nov 2002 21:09:42 +0000


On Thursday 14 November 2002 18:47, Iavor S. Diatchki wrote:
> hello,
>
> > Well, actually you must be right since the pure field defines a pure
> > (projection) function... Hmmm, ok, can someone explain this to me,
> >
> > data E s =3D E{
> >       refi :: STRef s Int,
> >       refc :: STRef s Char,
> >       m    :: Int
> >     }
> >
> > -- this is fine, obviously...
> > pure   :: E s -> Int
> > pure e =3D m e
> >
> > -- but this is not...
> > pure2 :: (?e :: E s) =3D> Int
> > pure2 =3D m (?e)
> >
> > Why exactly isn't this allowed? What is the workaround?
> > Error msg:
> > ---------------------------------------------------------------------=
---
> >     Ambiguous constraint `?e :: E s'
> >         At least one of the forall'd type variables mentioned by the
> > constraint
> >         must be reachable from the type after the '=3D>'
> >     In the type: forall s. (?e :: E s) =3D> Int
> >     While checking the type signature for `pure2'
> > Failed, modules loaded: none.
> > ---------------------------------------------------------------------=
----
> >-
>
> this seems like a bug in GHC.   Hugs is happy with it.  The "s" in the
> pure2 signature is not ambiguous because it is determined when you give
> the value of the implicit parameter.  in fact the way i think about
> implicit parameters is simply as a nice notation for computations in th=
e
> environment monad, so in my mind the above two definitions are pretty
> much the same.

Thanks Iavor!=20
GHC people, can you confirm this, Is it a bug? I'm using Ghc 5.0.4 SuSE r=
pms.
Is there a workaround?=20

Thanks,
J.A.