[Haskell-cafe] Can't get my head round monad transformers
colinpauladams at googlemail.com
Thu Sep 3 02:17:37 EDT 2009
Thanks. That was all I needed to sort it out.
2009/9/2 Martijn van Steenbergen <martijn at van.steenbergen.nl>:
> Hi Colin,
> Colin Adams wrote:
>> I'm trying to add a state monad onto the IO monad for use in a
>> happstack application. I thought this should involve using StateT and
>> Happstack.Server.SimpleHTTP.simpleHTTP', but I can't figure out how to
>> plumb it all together. Any tips will be welcome.
> I'm not familiar with Happstack, but looking at the documentation:
>> simpleHTTP' :: (Monad m, ToMessage b) =>
>> (m (Maybe (Either Response a, FilterFun Response)) ->
>> IO (Maybe (Either Response b, FilterFun Response))) ->
>> Conf ->
>> ServerPartT m a ->
>> IO ()
> Do I understand correctly you will be working with a
>> myAction :: ServerPartT (StateT S IO) A
> Then it seems that you may call simpleHTTP' like this:
>> (\action -> evalStateT action initState)
> The first argument (the lambda) has type
>> forall a m. Monad m => StateT S m a -> m a
> which can be specialised to what simpleHTTP' is expecting.
> I hope this helps!
More information about the Haskell-Cafe