[Haskell-cafe] State Monad
Iavor S. Diatchki
diatchki at cse.ogi.edu
Wed Mar 3 10:34:55 EST 2004
hi,
Georg Martius wrote:
> Now I have also functions to map from (a, String) -> (a,String).
> I could write:
>
> modifyT :: ((a, String) -> (a, String)) -> a -> State String a
> modifyT trans a = do str <- get
> let (a', str') = trans (a, str)
> put str'
> return a'
>
> f :: State String ()
> f = do put "hallo"
> modify strTrans
> i <- modifyT strIntTrans 4 -- strIntTrans :: (Int, String) ->
> (Int, String)
> i' <- modifyT strIntTrans i
> ...
>
> But this is obviously awkward. How can I stick two Monads in each
> other? I could't figure out how to use StateT. Any help would be
> appreciated.
>
> Thanks!
> Georg
could you be a little more specific on what you are trying to do?
what do you mean by sticking two monads in each other, do you want to
have two state componenets,
or perhaps work with computations that manipulate state, but can also
raise exceptions?
-iavor
--
==================================================
| Iavor S. Diatchki, Ph.D. student |
| Department of Computer Science and Engineering |
| School of OGI at OHSU |
| http://www.cse.ogi.edu/~diatchki |
==================================================
More information about the Haskell-Cafe
mailing list