Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 52 lines (38 sloc) 1.879 kb
9620ade Tom Lokhorst Moved language extensions into files instead of cabal file
authored
1 {-# LANGUAGE TypeSynonymInstances, MultiParamTypeClasses #-}
ce2864c Tom Lokhorst Started with Snap.
authored
2 {-
3
4 This module defines our application's monad and any application-specific
5 information it requires.
6
7 -}
8
9 module Application
10 ( Application
11 , applicationInitializer
12 ) where
13
14 import Snap.Extension
15 import Snap.Extension.Heist.Impl
16
17
18 ------------------------------------------------------------------------------
19 -- | 'Application' is our application's monad. It uses 'SnapExtend' from
20 -- 'Snap.Extension' to provide us with an extended 'MonadSnap' making use of
21 -- the Heist and Timer Snap extensions.
22 type Application = SnapExtend ApplicationState
23
24
25 ------------------------------------------------------------------------------
26 -- | 'ApplicationState' is a record which contains the state needed by the Snap
27 -- extensions we're using. We're using Heist so we can easily render Heist
28 -- templates, and Timer simply to illustrate the config loading differences
29 -- between development and production modes.
30 data ApplicationState = ApplicationState
31 { templateState :: HeistState Application
32 }
33
34
35 ------------------------------------------------------------------------------
36 instance HasHeistState Application ApplicationState where
37 getHeistState = templateState
38 setHeistState s a = a { templateState = s }
39
40
41 ------------------------------------------------------------------------------
42 -- | The 'Initializer' for ApplicationState. For more on 'Initializer's, see
43 -- the documentation from the snap package. Briefly, this is used to
44 -- generate the 'ApplicationState' needed for our application and will
45 -- automatically generate reload\/cleanup actions for us which we don't need
46 -- to worry about.
47 applicationInitializer :: Initializer ApplicationState
48 applicationInitializer = do
68c6145 Tom Lokhorst Updated to snap 0.5
authored
49 heist <- heistInitializer "resources/templates" id
d6337a3 Tom Lokhorst Removed last remnants of Yesod
authored
50 return $ ApplicationState heist
9620ade Tom Lokhorst Moved language extensions into files instead of cabal file
authored
51
Something went wrong with that request. Please try again.