[project @ 2001-08-22 11:45:06 by sewardj]
[ghc-hetmet.git] / ghc / tests / programs / dmgob_native1 / MaybeStateT.lhs
1         This module implements the ``State Transformer''
2 monad coupled with the ``Maybe'' monad, where the ``Maybe'' type is
3 wrapped around the pair containing the return value and the state.
4         \begin{haskell}{MaybeStateT}
5
6 > module MaybeStateT(
7 >#ifndef __GLASGOW_HASKELL__
8 >       Maybe..,
9 >#endif
10 >       MST(..),
11 >       returnMST,
12 >       bindMST
13 >       ) where
14
15 >#ifndef __GLASGOW_HASKELL__
16 > import Maybe
17 >#endif
18
19 > type MST s a  =  s -> Maybe (a, s)
20
21 > returnMST     :: a -> MST s a
22 > returnMST x   = \s -> Just (x, s)
23
24 > bindMST       :: MST s a -> (a -> MST s b) -> MST s b
25 > bindMST m k s =  m s >>= \(x, s') -> k x s'
26
27 \end{haskell}