How to interpret the definition of MonadState

I am confused about the definition of MonadState. The opening line looks like this: class Monad m => MonadState s m | m -> s where It is the vertical bar | that confuses me. What does that mean? How would one read this line in "natural language", say English? Thanks. - J -

On Tuesday 07 June 2011, 16:59:44, djp@arqux.com wrote:
I am confused about the definition of MonadState. The opening line looks like this:
class Monad m => MonadState s m | m -> s where
It is the vertical bar | that confuses me. What does that mean? How would one read this line in "natural language", say English?
The vertical bar signifies a functional dependency (cf. the ghc users' guide for details). It says here, that the monad determines the type of the state. Read it class (demanding a Monad instance for m) MonadState m s, m determining s uniquely, where ...

Thanks, Daniel.
Quoting Daniel Fischer
On Tuesday 07 June 2011, 16:59:44, djp@arqux.com wrote:
I am confused about the definition of MonadState. The opening line looks like this:
class Monad m => MonadState s m | m -> s where
It is the vertical bar | that confuses me. What does that mean? How would one read this line in "natural language", say English?
The vertical bar signifies a functional dependency (cf. the ghc users' guide for details). It says here, that the monad determines the type of the state.
Does that mean it's ghc specific, i.e. not in Haskell 98 / 2010?
Read it
class (demanding a Monad instance for m) MonadState m s, m determining s uniquely, where ...

On Tue, 07 Jun 2011 17:35:45 +0200,
Thanks, Daniel.
Quoting Daniel Fischer
: On Tuesday 07 June 2011, 16:59:44, djp@arqux.com wrote:
I am confused about the definition of MonadState. The opening line looks like this:
class Monad m => MonadState s m | m -> s where
It is the vertical bar | that confuses me. What does that mean? How would one read this line in "natural language", say English?
The vertical bar signifies a functional dependency (cf. the ghc users' guide for details). It says here, that the monad determines the type of the state.
Does that mean it's ghc specific, i.e. not in Haskell 98 / 2010?
That is correct. Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html --

djp@arqux.com wrote:
class Monad m => MonadState s m | m -> s where
It is the vertical bar | that confuses me. What does that mean? How would one read this line in "natural language", say English?
The vertical bar signifies a functional dependency (cf. the ghc users' guide for details). It says here, that the monad determines the type of the state.
Does that mean it's ghc specific, i.e. not in Haskell 98 / 2010?
It's a type system extension, which is not in any standard. But associated types (a special kind of type families) serve essentially the same purpose in a cleaner way. class MonadState m where type StateOf m get :: m (StateOf m) put :: StateOf m -> m () instance MonadState (State s) where type StateOf (State s) = s ... This is equivalent to the definition with fundeps. You can find TF-based monad transformer libraries. Their package names usually end with "-tf" to indicate this. Greets, Ertugrul -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://ertes.de/

On Tuesday 07 June 2011, 17:35:45, djp@arqux.com wrote:
Does that mean it's ghc specific, i.e. not in Haskell 98 / 2010?
It's not in haskell98 or haskell2010, but I think hugs also supports functional dependencies (however, hugs is pretty much dead, last release September 2006). I don't know which extensions other compilers support, not even which of them should be considered alive.
participants (4)
-
Daniel Fischer
-
djp@arqux.com
-
Ertugrul Soeylemez
-
Henk-Jan van Tuyl