The passthrough involves instances of common monad classes.  If
MyMonad has a MonadState instance, then you don't need to use lift to
get to the MonadState functions.  TemplateMonad defines an instance
that does the lift for you.  This is new in Heist 0.2.  It works for
most of the most common monad type classes that you might use.
MonadState, MonadReader, MonadPlus, etc.  You can see the list here:

http://github.com/snapframework/heist/blob/master/src/Text/Templating/Heist/Types.hs

On Tue, Jun 15, 2010 at 2:12 AM, Kevin Jardine <[email protected]> wrote:
> Yes, thanks. I do need lift to access MyMonad though. I understand that there 
> is something called a passthrough that might remove this requirement. Do you 
> know how that works?
>
> Kevin
>
> --- On Tue, 6/15/10, MightyByte <[email protected]> wrote:
>
>> From: MightyByte <[email protected]>
>> Subject: Re: [Snap Framework] Splice functions and a custom monad
>> To: "Kevin Jardine" <[email protected]>
>> Cc: [email protected]
>> Date: Tuesday, June 15, 2010, 3:21 AM
>> Kevin,
>>
>> You mentioned two different error messages above.  I
>> just wanted to
>> verify that both of them are taken care of now?
>>
>> On Mon, Jun 14, 2010 at 6:19 PM, Kevin Jardine <[email protected]>
>> wrote:
>> > As MonadIO was no longer being automatically derived
>> without mtl, I added these lines:
>> >
>> > instance MonadIO MyMonad where
>> >    liftIO m = MyM (liftIO m)
>> >
>> > and this seems to have fixed the problem. I no longer
>> need mtl and I can use Heist as needed!
>> >
>> > --- On Mon, 6/14/10, Kevin Jardine <[email protected]>
>> wrote:
>> >
>> >> From: Kevin Jardine <[email protected]>
>> >> Subject: [Snap Framework] Splice functions and a
>> custom monad
>> >> To: [email protected]
>> >> Date: Monday, June 14, 2010, 10:52 PM
>> >> I'd like to run Heist template splice
>> >> functions in my own custom monad (not Snap).
>> >>
>> >> I can define a splice function as:
>> >>
>> >> mySplice :: Splice MyMonad
>> >>
>> >> However, when I try to call functions that return
>> values in
>> >> my monad in mySplice, I get a compile error:
>> >>
>> >> Couldn't match expected type TemplateMonad MyMonad
>> a
>> >> against inferred type MyMonad ()
>> >>
>> >> I've seen an example in the Heist documentation
>> where the
>> >> inner MyMonad is accessed using lift. But when I
>> try that, I
>> >> get another compile error:
>> >>
>> >> No instance for (MonadTrans TemplateMonad)
>> >> arising from the use of 'lift'
>> >>
>> >> Gregory Collins advised replacing mtl with
>> monads-fd and
>> >> transformers.
>> >>
>> >> However, this breaks my custom monad (eg. MonadIO
>> is no
>> >> longer automatically derived).
>> >>
>> >> How do I get this to work?
>> >>
>> >> Kevin
>> >>
>> >>
>> >>
>> >> _______________________________________________
>> >> Snap mailing list
>> >> [email protected]
>> >> http://mailman-mail5.webfaction.com/listinfo/snap
>> >>
>> >
>> >
>> >
>> > _______________________________________________
>> > Snap mailing list
>> > [email protected]
>> > http://mailman-mail5.webfaction.com/listinfo/snap
>> >
>>
>
>
>
>
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap

Reply via email to