Usage of | in classes

Hi, Gracjan's question led me to another question:
class Monad m => Ref m r | m -> r where newRef :: a -> m (r a) readRef :: r a -> m a writeRef :: r a -> a -> m ()
What's the meaning of the bar and the function type in this declaration. I've seen something like that before (with state monads, I think), but couldn't find an explanation in the Haskell grammar (or anywhere else on haskell.org). Thanks in advance, Frank-Andre

On Tue, Jun 07, 2005 at 03:54:06PM +0200, Frank-Andre Riess wrote:
Hi,
Gracjan's question led me to another question:
class Monad m => Ref m r | m -> r where newRef :: a -> m (r a) readRef :: r a -> m a writeRef :: r a -> a -> m ()
What's the meaning of the bar and the function type in this declaration. I've seen something like that before (with state monads, I think), but couldn't find an explanation in the Haskell grammar (or anywhere else on haskell.org).
It is a functional dependency. That is, in this case, the choice of type r is uniquely determined by the choice for the type m. See also http://haskell.org/hawiki/FunDeps and http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html...
Thanks in advance,
My pleasure. Doei, Arthur. -- /\ / | arthurvl@cs.uu.nl | Work like you don't need the money /__\ / | A friend is someone with whom | Love like you have never been hurt / \/__ | you can dare to be yourself | Dance like there's nobody watching
participants (2)
-
Arthur van Leeuwen
-
Frank-Andre Riess