On Tue, Dec 6, 2011 at 11:49 AM, Bas van Dijk <[email protected]> wrote:
> On 6 December 2011 05:06, Michael Snoyman <[email protected]> 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

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to