Bug? [was: Implicit params]

Simon Peyton-Jones simonpj@microsoft.com
Mon, 18 Nov 2002 14:26:27 -0000


Now fixed in the HEAD, and will be in 5.04.2

Thanks for pointing it out.

Simon

| -----Original Message-----
| From: Jorge Adriano [mailto:jadrian@mat.uc.pt]
| Sent: 14 November 2002 21:10
| To: Iavor S. Diatchki
| Cc: Haskell Cafe; glasgow-haskell-users@haskell.org
| Subject: Bug? [was: Implicit params]
|=20
| 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
the
| > environment monad, so in my mind the above two definitions are
pretty
| > much the same.
|=20
| Thanks Iavor!
| GHC people, can you confirm this, Is it a bug? I'm using Ghc 5.0.4
SuSE rpms.
| Is there a workaround?
|=20
| Thanks,
| J.A.
|=20
|=20
|=20
| _______________________________________________
| Glasgow-haskell-users mailing list
| Glasgow-haskell-users@haskell.org
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-users