[Haskell-cafe] ANNOUNCE: monad-control-0.3

Michael Snoyman michael at snoyman.com
Tue Dec 6 12:59:18 CET 2011


On Tue, Dec 6, 2011 at 11:49 AM, Bas van Dijk <v.dijk.bas at gmail.com> wrote:
> On 6 December 2011 05:06, Michael Snoyman <michael at snoyman.com> wrote:
>> Maybe this will help[1]. It's using RWST instead of StateT, but it's
>> the same idea.
>>
>> [1] https://github.com/yesodweb/yesod/commit/7619e4e9dd88c152d1e00b6fea073c3d52dc797f#L0R105
>
> Hi Michael,
>
> Note that you can just reuse the MonadTransControl instance of the
> RWST transformer:
>
> instance MonadTransControl (GGWidget master) where
>    newtype StT (GGWidget master) a =
>        StWidget {unStWidget :: StT (GWInner master) a}
>    liftWith f = GWidget $ liftWith $ \run ->
>                   f $ liftM StWidget . run . unGWidget
>    restoreT = GWidget . restoreT . liftM unStWidget
>
> Cheers,
>
> Bas

Thanks Bas, I was just in the process of converting Widget from being
a RWS to a Writer, and your code made it much simpler :).

Michael



More information about the Haskell-Cafe mailing list