Creating and composing snaplets
In this recipe, we will create a snaplet and build the Snap application around it. We will also use the heist snaplet for serving the HTML templates. This recipe will demonstrate the following:
- How to create a snaplet
- How to use an existing snaplet inside another existing snaplet
- How the snaplet data is structured and placed
- How to access snaplet data
How to do it...
- Create a new project,
working-with-snaplets, with thesimplestack template:
stack new working-with-snaplets simple
- Add a dependency on the
snap-corelibrary in thebuild-dependssubsection of theexecutablesection, as follows:
executable working-with-snaplets
hs-source-dirs: src
main-is: Main.hs
default-language: Haskell2010
build-depends: base >= 4.7 && < 5
, snap-core
, snap-server
, snap
, lens
, bytestring
...