[Haskell-cafe] Hiding "growing" state using existentials.
stephen.tetley at gmail.com
Tue Aug 16 09:23:25 CEST 2011
You can't define (>>=) if your state type changes:
(>>=) :: m a -> (a -> m b) -> m c
Whereas, your bind is effectively three different parametric types:
_bind :: m1 a -> (a -> m2 b) -> m3 b
You can use parametric monads to represent state changing within a
monad. Oleg Kiselyov has tutorials on their use on his website (search
for the Monadish class). The SHE experimental extension of Haskell
also has parametric monads built in.
bindish :: m s1 a -> (a -> m s2 b) -> m s2 b
I don't think parametric monads will solve your problem though, as you
want a product of the states as the result of bind. Are you really
sure you want this behavior?, I'd imagine it breaks the monad laws
More information about the Haskell-Cafe