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.
bye
iavor
--
==================================================
| Iavor S. Diatchki, Ph.D. student |
| Department of Computer Science and Engineering |
| School of OGI at OHSU |
| http://www.cse.ogi.edu/~diatchki |
==================================================
_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe