Snap, Snaplets, Templates confusion

74 views
Skip to first unread message

Peter Ward

unread,
Nov 14, 2012, 11:40:22 AM11/14/12
to snap_fr...@googlegroups.com
Hi

Sorry, but I'm struggling.
I have some dynamic pages created with a site :: Snap(), some Snap() handler functions and Blaze for HTML generation.
I would like to use template files, but when I look at the Heist and Snaplet examples, it all seems radically different.
I have managed to get a template server up, but with no dynamic content.
Can my Snap() handlers co-exist, or do I have to approach this differently?
Where is the right place to bindSplice, for instance?

Peter

MightyByte

unread,
Nov 14, 2012, 12:35:15 PM11/14/12
to snap_fr...@googlegroups.com
Hi Peter,

The snap-core and snap-server packages provide a lower level of abstraction than the snap package, which provides snaplets.  The Snap monad is the snap-core level of abstraction.  If you're using snaplets, then the equivalent is the Handler monad.  The good news is that you can probably use the two interchangeably.  All you need to do is change the type signature from site :: Snap() to site :: Handler App App ().  This works because most of the snap-core API is written to work for any monad that is an instance of the MonadSnap type class.  Both the Snap monad and the Handler monad are instances of MonadSnap.

I would suggest starting with the default project template generated by "snap init".  That gives you a working project with snaplets and heist.  Then you can bring your old Snap () functions in and change their type signatures.



Peter

--
 
 
 

Peter Ward

unread,
Nov 14, 2012, 3:45:34 PM11/14/12
to snap_fr...@googlegroups.com
Very helpful. I think I am over that particular bump. Many thanks.

Peter

Phil de Joux

unread,
Jul 14, 2014, 12:02:36 AM7/14/14
to snap_fr...@googlegroups.com, peter.d...@gmail.com
In the hackage docs for Network.JMacroRPC.Snap there's a sample that is served up using

main = quickHttpServe =<< testPage

This video is of a talk about JMacroRPC and it talks about panels.

The docs for Network.JMacroRPC.Panels has a sample that is a Panel.

How could these samples be served using the site generated by "snap init default" that uses snaplets?

I had a go myself and haven't yet resolved this type error when trying to use  ...

Couldn't match expected type `Handler App App ()'
            with actual type `Snap ()'

Gregory Collins

unread,
Jul 15, 2014, 5:08:47 AM7/15/14
to snap_fr...@googlegroups.com, peter.d...@gmail.com

On Mon, Jul 14, 2014 at 6:02 AM, Phil de Joux <philde...@gmail.com> wrote:
haven't yet resolved this type error

Phil de Joux

unread,
Jul 19, 2014, 11:36:19 PM7/19/14
to snap_fr...@googlegroups.com, peter.d...@gmail.com
Thanks that works.
Reply all
Reply to author
Forward
0 new messages