[Haskell-beginners] State monad question

Jordan Cooper nefigah at gmail.com
Wed Jun 23 17:10:00 EDT 2010

I have two pieces of state I'm managing:
type FooState = State Foo Foo
type BarState = State Bar Bar

There is a bit of interplay between them, and I want a function that
does something like:
importantFunction :: Foo -> Bar -> (Foo, Bar)

The problem is, >>= only works when I'm chaining all of the same type
of state. So I can't do:
modifiesFoo >>= \foo ->
modifiesBar foo >>= \bar ->
return (foo, bar)

So how do I get the results of both modifications back? I hope that
makes sense. Programming in Haskell is proving to be very difficult; I
once again fear I'm too stupid.

More information about the Beginners mailing list