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 = E{
> > refi :: STRef s Int,
> > refc :: STRef s Char,
> > m :: Int
> > }
> >
> > -- this is fine, obviously...
> > pure :: E s -> Int
> > pure e = m e
> >
> > -- but this is not...
> > pure2 :: (?e :: E s) => Int
> > pure2 = 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 '=>'
> > In the type: forall s. (?e :: E s) => 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.
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?
Thanks,
J.A.
_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe