{"diffoscope-json-version": 1, "source1": "/srv/reproducible-results/rbuild-debian/r-b-build.CyRFl79Z/b1/haskell-snap-templates_1.0.0.2-5_armhf.changes", "source2": "/srv/reproducible-results/rbuild-debian/r-b-build.CyRFl79Z/b2/haskell-snap-templates_1.0.0.2-5_armhf.changes", "unified_diff": null, "details": [{"source1": "Files", "source2": "Files", "unified_diff": "@@ -1,2 +1,2 @@\n \n- 36deb15d0c39f98f21dac16bf3ec4612 3211896 haskell optional snap-templates_1.0.0.2-5_armhf.deb\n+ 0ed49e24179455711b298ef595f32e7b 3212664 haskell optional snap-templates_1.0.0.2-5_armhf.deb\n"}, {"source1": "snap-templates_1.0.0.2-5_armhf.deb", "source2": "snap-templates_1.0.0.2-5_armhf.deb", "unified_diff": null, "details": [{"source1": "file list", "source2": "file list", "unified_diff": "@@ -1,3 +1,3 @@\n -rw-r--r-- 0 0 0 4 2024-01-05 01:14:13.000000 debian-binary\n -rw-r--r-- 0 0 0 900 2024-01-05 01:14:13.000000 control.tar.xz\n--rw-r--r-- 0 0 0 3210804 2024-01-05 01:14:13.000000 data.tar.xz\n+-rw-r--r-- 0 0 0 3211572 2024-01-05 01:14:13.000000 data.tar.xz\n"}, {"source1": "control.tar.xz", "source2": "control.tar.xz", "unified_diff": null, "details": [{"source1": "control.tar", "source2": "control.tar", "unified_diff": null, "details": [{"source1": "./md5sums", "source2": "./md5sums", "unified_diff": null, "details": [{"source1": "./md5sums", "source2": "./md5sums", "comments": ["Files differ"], "unified_diff": null}]}]}]}, {"source1": "data.tar.xz", "source2": "data.tar.xz", "unified_diff": null, "details": [{"source1": "data.tar", "source2": "data.tar", "unified_diff": null, "details": [{"source1": "./usr/bin/snap-framework", "source2": "./usr/bin/snap-framework", "comments": ["File has been modified after NT_GNU_BUILD_ID has been applied."], "unified_diff": null, "details": [{"source1": "readelf --wide --notes {}", "source2": "readelf --wide --notes {}", "unified_diff": "@@ -1,12 +1,12 @@\n \n Displaying notes found in: .note.ABI-tag\n Owner Data size \tDescription\n GNU 0x00000010\tNT_GNU_ABI_TAG (ABI version tag)\t OS: Linux, ABI: 3.2.0\n \n Displaying notes found in: .note.gnu.build-id\n Owner Data size \tDescription\n- GNU 0x00000014\tNT_GNU_BUILD_ID (unique build ID bitstring)\t Build ID: 26b9dfe769d7a3a3d6a5f11dbe14c4ac6ec9a388\n+ GNU 0x00000014\tNT_GNU_BUILD_ID (unique build ID bitstring)\t Build ID: f0f266036a636bddf521bda94700e2e2b7e2cef2\n \n Displaying notes found in: .note.gnu.gold-version\n Owner Data size \tDescription\n GNU 0x00000009\tNT_GNU_GOLD_VERSION (gold version)\t Version: gold 1.16\n"}, {"source1": "strings --all --bytes=8 {}", "source2": "strings --all --bytes=8 {}", "comments": ["Ordering differences only"], "unified_diff": "@@ -251,26 +251,14 @@\n snap init [type]\n on that action\n Note: you can use --help after any of the above actions to get help \n init - create a new project directory structure in the current directory\n can be one of:\n snap \n Snap 1.0.0.0 Project Kickstarter\n-> {-# LANGUAGE OverloadedStrings #-}\n-> module Part2 where\n-> import Snap.Snaplet\n-> data Foo = Foo\n-> data Bar = Bar\n-> fooInit :: SnapletInit b Foo\n-> fooInit = makeSnaplet \"foo\" \"Foo snaplet\" Nothing $ do\n-> return Foo\n-> barInit :: SnapletLens b Foo -> SnapletInit b Bar\n-> barInit _h = makeSnaplet \"bar\" \"Bar snaplet\" Nothing $ do\n-> return Bar\n-./src/Part2.lhs\n What Are Snaplets?\n ==================\n A snaplet is a composable web application. Snaplets allow you to build\n self-contained pieces of functionality and glue them together to make larger\n applications. Here are some of the things provided by the snaplet API:\n - Infrastructure for application state/environment\n - Snaplet initialization, reload, and cleanup\n@@ -561,14 +549,26 @@\n run and it sees that the snaplet's directory does not already exist. If the\n user upgrades to a new version of the snaplet and the new version made changes\n to the filesystem resources, those resources will NOT be automatically copied\n in by default. Resource installation *only* happens when the `snaplets/foo`\n directory does not exist. If you want to get the latest version of the\n filesystem resources, remove the `snaplets/foo` directory, and restart your\n ./src/Tutorial.lhs\n+> {-# LANGUAGE OverloadedStrings #-}\n+> module Part2 where\n+> import Snap.Snaplet\n+> data Foo = Foo\n+> data Bar = Bar\n+> fooInit :: SnapletInit b Foo\n+> fooInit = makeSnaplet \"foo\" \"Foo snaplet\" Nothing $ do\n+> return Foo\n+> barInit :: SnapletLens b Foo -> SnapletInit b Bar\n+> barInit _h = makeSnaplet \"bar\" \"Bar snaplet\" Nothing $ do\n+> return Bar\n+./src/Part2.lhs\n Name: projname\n Version: 0.1\n Synopsis: Project Synopsis Here\n Description: Project Description Here\n License: AllRightsReserved\n Author: Author\n Maintainer: maintainer@example.com\n@@ -591,36 +591,83 @@\n snap >= 1.0 && < 1.2,\n snap-core >= 1.0 && < 1.1,\n snap-server >= 1.0 && < 1.2\n if impl(ghc >= 6.12.0)\n ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2\n -fno-warn-unused-do-bind\n ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2\n-{-# LANGUAGE TemplateHaskell #-}\n+{-# LANGUAGE OverloadedStrings #-}\n ------------------------------------------------------------------------------\n--- | This module defines our application's state type and an alias for its\n--- handler monad.\n-module Application where\n+-- | This module is where all the routes and handlers are defined for your\n+-- site. The 'app' function is the initializer that combines everything\n+-- together and is exported by this module.\n+module Site\n+ ) where\n ------------------------------------------------------------------------------\n-import Control.Lens\n-import Snap.Snaplet\n-import Snap.Snaplet.Heist\n-import Snap.Snaplet.Auth\n-import Snap.Snaplet.Session\n+import Control.Applicative\n+import Data.ByteString (ByteString)\n+import Data.Map.Syntax ((##))\n+import qualified Data.Text as T\n+import Snap.Core\n+import Snap.Snaplet\n+import Snap.Snaplet.Auth\n+import Snap.Snaplet.Auth.Backends.JsonFile\n+import Snap.Snaplet.Heist\n+import Snap.Snaplet.Session.Backends.CookieSession\n+import Snap.Util.FileServe\n+import qualified Heist.Interpreted as I\n ------------------------------------------------------------------------------\n-data App = App\n- { _heist :: Snaplet (Heist App)\n- , _sess :: Snaplet SessionManager\n- , _auth :: Snaplet (AuthManager App)\n-makeLenses ''App\n-instance HasHeist App where\n- heistLens = subSnaplet heist\n+import Application\n ------------------------------------------------------------------------------\n-type AppHandler = Handler App App\n-./src/Application.hs\n+-- | Render login form\n+handleLogin :: Maybe T.Text -> Handler App (AuthManager App) ()\n+handleLogin authError = heistLocal (I.bindSplices errs) $ render \"login\"\n+ errs = maybe mempty splice authError\n+ splice err = \"loginError\" ## I.textSplice err\n+------------------------------------------------------------------------------\n+-- | Handle login submit\n+handleLoginSubmit :: Handler App (AuthManager App) ()\n+handleLoginSubmit =\n+ loginUser \"login\" \"password\" Nothing\n+ (\\_ -> handleLogin err) (redirect \"/\")\n+ err = Just \"Unknown user or password\"\n+------------------------------------------------------------------------------\n+-- | Logs out and redirects the user to the site index.\n+handleLogout :: Handler App (AuthManager App) ()\n+handleLogout = logout >> redirect \"/\"\n+------------------------------------------------------------------------------\n+-- | Handle new user form submit\n+handleNewUser :: Handler App (AuthManager App) ()\n+handleNewUser = method GET handleForm <|> method POST handleFormSubmit\n+ handleForm = render \"new_user\"\n+ handleFormSubmit = registerUser \"login\" \"password\" >> redirect \"/\"\n+------------------------------------------------------------------------------\n+-- | The application's routes.\n+routes :: [(ByteString, Handler App App ())]\n+routes = [ (\"login\", with auth handleLoginSubmit)\n+ , (\"logout\", with auth handleLogout)\n+ , (\"new_user\", with auth handleNewUser)\n+ , (\"\", serveDirectory \"static\")\n+ ]\n+------------------------------------------------------------------------------\n+-- | The application initializer.\n+app :: SnapletInit App App\n+app = makeSnaplet \"app\" \"An snaplet example application.\" Nothing $ do\n+ h <- nestSnaplet \"\" heist $ heistInit \"templates\"\n+ s <- nestSnaplet \"sess\" sess $\n+ initCookieSessionManager \"site_key.txt\" \"sess\" Nothing (Just 3600)\n+ -- NOTE: We're using initJsonFileAuthManager here because it's easy and\n+ -- doesn't require any kind of database server to run. In practice,\n+ -- you'll probably want to change this to a more robust auth backend.\n+ a <- nestSnaplet \"auth\" auth $\n+ initJsonFileAuthManager defAuthSettings sess \"users.json\"\n+ addRoutes routes\n+ addAuthSplices h auth\n+ return $ App h s a\n+./src/Site.hs\n {-# LANGUAGE CPP #-}\n {-# LANGUAGE TemplateHaskell #-}\n NOTE: Don't modify this file unless you know what you are doing. If you are\n new to snap, start with Site.hs and Application.hs. This file contains\n boilerplate needed for dynamic reloading and is not meant for general\n consumption.\n Occasionally if we modify the way the dynamic reloader works and you want to\n@@ -700,141 +747,36 @@\n -- sophisticated code might.\n getActions :: Config Snap AppConfig -> IO (Snap (), IO ())\n getActions conf = do\n (msgs, site, cleanup) <- runSnaplet\n (appEnvironment =<< getOther conf) app\n hPutStrLn stderr $ T.unpack msgs\n return (site, cleanup)\n-{-# LANGUAGE OverloadedStrings #-}\n-------------------------------------------------------------------------------\n--- | This module is where all the routes and handlers are defined for your\n--- site. The 'app' function is the initializer that combines everything\n--- together and is exported by this module.\n-module Site\n- ) where\n-------------------------------------------------------------------------------\n-import Control.Applicative\n-import Data.ByteString (ByteString)\n-import Data.Map.Syntax ((##))\n-import qualified Data.Text as T\n-import Snap.Core\n-import Snap.Snaplet\n-import Snap.Snaplet.Auth\n-import Snap.Snaplet.Auth.Backends.JsonFile\n-import Snap.Snaplet.Heist\n-import Snap.Snaplet.Session.Backends.CookieSession\n-import Snap.Util.FileServe\n-import qualified Heist.Interpreted as I\n-------------------------------------------------------------------------------\n-import Application\n-------------------------------------------------------------------------------\n--- | Render login form\n-handleLogin :: Maybe T.Text -> Handler App (AuthManager App) ()\n-handleLogin authError = heistLocal (I.bindSplices errs) $ render \"login\"\n- errs = maybe mempty splice authError\n- splice err = \"loginError\" ## I.textSplice err\n-------------------------------------------------------------------------------\n--- | Handle login submit\n-handleLoginSubmit :: Handler App (AuthManager App) ()\n-handleLoginSubmit =\n- loginUser \"login\" \"password\" Nothing\n- (\\_ -> handleLogin err) (redirect \"/\")\n- err = Just \"Unknown user or password\"\n+{-# LANGUAGE TemplateHaskell #-}\n ------------------------------------------------------------------------------\n--- | Logs out and redirects the user to the site index.\n-handleLogout :: Handler App (AuthManager App) ()\n-handleLogout = logout >> redirect \"/\"\n+-- | This module defines our application's state type and an alias for its\n+-- handler monad.\n+module Application where\n ------------------------------------------------------------------------------\n--- | Handle new user form submit\n-handleNewUser :: Handler App (AuthManager App) ()\n-handleNewUser = method GET handleForm <|> method POST handleFormSubmit\n- handleForm = render \"new_user\"\n- handleFormSubmit = registerUser \"login\" \"password\" >> redirect \"/\"\n+import Control.Lens\n+import Snap.Snaplet\n+import Snap.Snaplet.Heist\n+import Snap.Snaplet.Auth\n+import Snap.Snaplet.Session\n ------------------------------------------------------------------------------\n--- | The application's routes.\n-routes :: [(ByteString, Handler App App ())]\n-routes = [ (\"login\", with auth handleLoginSubmit)\n- , (\"logout\", with auth handleLogout)\n- , (\"new_user\", with auth handleNewUser)\n- , (\"\", serveDirectory \"static\")\n- ]\n+data App = App\n+ { _heist :: Snaplet (Heist App)\n+ , _sess :: Snaplet SessionManager\n+ , _auth :: Snaplet (AuthManager App)\n+makeLenses ''App\n+instance HasHeist App where\n+ heistLens = subSnaplet heist\n ------------------------------------------------------------------------------\n--- | The application initializer.\n-app :: SnapletInit App App\n-app = makeSnaplet \"app\" \"An snaplet example application.\" Nothing $ do\n- h <- nestSnaplet \"\" heist $ heistInit \"templates\"\n- s <- nestSnaplet \"sess\" sess $\n- initCookieSessionManager \"site_key.txt\" \"sess\" Nothing (Just 3600)\n- -- NOTE: We're using initJsonFileAuthManager here because it's easy and\n- -- doesn't require any kind of database server to run. In practice,\n- -- you'll probably want to change this to a more robust auth backend.\n- a <- nestSnaplet \"auth\" auth $\n- initJsonFileAuthManager defAuthSettings sess \"users.json\"\n- addRoutes routes\n- addAuthSplices h auth\n- return $ App h s a\n-./src/Site.hs\n- \n- Snap web server\n- \n- \n- \n-
\n- \n-
\n- \n-./snaplets/heist/templates/base.tpl\n-

Snap Example App Login

\n-

\n-/login\n-Login\n-\n-

Don't have a login yet? Create a new user

\n-./snaplets/heist/templates/_login.tpl\n-

Register a new user

\n-/new_user\n-Add User\n-\n-./snaplets/heist/templates/_new_user.tpl\n-\n- \n-\n-./snaplets/heist/templates/login.tpl\n-\n- \n- This is a simple demo page served using\n- Heist\n- and the Snap web framework.\n-

\n-

Congrats! You're logged in as ''

\n-

Logout

\n-
\n- \n- \n- \n-
\n-./snaplets/heist/templates/index.tpl\n-
\n- \n- \n- \n- \n- \n- \n- \n- \n- \n- \n- \n-
Login:
Password:
\n-./snaplets/heist/templates/userform.tpl\n-\n- \n-\n-./snaplets/heist/templates/new_user.tpl\n+type AppHandler = Handler App App\n+./src/Application.hs\n Name: projname\n Version: 0.1\n Synopsis: Project Synopsis Here\n Description: Project Description Here\n License: AllRightsReserved\n Author: Author\n Maintainer: maintainer@example.com\n@@ -878,14 +820,72 @@\n ghc-options: -threaded -w\n if impl(ghc >= 6.12.0)\n ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2\n -fno-warn-orphans -fno-warn-unused-do-bind\n else\n ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2\n -fno-warn-orphans\n+

Register a new user

\n+/new_user\n+Add User\n+\n+./snaplets/heist/templates/_new_user.tpl\n+\n+ \n+ \n+ \n+ \n+ \n+ \n+ \n+ \n+ \n+ \n+ \n+
Login:
Password:
\n+./snaplets/heist/templates/userform.tpl\n+\n+ \n+\n+./snaplets/heist/templates/new_user.tpl\n+\n+ \n+\n+./snaplets/heist/templates/login.tpl\n+

Snap Example App Login

\n+

\n+/login\n+Login\n+\n+

Don't have a login yet? Create a new user

\n+./snaplets/heist/templates/_login.tpl\n+ \n+ Snap web server\n+ \n+ \n+ \n+
\n+ \n+
\n+ \n+./snaplets/heist/templates/base.tpl\n+\n+ \n+ This is a simple demo page served using\n+ Heist\n+ and the Snap web framework.\n+

\n+

Congrats! You're logged in as ''

\n+

Logout

\n+
\n+ \n+ \n+ \n+
\n+./snaplets/heist/templates/index.tpl\n padding: 0;\n margin: 0;\n background-color: #ffffff;\n font-family: Verdana, Helvetica, sans-serif;\n padding: 0;\n margin: 0;\n text-decoration: underline;\n@@ -917,16 +917,14 @@\n dir \"static\" (serveDirectory \".\")\n echoHandler :: Snap ()\n echoHandler = do\n param <- getParam \"echoparam\"\n maybe (writeBS \"must specify echo/param in URL\")\n writeBS param\n ./src/Main.hs\n-placeholder\n-./log/placeholder\n Name: projname\n Version: 0.1\n Synopsis: Project Synopsis Here\n Description: Project Description Here\n License: AllRightsReserved\n Author: Author\n Maintainer: maintainer@example.com\n@@ -944,14 +942,16 @@\n snap-core >= 1.0 && < 1.1,\n snap-server >= 1.0 && < 1.2\n if impl(ghc >= 6.12.0)\n ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2\n -fno-warn-unused-do-bind\n ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2\n ./foo.cabal\n+placeholder\n+./log/placeholder\n :set -isrc\n :set -hide-package MonadCatchIO-mtl\n :set -hide-package monads-fd\n :set -XOverloadedStrings\n main:Main.Help\n Data.Text.concat: size overflow\n overflowError\n"}, {"source1": "readelf --wide --decompress --hex-dump=.rodata {}", "source2": "readelf --wide --decompress --hex-dump=.rodata {}", "unified_diff": "@@ -46,1115 +46,1115 @@\n 0x011466f0 79207374 72756374 75726520 696e2074 y structure in t\n 0x01146700 68652063 75727265 6e742064 69726563 he current direc\n 0x01146710 746f7279 00202020 203c6163 74696f6e tory. can be one of:\n 0x01146730 00202073 6e617020 3c616374 696f6e3e . snap \n 0x01146740 00557361 67653a00 536e6170 20312e30 .Usage:.Snap 1.0\n 0x01146750 2e302e30 2050726f 6a656374 204b6963 .0.0 Project Kic\n- 0x01146760 6b737461 72746572 003e207b 2d23204c kstarter.> {-# L\n- 0x01146770 414e4755 41474520 4f766572 6c6f6164 ANGUAGE Overload\n- 0x01146780 65645374 72696e67 7320232d 7d0a3e20 edStrings #-}.> \n- 0x01146790 6d6f6475 6c652050 61727432 20776865 module Part2 whe\n- 0x011467a0 72650a0a 3e20696d 706f7274 20202020 re..> import \n- 0x011467b0 20202020 20202053 6e61702e 536e6170 Snap.Snap\n- 0x011467c0 6c65740a 0a3e2064 61746120 466f6f20 let..> data Foo \n- 0x011467d0 3d20466f 6f0a3e0a 3e206461 74612042 = Foo.>.> data B\n- 0x011467e0 6172203d 20426172 0a3e0a3e 20666f6f ar = Bar.>.> foo\n- 0x011467f0 496e6974 203a3a20 536e6170 6c657449 Init :: SnapletI\n- 0x01146800 6e697420 6220466f 6f0a3e20 666f6f49 nit b Foo.> fooI\n- 0x01146810 6e697420 3d206d61 6b65536e 61706c65 nit = makeSnaple\n- 0x01146820 74202266 6f6f2220 22466f6f 20736e61 t \"foo\" \"Foo sna\n- 0x01146830 706c6574 22204e6f 7468696e 67202420 plet\" Nothing $ \n- 0x01146840 646f0a3e 20202020 20726574 75726e20 do.> return \n- 0x01146850 466f6f0a 3e0a3e20 62617249 6e697420 Foo.>.> barInit \n- 0x01146860 3a3a2053 6e61706c 65744c65 6e732062 :: SnapletLens b\n- 0x01146870 20466f6f 202d3e20 536e6170 6c657449 Foo -> SnapletI\n- 0x01146880 6e697420 62204261 720a3e20 62617249 nit b Bar.> barI\n- 0x01146890 6e697420 5f68203d 206d616b 65536e61 nit _h = makeSna\n- 0x011468a0 706c6574 20226261 72222022 42617220 plet \"bar\" \"Bar \n- 0x011468b0 736e6170 6c657422 204e6f74 68696e67 snaplet\" Nothing\n- 0x011468c0 20242064 6f0a3e20 20202020 72657475 $ do.> retu\n- 0x011468d0 726e2042 61720a00 2e2f7372 632f5061 rn Bar.../src/Pa\n- 0x011468e0 7274322e 6c687300 57686174 20417265 rt2.lhs.What Are\n- 0x011468f0 20536e61 706c6574 733f0a3d 3d3d3d3d Snaplets?.=====\n- 0x01146900 3d3d3d3d 3d3d3d3d 3d3d3d3d 3d0a0a41 =============..A\n- 0x01146910 20736e61 706c6574 20697320 6120636f snaplet is a co\n- 0x01146920 6d706f73 61626c65 20776562 20617070 mposable web app\n- 0x01146930 6c696361 74696f6e 2e202053 6e61706c lication. Snapl\n- 0x01146940 65747320 616c6c6f 7720796f 7520746f ets allow you to\n- 0x01146950 20627569 6c640a73 656c662d 636f6e74 build.self-cont\n- 0x01146960 61696e65 64207069 65636573 206f6620 ained pieces of \n- 0x01146970 66756e63 74696f6e 616c6974 7920616e functionality an\n- 0x01146980 6420676c 75652074 68656d20 746f6765 d glue them toge\n- 0x01146990 74686572 20746f20 6d616b65 206c6172 ther to make lar\n- 0x011469a0 6765720a 6170706c 69636174 696f6e73 ger.applications\n- 0x011469b0 2e202048 65726520 61726520 736f6d65 . Here are some\n- 0x011469c0 206f6620 74686520 7468696e 67732070 of the things p\n- 0x011469d0 726f7669 64656420 62792074 68652073 rovided by the s\n- 0x011469e0 6e61706c 65742041 50493a0a 0a20202d naplet API:.. -\n- 0x011469f0 20496e66 72617374 72756374 75726520 Infrastructure \n- 0x01146a00 666f7220 6170706c 69636174 696f6e20 for application \n- 0x01146a10 73746174 652f656e 7669726f 6e6d656e state/environmen\n- 0x01146a20 740a0a20 202d2053 6e61706c 65742069 t.. - Snaplet i\n- 0x01146a30 6e697469 616c697a 6174696f 6e2c2072 nitialization, r\n- 0x01146a40 656c6f61 642c2061 6e642063 6c65616e eload, and clean\n- 0x01146a50 75700a0a 20202d20 4d616e61 67656d65 up.. - Manageme\n- 0x01146a60 6e74206f 66206669 6c657379 7374656d nt of filesystem\n- 0x01146a70 20646174 6120616e 64206175 746f6d61 data and automa\n- 0x01146a80 74696320 736e6170 6c657420 696e7374 tic snaplet inst\n- 0x01146a90 616c6c61 74696f6e 0a0a2020 2d20556e allation.. - Un\n- 0x01146aa0 69666965 6420636f 6e666967 2066696c ified config fil\n- 0x01146ab0 6520696e 66726173 74727563 74757265 e infrastructure\n- 0x01146ac0 0a0a4f6e 65206578 616d706c 65206d69 ..One example mi\n- 0x01146ad0 67687420 62652061 2077696b 6920736e ght be a wiki sn\n- 0x01146ae0 61706c65 742e2020 49742077 6f756c64 aplet. It would\n- 0x01146af0 20626520 64697374 72696275 74656420 be distributed \n- 0x01146b00 61732061 20686173 6b656c6c 0a706163 as a haskell.pac\n- 0x01146b10 6b616765 20746861 7420776f 756c6420 kage that would \n- 0x01146b20 62652069 6e737461 6c6c6564 20776974 be installed wit\n- 0x01146b30 68206361 62616c20 616e6420 776f756c h cabal and woul\n- 0x01146b40 64207072 6f626162 6c792069 6e636c75 d probably inclu\n- 0x01146b50 64652063 6f64652c 0a636f6e 66696720 de code,.config \n- 0x01146b60 66696c65 732c2048 544d4c20 74656d70 files, HTML temp\n- 0x01146b70 6c617465 732c2073 74796c65 73686565 lates, styleshee\n- 0x01146b80 74732c20 4a617661 53637269 70742c20 ts, JavaScript, \n- 0x01146b90 696d6167 65732c20 6574632e 20205468 images, etc. Th\n- 0x01146ba0 650a736e 61706c65 74277320 636f6465 e.snaplet's code\n- 0x01146bb0 20776f75 6c642070 726f7669 64652074 would provide t\n- 0x01146bc0 6865206e 65636573 73617279 20415049 he necessary API\n- 0x01146bd0 20746f20 6c657420 796f7572 20617070 to let your app\n- 0x01146be0 6c696361 74696f6e 0a696e74 65726163 lication.interac\n- 0x01146bf0 74207365 616d6c65 73736c79 20776974 t seamlessly wit\n- 0x01146c00 68207468 65207769 6b692066 756e6374 h the wiki funct\n- 0x01146c10 696f6e61 6c697479 2e202057 68656e20 ionality. When \n- 0x01146c20 796f7520 72756e20 796f7572 0a617070 you run your.app\n- 0x01146c30 6c696361 74696f6e 20666f72 20746865 lication for the\n- 0x01146c40 20666972 73742074 696d652c 20616c6c first time, all\n- 0x01146c50 206f6620 74686520 77696b69 20736e61 of the wiki sna\n- 0x01146c60 706c6574 27732066 696c6573 79737465 plet's filesyste\n- 0x01146c70 6d207265 736f7572 6365730a 77696c6c m resources.will\n- 0x01146c80 20617574 6f6d6174 6963616c 6c792062 automatically b\n- 0x01146c90 6520636f 70696564 20696e74 6f207468 e copied into th\n- 0x01146ca0 65206170 70726f70 72696174 6520706c e appropriate pl\n- 0x01146cb0 61636573 2e202054 68656e20 796f7520 aces. Then you \n- 0x01146cc0 77696c6c 0a696d6d 65646961 74656c79 will.immediately\n- 0x01146cd0 20626520 61626c65 20746f20 63757374 be able to cust\n- 0x01146ce0 6f6d697a 65207468 65207769 6b692074 omize the wiki t\n- 0x01146cf0 6f206669 7420796f 7572206e 65656473 o fit your needs\n- 0x01146d00 20627920 65646974 696e6720 636f6e66 by editing conf\n- 0x01146d10 69670a66 696c6573 2c207072 6f766964 ig.files, provid\n- 0x01146d20 696e6720 796f7572 206f776e 20737479 ing your own sty\n- 0x01146d30 6c657368 65657473 2c206574 632e2020 lesheets, etc. \n- 0x01146d40 57652077 696c6c20 64697363 75737320 We will discuss \n- 0x01146d50 74686973 20696e20 6d6f7265 0a646574 this in more.det\n- 0x01146d60 61696c20 6c617465 722e0a0a 4120736e ail later...A sn\n- 0x01146d70 61706c65 74206361 6e207265 70726573 aplet can repres\n- 0x01146d80 656e7420 616e7974 68696e67 2066726f ent anything fro\n- 0x01146d90 6d206261 636b656e 64204861 736b656c m backend Haskel\n- 0x01146da0 6c20696e 66726173 74727563 74757265 l infrastructure\n- 0x01146db0 20776974 68206e6f 0a757365 72206661 with no.user fa\n- 0x01146dc0 63696e67 2066756e 6374696f 6e616c69 cing functionali\n- 0x01146dd0 74792074 6f206120 736d616c 6c207769 ty to a small wi\n- 0x01146de0 64676574 206c696b 65206120 63686174 dget like a chat\n- 0x01146df0 20626f78 20746861 7420676f 65732069 box that goes i\n- 0x01146e00 6e207468 650a636f 726e6572 206f6620 n the.corner of \n- 0x01146e10 61207765 62207061 67652074 6f20616e a web page to an\n- 0x01146e20 20656e74 69726520 7374616e 64616c6f entire standalo\n- 0x01146e30 6e652077 65627369 7465206c 696b6520 ne website like \n- 0x01146e40 6120626c 6f67206f 7220666f 72756d2e a blog or forum.\n- 0x01146e50 0a546865 20706f73 73696269 6c697469 .The possibiliti\n- 0x01146e60 65732061 72652065 6e646c65 73732e20 es are endless. \n- 0x01146e70 20412073 6e61706c 65742069 73206120 A snaplet is a \n- 0x01146e80 77656220 6170706c 69636174 696f6e2c web application,\n- 0x01146e90 20616e64 20776562 0a617070 6c696361 and web.applica\n- 0x01146ea0 74696f6e 73206172 6520736e 61706c65 tions are snaple\n- 0x01146eb0 74732e20 20546869 73206d65 616e7320 ts. This means \n- 0x01146ec0 74686174 20757369 6e672073 6e61706c that using snapl\n- 0x01146ed0 65747320 616e6420 77726974 696e670a ets and writing.\n- 0x01146ee0 736e6170 6c657473 20617265 20616c6d snaplets are alm\n- 0x01146ef0 6f737420 74686520 73616d65 20746869 ost the same thi\n- 0x01146f00 6e672c20 616e6420 69742773 20747269 ng, and it's tri\n- 0x01146f10 7669616c 20746f20 64726f70 20612077 vial to drop a w\n- 0x01146f20 686f6c65 20776562 73697465 0a696e74 hole website.int\n- 0x01146f30 6f20616e 6f746865 72206f6e 652e0a0a o another one...\n- 0x01146f40 57652772 65207265 616c6c79 20657863 We're really exc\n- 0x01146f50 69746564 2061626f 75742074 68652070 ited about the p\n- 0x01146f60 6f737369 62696c69 74696573 20617661 ossibilities ava\n- 0x01146f70 696c6162 6c652077 69746820 736e6170 ilable with snap\n- 0x01146f80 6c657473 2e202049 6e0a6661 63742c20 lets. In.fact, \n- 0x01146f90 536e6170 20616c72 65616479 20736869 Snap already shi\n- 0x01146fa0 70732077 69746820 736e6170 6c657473 ps with snaplets\n- 0x01146fb0 20666f72 20736573 73696f6e 732c2061 for sessions, a\n- 0x01146fc0 75746865 6e746963 6174696f 6e2c2061 uthentication, a\n- 0x01146fd0 6e640a74 656d706c 6174696e 67202877 nd.templating (w\n- 0x01146fe0 69746820 48656973 74292c20 20546869 ith Heist), Thi\n- 0x01146ff0 73206769 76657320 796f7520 75736566 s gives you usef\n- 0x01147000 756c2066 756e6374 696f6e61 6c697479 ul functionality\n- 0x01147010 206f7574 206f6620 74686520 626f782c out of the box,\n- 0x01147020 0a616e64 206a756d 70207374 61727473 .and jump starts\n- 0x01147030 20796f75 72206f77 6e20736e 61706c65 your own snaple\n- 0x01147040 74206465 76656c6f 706d656e 74206279 t development by\n- 0x01147050 2064656d 6f6e7374 72617469 6e672073 demonstrating s\n- 0x01147060 6f6d6520 75736566 756c0a64 65736967 ome useful.desig\n- 0x01147070 6e207061 74746572 6e732e20 20536f20 n patterns. So \n- 0x01147080 77697468 6f757420 66757274 68657220 without further \n- 0x01147090 61646f2c 206c6574 27732067 65742073 ado, let's get s\n- 0x011470a0 74617274 65642e0a 0a536e61 706c6574 tarted...Snaplet\n- 0x011470b0 204f7665 72766965 770a3d3d 3d3d3d3d Overview.======\n- 0x011470c0 3d3d3d3d 3d3d3d3d 3d3d0a0a 54686520 ==========..The \n- 0x011470d0 68656172 74206f66 20746865 20736e61 heart of the sna\n- 0x011470e0 706c6574 7320696e 66726173 74727563 plets infrastruc\n- 0x011470f0 74757265 20697320 73746174 65206d61 ture is state ma\n- 0x01147100 6e616765 6d656e74 2e20204d 6f737420 nagement. Most \n- 0x01147110 6e6f6e74 72697669 616c0a70 69656365 nontrivial.piece\n- 0x01147120 73206f66 20612077 65622061 7070206e s of a web app n\n- 0x01147130 65656420 736f6d65 206b696e 64206f66 eed some kind of\n- 0x01147140 20737461 7465206f 7220656e 7669726f state or enviro\n- 0x01147150 6e6d656e 74206461 74612e20 20436f6d nment data. Com\n- 0x01147160 706f6e65 6e74730a 74686174 20646f20 ponents.that do \n- 0x01147170 6e6f7420 6e656564 20616e79 206b696e not need any kin\n- 0x01147180 64206f66 20737461 7465206f 7220656e d of state or en\n- 0x01147190 7669726f 6e6d656e 74206172 65207072 vironment are pr\n- 0x011471a0 6f626162 6c79206d 6f72650a 61707072 obably more.appr\n- 0x011471b0 6f707269 61746520 61732061 20737461 opriate as a sta\n- 0x011471c0 6e64616c 6f6e6520 6c696272 61727920 ndalone library \n- 0x011471d0 7468616e 20617320 6120736e 61706c65 than as a snaple\n- 0x011471e0 742e0a0a 4265666f 72652077 6520636f t...Before we co\n- 0x011471f0 6e74696e 75652c20 7765206d 75737420 ntinue, we must \n- 0x01147200 636c6172 69667920 616e2069 6d706f72 clarify an impor\n- 0x01147210 74616e74 20706f69 6e742e20 20546865 tant point. The\n- 0x01147220 20536e61 70207765 62207365 72766572 Snap web server\n- 0x01147230 0a70726f 63657373 65732065 61636820 .processes each \n- 0x01147240 72657175 65737420 696e2069 7473206f request in its o\n- 0x01147250 776e2067 7265656e 20746872 6561642e wn green thread.\n- 0x01147260 20205468 6973206d 65616e73 20746861 This means tha\n- 0x01147270 74206561 63682072 65717565 73740a77 t each request.w\n- 0x01147280 696c6c20 72656365 69766520 61207365 ill receive a se\n- 0x01147290 70617261 74652063 6f707920 6f662074 parate copy of t\n- 0x011472a0 68652073 74617465 20646566 696e6564 he state defined\n- 0x011472b0 20627920 796f7572 20617070 6c696361 by your applica\n- 0x011472c0 74696f6e 20616e64 0a736e61 706c6574 tion and.snaplet\n- 0x011472d0 732c2061 6e64206d 6f646966 69636174 s, and modificat\n- 0x011472e0 696f6e73 20746f20 74686174 20737461 ions to that sta\n- 0x011472f0 7465206f 6e6c7920 61666665 63742074 te only affect t\n- 0x01147300 6865206c 6f63616c 20746872 65616420 he local thread \n- 0x01147310 74686174 0a67656e 65726174 65732061 that.generates a\n- 0x01147320 2073696e 676c6520 72657370 6f6e7365 single response\n- 0x01147330 2e202046 726f6d20 6e6f7720 6f6e2c20 . From now on, \n- 0x01147340 7768656e 20776520 74616c6b 2061626f when we talk abo\n- 0x01147350 75742073 74617465 20746869 73206973 ut state this is\n- 0x01147360 0a776861 74207765 20617265 2074616c .what we are tal\n- 0x01147370 6b696e67 2061626f 75742e20 20496620 king about. If \n- 0x01147380 796f7520 6e656564 20676c6f 62616c20 you need global \n- 0x01147390 6170706c 69636174 696f6e20 73746174 application stat\n- 0x011473a0 652c2079 6f752068 61766520 746f0a75 e, you have to.u\n- 0x011473b0 73652061 20746872 6561642d 73616665 se a thread-safe\n- 0x011473c0 20636f6e 73747275 63742073 75636820 construct such \n- 0x011473d0 61732061 6e204d56 6172206f 7220494f as an MVar or IO\n- 0x011473e0 5265662e 0a0a5468 69732070 6f737420 Ref...This post \n- 0x011473f0 69732077 72697474 656e2069 6e206c69 is written in li\n- 0x01147400 74657261 74652048 61736b65 6c6c2e20 terate Haskell. \n- 0x01147410 20497420 75736573 20612073 6d616c6c It uses a small\n- 0x01147420 20657874 65726e61 6c206d6f 64756c65 external module\n- 0x01147430 0a63616c 6c656420 50617274 32207468 .called Part2 th\n- 0x01147440 61742069 73205b61 7661696c 61626c65 at is [available\n- 0x01147450 0a686572 655d2868 74747073 3a2f2f67 .here](https://g\n- 0x01147460 69746875 622e636f 6d2f736e 61706672 ithub.com/snapfr\n- 0x01147470 616d6577 6f726b2f 736e6170 2d74656d amework/snap-tem\n- 0x01147480 706c6174 65732f62 6c6f622f 6d617374 plates/blob/mast\n- 0x01147490 65722f70 726f6a65 63745f74 656d706c er/project_templ\n- 0x011474a0 6174652f 7475746f 7269616c 2f737263 ate/tutorial/src\n- 0x011474b0 2f506172 74322e6c 6873292e 0a596f75 /Part2.lhs)..You\n- 0x011474c0 2063616e 20616c73 6f20696e 7374616c can also instal\n- 0x011474d0 6c207468 65206675 6c6c2063 6f646520 l the full code \n- 0x011474e0 696e2074 68652063 75727265 6e742064 in the current d\n- 0x011474f0 69726563 746f7279 20776974 68207468 irectory with th\n- 0x01147500 6520636f 6d6d616e 640a6073 6e617020 e command.`snap \n- 0x01147510 696e6974 20747574 6f726961 6c602e20 init tutorial`. \n- 0x01147520 20466972 73742077 65206e65 65642074 First we need t\n- 0x01147530 6f206765 7420696d 706f7274 73206f75 o get imports ou\n- 0x01147540 74206f66 20746865 20776179 2e0a0a3e t of the way...>\n- 0x01147550 207b2d23 204c414e 47554147 45205465 {-# LANGUAGE Te\n- 0x01147560 6d706c61 74654861 736b656c 6c20232d mplateHaskell #-\n- 0x01147570 7d0a3e20 7b2d2320 4c414e47 55414745 }.> {-# LANGUAGE\n- 0x01147580 204f7665 726c6f61 64656453 7472696e OverloadedStrin\n- 0x01147590 67732023 2d7d0a3e 0a3e206d 6f64756c gs #-}.>.> modul\n- 0x011475a0 65204d61 696e2077 68657265 0a3e0a3e e Main where.>.>\n- 0x011475b0 20696d70 6f727420 20202020 20202020 import \n- 0x011475c0 2020436f 6e74726f 6c2e4170 706c6963 Control.Applic\n- 0x011475d0 61746976 65202828 3c7c3e29 290a3e20 ative ((<|>)).> \n- 0x011475e0 696d706f 72742020 20202020 20202020 import \n- 0x011475f0 20436f6e 74726f6c 2e4c656e 732e5448 Control.Lens.TH\n- 0x01147600 0a3e2069 6d706f72 74202020 20202020 .> import \n- 0x01147610 20202020 436f6e74 726f6c2e 4d6f6e61 Control.Mona\n- 0x01147620 642e494f 2e436c61 73732028 6c696674 d.IO.Class (lift\n- 0x01147630 494f290a 3e20696d 706f7274 20202020 IO).> import \n- 0x01147640 20202020 20202043 6f6e7472 6f6c2e4d Control.M\n- 0x01147650 6f6e6164 2e537461 74652e43 6c617373 onad.State.Class\n- 0x01147660 20286765 7473290a 3e20696d 706f7274 (gets).> import\n- 0x01147670 20202020 20202020 20202044 6174612e Data.\n- 0x01147680 494f5265 660a3e20 696d706f 72742071 IORef.> import q\n- 0x01147690 75616c69 66696564 20446174 612e4279 ualified Data.By\n- 0x011476a0 74655374 72696e67 2e436861 72382061 teString.Char8 a\n- 0x011476b0 7320420a 3e20696d 706f7274 20202020 s B.> import \n- 0x011476c0 20202020 20202044 6174612e 4d617962 Data.Mayb\n- 0x011476d0 650a3e20 696d706f 72742020 20202020 e.> import \n- 0x011476e0 20202020 20536e61 700a3e20 696d706f Snap.> impo\n- 0x011476f0 72742020 20202020 20202020 20536e61 rt Sna\n- 0x01147700 702e536e 61706c65 742e4865 6973740a p.Snaplet.Heist.\n- 0x01147710 3e20696d 706f7274 20202020 20202020 > import \n- 0x01147720 20202050 61727432 0a0a5765 20737461 Part2..We sta\n- 0x01147730 7274206f 75722061 70706c69 63617469 rt our applicati\n- 0x01147740 6f6e2062 79206465 66696e69 6e672061 on by defining a\n- 0x01147750 20646174 61207374 72756374 75726520 data structure \n- 0x01147760 746f2068 6f6c6420 74686520 73746174 to hold the stat\n- 0x01147770 652e2020 54686973 0a646174 61207374 e. This.data st\n- 0x01147780 72756374 75726520 696e636c 75646573 ructure includes\n- 0x01147790 20746865 20737461 7465206f 6620616c the state of al\n- 0x011477a0 6c20736e 61706c65 74732028 77726170 l snaplets (wrap\n- 0x011477b0 70656420 696e2061 20536e61 706c6574 ped in a Snaplet\n- 0x011477c0 29207573 65640a62 79206f75 72206170 ) used.by our ap\n- 0x011477d0 706c6963 6174696f 6e206173 2077656c plication as wel\n- 0x011477e0 6c206173 20616e79 206f7468 65722073 l as any other s\n- 0x011477f0 74617465 20776520 6d696768 74207761 tate we might wa\n- 0x01147800 6e742e0a 0a3e2064 61746120 41707020 nt...> data App \n- 0x01147810 3d204170 700a3e20 20202020 7b205f68 = App.> { _h\n- 0x01147820 65697374 20202020 2020203a 3a20536e eist :: Sn\n- 0x01147830 61706c65 74202848 65697374 20417070 aplet (Heist App\n- 0x01147840 290a3e20 20202020 2c205f66 6f6f2020 ).> , _foo \n- 0x01147850 20202020 2020203a 3a20536e 61706c65 :: Snaple\n- 0x01147860 7420466f 6f0a3e20 20202020 2c205f62 t Foo.> , _b\n- 0x01147870 61722020 20202020 2020203a 3a20536e ar :: Sn\n- 0x01147880 61706c65 74204261 720a3e20 20202020 aplet Bar.> \n- 0x01147890 2c205f63 6f6d7061 6e794e61 6d65203a , _companyName :\n- 0x011478a0 3a20494f 52656620 422e4279 74655374 : IORef B.ByteSt\n- 0x011478b0 72696e67 0a3e2020 2020207d 0a3e0a3e ring.> }.>.>\n- 0x011478c0 206d616b 654c656e 73657320 27274170 makeLenses ''Ap\n- 0x011478d0 700a0a54 68652066 69656c64 206e616d p..The field nam\n- 0x011478e0 65732062 6567696e 20776974 6820616e es begin with an\n- 0x011478f0 20756e64 65727363 6f726520 62656361 underscore beca\n- 0x01147900 75736520 6f662073 6f6d6520 6d6f7265 use of some more\n- 0x01147910 20636f6d 706c6963 61746564 0a746869 complicated.thi\n- 0x01147920 6e677320 676f696e 67206f6e 20756e64 ngs going on und\n- 0x01147930 65722074 68652068 6f6f642e 2020486f er the hood. Ho\n- 0x01147940 77657665 722c2061 6c6c2079 6f75206e wever, all you n\n- 0x01147950 65656420 746f206b 6e6f7720 72696768 eed to know righ\n- 0x01147960 74206e6f 77206973 0a746861 7420796f t now is.that yo\n- 0x01147970 75207368 6f756c64 20707265 66697820 u should prefix \n- 0x01147980 7468696e 67732077 69746820 616e2075 things with an u\n- 0x01147990 6e646572 73636f72 6520616e 64207468 nderscore and th\n- 0x011479a0 656e2063 616c6c20 606d616b 654c656e en call `makeLen\n- 0x011479b0 73657360 2e0a5468 6973206c 65747320 ses`..This lets \n- 0x011479c0 796f7520 75736520 74686520 6e616d65 you use the name\n- 0x011479d0 73207769 74686f75 7420616e 20756e64 s without an und\n- 0x011479e0 65727363 6f726520 696e2074 68652072 erscore in the r\n- 0x011479f0 65737420 6f662079 6f75720a 6170706c est of your.appl\n- 0x01147a00 69636174 696f6e2e 0a0a5468 65206e65 ication...The ne\n- 0x01147a10 78742074 68696e67 20776520 6e656564 xt thing we need\n- 0x01147a20 20746f20 646f2069 73206465 66696e65 to do is define\n- 0x01147a30 20616e20 696e6974 69616c69 7a65722e an initializer.\n- 0x01147a40 0a0a3e20 61707049 6e697420 3a3a2053 ..> appInit :: S\n- 0x01147a50 6e61706c 6574496e 69742041 70702041 napletInit App A\n- 0x01147a60 70700a3e 20617070 496e6974 203d206d pp.> appInit = m\n- 0x01147a70 616b6553 6e61706c 65742022 6d796170 akeSnaplet \"myap\n- 0x01147a80 70222022 4d792065 78616d70 6c652061 p\" \"My example a\n- 0x01147a90 70706c69 63617469 6f6e2220 4e6f7468 pplication\" Noth\n- 0x01147aa0 696e6720 2420646f 0a3e2020 20202068 ing $ do.> h\n- 0x01147ab0 73203c2d 206e6573 74536e61 706c6574 s <- nestSnaplet\n- 0x01147ac0 20226865 69737422 20686569 73742024 \"heist\" heist $\n- 0x01147ad0 20686569 7374496e 69742022 74656d70 heistInit \"temp\n- 0x01147ae0 6c617465 73220a3e 20202020 20667320 lates\".> fs \n- 0x01147af0 3c2d206e 65737453 6e61706c 65742022 <- nestSnaplet \"\n- 0x01147b00 666f6f22 20666f6f 20242066 6f6f496e foo\" foo $ fooIn\n- 0x01147b10 69740a3e 20202020 20627320 3c2d206e it.> bs <- n\n- 0x01147b20 65737453 6e61706c 65742022 22206261 estSnaplet \"\" ba\n- 0x01147b30 72202420 6e616d65 536e6170 6c657420 r $ nameSnaplet \n- 0x01147b40 226e6577 6e616d65 22202420 62617249 \"newname\" $ barI\n- 0x01147b50 6e697420 666f6f0a 3e202020 20206164 nit foo.> ad\n- 0x01147b60 64526f75 74657320 5b202822 68656c6c dRoutes [ (\"hell\n- 0x01147b70 6f222c20 77726974 65546578 74202268 o\", writeText \"h\n- 0x01147b80 656c6c6f 20776f72 6c642229 0a3e2020 ello world\").> \n- 0x01147b90 20202020 20202020 20202020 202c2028 , (\n- 0x01147ba0 22666f6f 6e616d65 222c2077 69746820 \"fooname\", with \n- 0x01147bb0 666f6f20 6e616d65 50616765 290a3e20 foo namePage).> \n- 0x01147bc0 20202020 20202020 20202020 20202c20 , \n- 0x01147bd0 28226261 726e616d 65222c20 77697468 (\"barname\", with\n- 0x01147be0 20626172 206e616d 65506167 65290a3e bar namePage).>\n- 0x01147bf0 20202020 20202020 20202020 2020202c ,\n- 0x01147c00 20282263 6f6d7061 6e79222c 20636f6d (\"company\", com\n- 0x01147c10 70616e79 48616e64 6c657229 0a3e2020 panyHandler).> \n- 0x01147c20 20202020 20202020 20202020 205d0a3e ].>\n- 0x01147c30 20202020 20777261 70536974 6520283c wrapSite (<\n- 0x01147c40 7c3e2068 65697374 53657276 65290a3e |> heistServe).>\n- 0x01147c50 20202020 20726566 203c2d20 6c696674 ref <- lift\n- 0x01147c60 494f2024 206e6577 494f5265 66202266 IO $ newIORef \"f\n- 0x01147c70 6f6f436f 7270220a 3e202020 20207265 ooCorp\".> re\n- 0x01147c80 7475726e 20242041 70702068 73206673 turn $ App hs fs\n- 0x01147c90 20627320 7265660a 0a466f72 206e6f77 bs ref..For now\n- 0x01147ca0 20646f6e 27742077 6f727279 2061626f don't worry abo\n- 0x01147cb0 75742061 6c6c2074 68652064 65746169 ut all the detai\n- 0x01147cc0 6c73206f 66207468 69732063 6f64652e ls of this code.\n- 0x01147cd0 20205765 276c6c20 776f726b 20746872 We'll work thr\n- 0x01147ce0 6f756768 20746865 0a696e64 69766964 ough the.individ\n- 0x01147cf0 75616c20 70696563 6573206f 6e652061 ual pieces one a\n- 0x01147d00 74206120 74696d65 2e202054 68652062 t a time. The b\n- 0x01147d10 61736963 20696465 61206865 72652069 asic idea here i\n- 0x01147d20 73207468 61742074 6f20696e 69746961 s that to initia\n- 0x01147d30 6c697a65 20616e0a 6170706c 69636174 lize an.applicat\n- 0x01147d40 696f6e2c 20776520 66697273 7420696e ion, we first in\n- 0x01147d50 69746961 6c697a65 20656163 68206f66 itialize each of\n- 0x01147d60 20746865 20736e61 706c6574 732c2061 the snaplets, a\n- 0x01147d70 64642073 6f6d6520 726f7574 65732c20 dd some routes, \n- 0x01147d80 72756e20 610a6675 6e637469 6f6e2077 run a.function w\n- 0x01147d90 72617070 696e6720 616c6c20 74686520 rapping all the \n- 0x01147da0 726f7574 65732c20 616e6420 72657475 routes, and retu\n- 0x01147db0 726e2074 68652072 6573756c 74696e67 rn the resulting\n- 0x01147dc0 20737461 74652064 6174610a 73747275 state data.stru\n- 0x01147dd0 63747572 652e2020 54686973 20657861 cture. This exa\n- 0x01147de0 6d706c65 2064656d 6f6e7374 72617465 mple demonstrate\n- 0x01147df0 73207468 65207573 65206f66 20612066 s the use of a f\n- 0x01147e00 6577206f 66207468 65206d6f 73742063 ew of the most c\n- 0x01147e10 6f6d6d6f 6e0a736e 61706c65 74206675 ommon.snaplet fu\n- 0x01147e20 6e637469 6f6e732e 0a0a6e65 7374536e nctions...nestSn\n- 0x01147e30 61706c65 740a2d2d 2d2d2d2d 2d2d2d2d aplet.----------\n- 0x01147e40 2d0a0a41 6c6c2063 616c6c73 20746f20 -..All calls to \n- 0x01147e50 6368696c 6420736e 61706c65 7420696e child snaplet in\n- 0x01147e60 69746961 6c697a65 72206675 6e637469 itializer functi\n- 0x01147e70 6f6e7320 6d757374 20626520 77726170 ons must be wrap\n- 0x01147e80 70656420 696e2061 2063616c 6c20746f ped in a call to\n- 0x01147e90 0a6e6573 74536e61 706c6574 2e202054 .nestSnaplet. T\n- 0x01147ea0 68652066 69727374 20706172 616d6574 he first paramet\n- 0x01147eb0 65722069 73206120 55524c20 70617468 er is a URL path\n- 0x01147ec0 20736567 6d656e74 20746861 74206973 segment that is\n- 0x01147ed0 20757365 6420746f 20707265 6669780a used to prefix.\n- 0x01147ee0 616c6c20 726f7574 65732064 6566696e all routes defin\n- 0x01147ef0 65642062 79207468 6520736e 61706c65 ed by the snaple\n- 0x01147f00 742e2020 54686973 206c6574 7320796f t. This lets yo\n- 0x01147f10 7520656e 73757265 20746861 74207468 u ensure that th\n- 0x01147f20 65726520 77696c6c 20626520 6e6f0a70 ere will be no.p\n- 0x01147f30 726f626c 656d7320 77697468 20647570 roblems with dup\n- 0x01147f40 6c696361 74652072 6f757465 73206465 licate routes de\n- 0x01147f50 66696e65 6420696e 20646966 66657265 fined in differe\n- 0x01147f60 6e742073 6e61706c 6574732e 20204966 nt snaplets. If\n- 0x01147f70 20746865 20666f6f 0a736e61 706c6574 the foo.snaplet\n- 0x01147f80 20646566 696e6573 20612072 6f757465 defines a route\n- 0x01147f90 20602f66 6f6f7061 6765602c 20746865 `/foopage`, the\n- 0x01147fa0 6e20696e 20746865 2061626f 76652065 n in the above e\n- 0x01147fb0 78616d70 6c652c20 74686174 20706167 xample, that pag\n- 0x01147fc0 65207769 6c6c0a62 65206176 61696c61 e will.be availa\n- 0x01147fd0 626c6520 61742060 2f666f6f 2f666f6f ble at `/foo/foo\n- 0x01147fe0 70616765 602e2020 536f6d65 74696d65 page`. Sometime\n- 0x01147ff0 73207468 6f756768 2c20796f 75206d69 s though, you mi\n- 0x01148000 67687420 77616e74 20612073 6e61706c ght want a snapl\n- 0x01148010 65742773 0a726f75 74657320 746f2062 et's.routes to b\n- 0x01148020 65206176 61696c61 626c6520 61742074 e available at t\n- 0x01148030 68652074 6f70206c 6576656c 2e202054 he top level. T\n- 0x01148040 6f20646f 20746861 742c206a 75737420 o do that, just \n- 0x01148050 70617373 20616e20 656d7074 79207374 pass an empty st\n- 0x01148060 72696e67 0a746f20 6e657374 536e6170 ring.to nestSnap\n- 0x01148070 6c657420 61732073 686f776e 2061626f let as shown abo\n- 0x01148080 76652077 69746820 74686520 62617220 ve with the bar \n- 0x01148090 736e6170 6c65742e 0a0a496e 206f7572 snaplet...In our\n- 0x011480a0 20657861 6d706c65 2061626f 76652c20 example above, \n- 0x011480b0 74686520 62617220 736e6170 6c657420 the bar snaplet \n- 0x011480c0 646f6573 20736f6d 65746869 6e672074 does something t\n- 0x011480d0 68617420 6e656564 7320746f 206b6e6f hat needs to kno\n- 0x011480e0 77206162 6f75740a 74686520 666f6f20 w about.the foo \n- 0x011480f0 736e6170 6c65742e 20204d61 79626520 snaplet. Maybe \n- 0x01148100 666f6f20 69732061 20646174 61626173 foo is a databas\n- 0x01148110 6520736e 61706c65 7420616e 64206261 e snaplet and ba\n- 0x01148120 72207761 6e747320 746f2073 746f7265 r wants to store\n- 0x01148130 206f720a 72656164 20736f6d 65746869 or.read somethi\n- 0x01148140 6e672e20 20496e20 6f726465 7220746f ng. In order to\n- 0x01148150 206d616b 65207468 61742068 61707065 make that happe\n- 0x01148160 6e2c2069 74206e65 65647320 746f2068 n, it needs to h\n- 0x01148170 61766520 61202268 616e646c 65222074 ave a \"handle\" t\n- 0x01148180 6f0a7468 6520736e 61706c65 742e2020 o.the snaplet. \n- 0x01148190 4f757220 68616e64 6c657320 61726520 Our handles are \n- 0x011481a0 77686174 65766572 20666965 6c64206e whatever field n\n- 0x011481b0 616d6573 20776520 75736564 20696e20 ames we used in \n- 0x011481c0 74686520 41707020 64617461 0a737472 the App data.str\n- 0x011481d0 75637475 7265206d 696e7573 20746865 ucture minus the\n- 0x011481e0 20696e69 7469616c 20756e64 65727363 initial undersc\n- 0x011481f0 6f726520 63686172 61637465 722e2020 ore character. \n- 0x01148200 54686579 20617265 20617574 6f6d6174 They are automat\n- 0x01148210 6963616c 6c790a67 656e6572 61746564 ically.generated\n- 0x01148220 20627920 74686520 606d616b 654c656e by the `makeLen\n- 0x01148230 73657360 2066756e 6374696f 6e2e2020 ses` function. \n- 0x01148240 466f7220 6e6f7720 69742773 20737566 For now it's suf\n- 0x01148250 66696369 656e7420 746f2074 68696e6b ficient to think\n- 0x01148260 206f660a 7468656d 20617320 61206765 of.them as a ge\n- 0x01148270 74746572 20616e64 20612073 65747465 tter and a sette\n- 0x01148280 7220636f 6d62696e 65642028 746f2075 r combined (to u\n- 0x01148290 73652061 6e204f4f 206d6574 6170686f se an OO metapho\n- 0x011482a0 72292e0a 0a546865 20736563 6f6e6420 r)...The second \n- 0x011482b0 70617261 6d657465 7220746f 206e6573 parameter to nes\n- 0x011482c0 74536e61 706c6574 20697320 74686520 tSnaplet is the \n- 0x011482d0 6c656e73 20746f20 74686520 736e6170 lens to the snap\n- 0x011482e0 6c657420 796f7527 7265206e 65737469 let you're nesti\n- 0x011482f0 6e672e0a 496e206f 72646572 20746f20 ng..In order to \n- 0x01148300 706c6163 65206120 70696563 6520696e place a piece in\n- 0x01148310 746f2074 68652070 757a7a6c 652c2079 to the puzzle, y\n- 0x01148320 6f75206e 65656420 746f206b 6e6f7720 ou need to know \n- 0x01148330 77686572 65206974 20676f65 732e0a0a where it goes...\n- 0x01148340 6e616d65 536e6170 6c65740a 2d2d2d2d nameSnaplet.----\n- 0x01148350 2d2d2d2d 2d2d2d0a 0a546865 20617574 -------..The aut\n- 0x01148360 686f7220 6f662061 20736e61 706c6574 hor of a snaplet\n- 0x01148370 20646566 696e6573 20612064 65666175 defines a defau\n- 0x01148380 6c74206e 616d6520 666f7220 74686520 lt name for the \n- 0x01148390 736e6170 6c657420 696e2074 68652066 snaplet in the f\n- 0x011483a0 69727374 0a617267 756d656e 7420746f irst.argument to\n- 0x011483b0 20746865 206d616b 65536e61 706c6574 the makeSnaplet\n- 0x011483c0 2066756e 6374696f 6e2e2020 54686973 function. This\n- 0x011483d0 206e616d 65206973 20757365 6420666f name is used fo\n- 0x011483e0 72207468 6520736e 61706c65 7427730a r the snaplet's.\n- 0x011483f0 64697265 63746f72 7920696e 20746865 directory in the\n- 0x01148400 2066696c 65737973 74656d2e 20204966 filesystem. If\n- 0x01148410 20796f75 20646f6e 27742077 616e7420 you don't want \n- 0x01148420 746f2075 73652074 68652064 65666175 to use the defau\n- 0x01148430 6c74206e 616d652c 20796f75 0a63616e lt name, you.can\n- 0x01148440 206f7665 72726964 65206974 20776974 override it wit\n- 0x01148450 68207468 6520606e 616d6553 6e61706c h the `nameSnapl\n- 0x01148460 65746020 66756e63 74696f6e 2e202041 et` function. A\n- 0x01148470 6c736f2c 20696620 796f7520 77616e74 lso, if you want\n- 0x01148480 20746f20 68617665 2074776f 0a696e73 to have two.ins\n- 0x01148490 74616e63 6573206f 66207468 65207361 tances of the sa\n- 0x011484a0 6d652073 6e61706c 65742c20 7468656e me snaplet, then\n- 0x011484b0 20796f75 2077696c 6c206e65 65642074 you will need t\n- 0x011484c0 6f207573 6520606e 616d6553 6e61706c o use `nameSnapl\n- 0x011484d0 65746020 746f2067 6976650a 6174206c et` to give.at l\n- 0x011484e0 65617374 206f6e65 206f6620 7468656d east one of them\n- 0x011484f0 20612075 6e697175 65206e61 6d652e0a a unique name..\n- 0x01148500 0a616464 526f7574 65730a2d 2d2d2d2d .addRoutes.-----\n- 0x01148510 2d2d2d2d 0a0a5468 65206061 6464526f ----..The `addRo\n- 0x01148520 75746573 60206675 6e637469 6f6e2069 utes` function i\n- 0x01148530 7320686f 7720616e 20617070 6c696361 s how an applica\n- 0x01148540 74696f6e 20286f72 20736e61 706c6574 tion (or snaplet\n- 0x01148550 29206465 66696e65 73206974 730a726f ) defines its.ro\n- 0x01148560 75746573 2e202055 6e646572 20746865 utes. Under the\n- 0x01148570 20686f6f 64207468 6520736e 61706c65 hood the snaple\n- 0x01148580 7420696e 66726173 74727563 74757265 t infrastructure\n- 0x01148590 206d6572 67657320 616c6c20 74686520 merges all the \n- 0x011485a0 726f7574 65732066 726f6d0a 616c6c20 routes from.all \n- 0x011485b0 736e6170 6c657473 2c207072 6570656e snaplets, prepen\n- 0x011485c0 64732070 72656669 78657320 66726f6d ds prefixes from\n- 0x011485d0 20606e65 7374536e 61706c65 74602063 `nestSnaplet` c\n- 0x011485e0 616c6c73 2c20616e 64207061 73736573 alls, and passes\n- 0x011485f0 20746865 206c6973 740a746f 20536e61 the list.to Sna\n- 0x01148600 7027730a 5b726f75 74655d28 68747470 p's.[route](http\n- 0x01148610 3a2f2f68 61636b61 67652e68 61736b65 ://hackage.haske\n- 0x01148620 6c6c2e6f 72672f70 61636b61 6765732f ll.org/packages/\n- 0x01148630 61726368 6976652f 736e6170 2d636f72 archive/snap-cor\n- 0x01148640 652f302e 352e312e 342f646f 632f6874 e/0.5.1.4/doc/ht\n- 0x01148650 6d6c2f53 6e61702d 54797065 732e6874 ml/Snap-Types.ht\n- 0x01148660 6d6c2376 3a726f75 7465290a 66756e63 ml#v:route).func\n- 0x01148670 74696f6e 2e0a0a41 20726f75 74652069 tion...A route i\n- 0x01148680 73206120 7475706c 65206f66 20612055 s a tuple of a U\n- 0x01148690 524c2061 6e642061 2068616e 646c6572 RL and a handler\n- 0x011486a0 2066756e 6374696f 6e207468 61742077 function that w\n- 0x011486b0 696c6c20 62652063 616c6c65 64207768 ill be called wh\n- 0x011486c0 656e0a74 68652055 524c2069 73207265 en.the URL is re\n- 0x011486d0 71756573 7465642e 20204861 6e646c65 quested. Handle\n- 0x011486e0 72206973 20612077 72617070 65722061 r is a wrapper a\n- 0x011486f0 726f756e 64207468 6520536e 6170206d round the Snap m\n- 0x01148700 6f6e6164 20746861 74206861 6e646c65 onad that handle\n- 0x01148710 730a7468 6520736e 61706c65 74277320 s.the snaplet's \n- 0x01148720 696e6672 61737472 75637475 72652e20 infrastructure. \n- 0x01148730 20447572 696e6720 696e6974 69616c69 During initiali\n- 0x01148740 7a617469 6f6e2c20 736e6170 6c657473 zation, snaplets\n- 0x01148750 20757365 20746865 0a60496e 69746961 use the.`Initia\n- 0x01148760 6c697a65 7260206d 6f6e6164 2e202044 lizer` monad. D\n- 0x01148770 7572696e 67207275 6e74696d 652c2074 uring runtime, t\n- 0x01148780 68657920 75736520 74686520 6048616e hey use the `Han\n- 0x01148790 646c6572 60206d6f 6e61642e 20205765 dler` monad. We\n- 0x011487a0 276c6c0a 64697363 75737320 6048616e 'll.discuss `Han\n- 0x011487b0 646c6572 6020696e 206d6f72 65206465 dler` in more de\n- 0x011487c0 7461696c 206c6174 65722e20 20496620 tail later. If \n- 0x011487d0 796f7527 72652066 616d696c 69617220 you're familiar \n- 0x011487e0 77697468 20536e61 70277320 6f6c640a with Snap's old.\n- 0x011487f0 65787465 6e73696f 6e207379 7374656d extension system\n- 0x01148800 2c20796f 75206361 6e207468 696e6b20 , you can think \n- 0x01148810 6f662069 74206173 20726f75 67686c79 of it as roughly\n- 0x01148820 20657175 6976616c 656e7420 746f2074 equivalent to t\n- 0x01148830 68652041 70706c69 63617469 6f6e0a6d he Application.m\n- 0x01148840 6f6e6164 2e202049 74206861 73206120 onad. It has a \n- 0x01148850 604d6f6e 61645374 61746560 20696e73 `MonadState` ins\n- 0x01148860 74616e63 65207468 6174206c 65747320 tance that lets \n- 0x01148870 796f7520 61636365 73732061 6e64206d you access and m\n- 0x01148880 6f646966 79207468 650a6375 7272656e odify the.curren\n- 0x01148890 7420736e 61706c65 74277320 73746174 t snaplet's stat\n- 0x011488a0 652c2061 6e642061 20604d6f 6e616453 e, and a `MonadS\n- 0x011488b0 6e617060 20696e73 74616e63 65207072 nap` instance pr\n- 0x011488c0 6f766964 696e6720 7468650a 72657175 oviding the.requ\n- 0x011488d0 6573742d 70726f63 65737369 6e672066 est-processing f\n- 0x011488e0 756e6374 696f6e73 20646566 696e6564 unctions defined\n- 0x011488f0 20696e20 536e6170 2e547970 65732e0a in Snap.Types..\n- 0x01148900 0a777261 70536974 650a2d2d 2d2d2d2d .wrapSite.------\n- 0x01148910 2d2d2d2d 2d2d0a0a 60777261 70536974 ------..`wrapSit\n- 0x01148920 65602061 6c6c6f77 7320796f 7520746f e` allows you to\n- 0x01148930 20617070 6c792061 6e206172 62697472 apply an arbitr\n- 0x01148940 61727920 6048616e 646c6572 60207472 ary `Handler` tr\n- 0x01148950 616e7366 6f726d61 74696f6e 20746f0a ansformation to.\n- 0x01148960 74686520 746f702d 6c657665 6c206861 the top-level ha\n- 0x01148970 6e646c65 722e2020 54686973 20697320 ndler. This is \n- 0x01148980 75736566 756c2069 6620796f 75207761 useful if you wa\n- 0x01148990 6e742074 6f20646f 20736f6d 65206765 nt to do some ge\n- 0x011489a0 6e657269 630a7072 6f636573 73696e67 neric.processing\n- 0x011489b0 20617420 74686520 62656769 6e6e696e at the beginnin\n- 0x011489c0 67206f72 20656e64 206f6620 65766572 g or end of ever\n- 0x011489d0 79207265 71756573 742e2020 466f7220 y request. For \n- 0x011489e0 696e7374 616e6365 2c206120 73657373 instance, a sess\n- 0x011489f0 696f6e0a 736e6170 6c657420 6d696768 ion.snaplet migh\n- 0x01148a00 74207573 65206974 20746f20 746f7563 t use it to touc\n- 0x01148a10 68206120 73657373 696f6e20 61637469 h a session acti\n- 0x01148a20 76697479 20746f6b 656e2062 65666f72 vity token befor\n- 0x01148a30 6520726f 7574696e 67206861 7070656e e routing happen\n- 0x01148a40 732e0a49 7420636f 756c6420 616c736f s..It could also\n- 0x01148a50 20626520 75736564 20746f20 696d706c be used to impl\n- 0x01148a60 656d656e 74206375 73746f6d 206c6f67 ement custom log\n- 0x01148a70 67696e67 2e202054 68652065 78616d70 ging. The examp\n- 0x01148a80 6c652061 626f7665 20757365 73206974 le above uses it\n- 0x01148a90 0a746f20 64656669 6e652068 65697374 .to define heist\n- 0x01148aa0 53657276 65202870 726f7669 64656420 Serve (provided \n- 0x01148ab0 62792074 68652048 65697374 20736e61 by the Heist sna\n- 0x01148ac0 706c6574 29206173 20746865 20646566 plet) as the def\n- 0x01148ad0 61756c74 2068616e 646c6572 20746f0a ault handler to.\n- 0x01148ae0 62652074 72696564 20696620 6e6f206f be tried if no o\n- 0x01148af0 74686572 2068616e 646c6572 206d6174 ther handler mat\n- 0x01148b00 63686564 2e202054 68697320 6d617920 ched. This may \n- 0x01148b10 7365656d 206c696b 6520616e 20656173 seem like an eas\n- 0x01148b20 79207761 7920746f 20646566 696e650a y way to define.\n- 0x01148b30 726f7574 65732c20 62757420 69662079 routes, but if y\n- 0x01148b40 6f752073 7472696e 67207468 656d2061 ou string them a\n- 0x01148b50 6c6c2074 6f676574 68657220 696e2074 ll together in t\n- 0x01148b60 68697320 77617920 65616368 2068616e his way each han\n- 0x01148b70 646c6572 2077696c 6c206265 0a657661 dler will be.eva\n- 0x01148b80 6c756174 65642073 65717565 6e746961 luated sequentia\n- 0x01148b90 6c6c7920 616e6420 796f7527 6c6c2067 lly and you'll g\n- 0x01148ba0 6574204f 286e2920 74696d65 20636f6d et O(n) time com\n- 0x01148bb0 706c6578 6974792c 20776865 72656173 plexity, whereas\n- 0x01148bc0 20726f75 7465730a 64656669 6e656420 routes.defined \n- 0x01148bd0 77697468 20606164 64526f75 74657360 with `addRoutes`\n- 0x01148be0 20686176 65204f28 6c6f6720 6e292074 have O(log n) t\n- 0x01148bf0 696d6520 636f6d70 6c657869 74792e20 ime complexity. \n- 0x01148c00 20546865 7265666f 72652c20 696e2061 Therefore, in a\n- 0x01148c10 0a726561 6c2d776f 726c6420 6170706c .real-world appl\n- 0x01148c20 69636174 696f6e20 796f7520 776f756c ication you woul\n- 0x01148c30 64207072 6f626162 6c792077 616e7420 d probably want \n- 0x01148c40 746f2068 61766520 60282222 2c206865 to have `(\"\", he\n- 0x01148c50 69737453 65727665 29602069 6e0a7468 istServe)` in.th\n- 0x01148c60 65206c69 73742070 61737365 6420746f e list passed to\n- 0x01148c70 20606164 64526f75 74657360 2e0a0a77 `addRoutes`...w\n- 0x01148c80 6974680a 2d2d2d2d 0a0a5468 65206c61 ith.----..The la\n- 0x01148c90 73742075 6e66616d 696c6961 72206675 st unfamiliar fu\n- 0x01148ca0 6e637469 6f6e2069 6e207468 65206578 nction in the ex\n- 0x01148cb0 616d706c 65206973 20607769 7468602e ample is `with`.\n- 0x01148cc0 20204865 72652069 74206163 636f6d70 Here it accomp\n- 0x01148cd0 616e6965 7320610a 63616c6c 20746f20 anies a.call to \n- 0x01148ce0 74686520 66756e63 74696f6e 20606e61 the function `na\n- 0x01148cf0 6d655061 6765602e 2020606e 616d6550 mePage`. `nameP\n- 0x01148d00 61676560 20697320 61207369 6d706c65 age` is a simple\n- 0x01148d10 20657861 6d706c65 2068616e 646c6572 example handler\n- 0x01148d20 20616e64 0a6c6f6f 6b73206c 696b6520 and.looks like \n- 0x01148d30 74686973 2e0a0a3e 206e616d 65506167 this...> namePag\n- 0x01148d40 65203a3a 2048616e 646c6572 20622076 e :: Handler b v\n- 0x01148d50 2028290a 3e206e61 6d655061 6765203d ().> namePage =\n- 0x01148d60 20646f0a 3e202020 20206d6e 616d6520 do.> mname \n- 0x01148d70 3c2d2067 6574536e 61706c65 744e616d <- getSnapletNam\n- 0x01148d80 650a3e20 20202020 77726974 65546578 e.> writeTex\n- 0x01148d90 74202420 66726f6d 4d617962 65202254 t $ fromMaybe \"T\n- 0x01148da0 68697320 73686f75 6c646e27 74206861 his shouldn't ha\n- 0x01148db0 7070656e 22206d6e 616d650a 0a546869 ppen\" mname..Thi\n- 0x01148dc0 73206675 6e637469 6f6e2069 73206120 s function is a \n- 0x01148dd0 67656e65 72696320 68616e64 6c657220 generic handler \n- 0x01148de0 74686174 20676574 73207468 65206e61 that gets the na\n- 0x01148df0 6d65206f 66207468 65206375 7272656e me of the curren\n- 0x01148e00 7420736e 61706c65 740a616e 64207772 t snaplet.and wr\n- 0x01148e10 69746573 20697420 696e746f 20746865 ites it into the\n- 0x01148e20 20726573 706f6e73 65207769 74682074 response with t\n- 0x01148e30 68652060 77726974 65546578 74602066 he `writeText` f\n- 0x01148e40 756e6374 696f6e20 64656669 6e656420 unction defined \n- 0x01148e50 62792074 68650a73 6e61702d 636f7265 by the.snap-core\n- 0x01148e60 2070726f 6a656374 2e202054 68652074 project. The t\n- 0x01148e70 79706520 76617269 61626c65 73202762 ype variables 'b\n- 0x01148e80 2720616e 64202776 2720696e 64696361 ' and 'v' indica\n- 0x01148e90 74652074 68617420 74686973 2066756e te that this fun\n- 0x01148ea0 6374696f 6e0a7769 6c6c2077 6f726b20 ction.will work \n- 0x01148eb0 696e2061 6e792073 6e61706c 65742077 in any snaplet w\n- 0x01148ec0 69746820 616e7920 62617365 20617070 ith any base app\n- 0x01148ed0 6c696361 74696f6e 2e202054 68652027 lication. The '\n- 0x01148ee0 77697468 27206675 6e637469 6f6e2069 with' function i\n- 0x01148ef0 730a7573 65642074 6f207275 6e20606e s.used to run `n\n- 0x01148f00 616d6550 61676560 20696e20 74686520 amePage` in the \n- 0x01148f10 636f6e74 65787420 6f662074 68652073 context of the s\n- 0x01148f20 6e61706c 65747320 666f6f20 616e6420 naplets foo and \n- 0x01148f30 62617220 666f7220 7468650a 636f7272 bar for the.corr\n- 0x01148f40 6573706f 6e64696e 6720726f 75746573 esponding routes\n- 0x01148f50 2e0a0a53 69746520 52656c6f 6164696e ...Site Reloadin\n- 0x01148f60 670a2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d g.--------------\n- 0x01148f70 0a0a536e 61706c65 7420496e 69746961 ..Snaplet Initia\n- 0x01148f80 6c697a65 72732073 65727665 20647561 lizers serve dua\n- 0x01148f90 6c207075 72706f73 65206173 20626f74 l purpose as bot\n- 0x01148fa0 6820696e 69746961 6c697a65 72732061 h initializers a\n- 0x01148fb0 6e642072 656c6f61 64657273 2e0a5265 nd reloaders..Re\n- 0x01148fc0 6c6f6164 73206172 65207472 69676765 loads are trigge\n- 0x01148fd0 72656420 62792061 20737065 6369616c red by a special\n- 0x01148fe0 2068616e 646c6572 20746861 74206973 handler that is\n- 0x01148ff0 20626f75 6e642074 6f207468 650a602f bound to the.`/\n- 0x01149000 61646d69 6e2f7265 6c6f6164 6020726f admin/reload` ro\n- 0x01149010 7574652e 20205468 69732068 616e646c ute. This handl\n- 0x01149020 65722072 652d7275 6e732074 68652073 er re-runs the s\n- 0x01149030 69746520 696e6974 69616c69 7a657220 ite initializer \n- 0x01149040 616e6420 69662069 74206973 0a737563 and if it is.suc\n- 0x01149050 63657373 66756c2c 206c6f61 64732074 cessful, loads t\n- 0x01149060 6865206e 65776c79 2067656e 65726174 he newly generat\n- 0x01149070 65642069 6e2d6d65 6d6f7279 20737461 ed in-memory sta\n- 0x01149080 74652e20 20546f20 70726576 656e7420 te. To prevent \n- 0x01149090 64656e69 616c206f 660a7365 72766963 denial of.servic\n- 0x011490a0 65206174 7461636b 732c2074 68652072 e attacks, the r\n- 0x011490b0 656c6f61 6420726f 75746520 6973206f eload route is o\n- 0x011490c0 6e6c7920 61636365 73736962 6c652066 nly accessible f\n- 0x011490d0 726f6d20 6c6f6361 6c686f73 742e0a0a rom localhost...\n- 0x011490e0 49662074 68657265 20617265 20616e79 If there are any\n- 0x011490f0 20657272 6f727320 64757269 6e672072 errors during r\n- 0x01149100 656c6f61 642c2079 6f752077 6f756c64 eload, you would\n- 0x01149110 206e6174 7572616c 6c792077 616e7420 naturally want \n- 0x01149120 746f2073 65652074 68656d20 696e0a74 to see them in.t\n- 0x01149130 68652048 54545020 72657370 6f6e7365 he HTTP response\n- 0x01149140 20726574 75726e65 64206279 20746865 returned by the\n- 0x01149150 20736572 7665722e 2020486f 77657665 server. Howeve\n- 0x01149160 722c2077 68656e20 74686573 65207361 r, when these sa\n- 0x01149170 6d650a69 6e697469 616c697a 65727320 me.initializers \n- 0x01149180 61726520 72756e20 7768656e 20796f75 are run when you\n- 0x01149190 20666972 73742073 74617274 20796f75 first start you\n- 0x011491a0 72206170 702c2079 6f752077 696c6c20 r app, you will \n- 0x011491b0 77616e74 20746f20 7365650a 73746174 want to see.stat\n- 0x011491c0 7573206d 65737361 67657320 7072696e us messages prin\n- 0x011491d0 74656420 746f2074 68652063 6f6e736f ted to the conso\n- 0x011491e0 6c652e20 20546f20 6d616b65 20746869 le. To make thi\n- 0x011491f0 7320706f 73736962 6c652077 65207072 s possible we pr\n- 0x01149200 6f766964 65207468 650a6070 72696e74 ovide the.`print\n- 0x01149210 496e666f 60206675 6e637469 6f6e2e20 Info` function. \n- 0x01149220 20596f75 2073686f 756c6420 75736520 You should use \n- 0x01149230 69742074 6f206f75 74707574 20616e79 it to output any\n- 0x01149240 20696e66 6f726d61 74696f6e 616c206d informational m\n- 0x01149250 65737361 6765730a 67656e65 72617465 essages.generate\n- 0x01149260 64206279 20796f75 7220696e 69746961 d by your initia\n- 0x01149270 6c697a65 72732e20 20496620 796f7520 lizers. If you \n- 0x01149280 7072696e 74206469 72656374 6c792074 print directly t\n- 0x01149290 6f207374 616e6461 7264206f 75747075 o standard outpu\n- 0x011492a0 74206f72 0a737461 6e646172 64206572 t or.standard er\n- 0x011492b0 726f722c 20746865 6e207468 6f736520 ror, then those \n- 0x011492c0 6d657373 61676573 2077696c 6c206e6f messages will no\n- 0x011492d0 74206265 20617661 696c6162 6c652069 t be available i\n- 0x011492e0 6e20796f 75722062 726f7773 65722077 n your browser w\n- 0x011492f0 68656e0a 796f7520 72656c6f 61642074 hen.you reload t\n- 0x01149300 68652073 6974652e 0a0a576f 726b696e he site...Workin\n- 0x01149310 67207769 74682073 74617465 0a2d2d2d g with state.---\n- 0x01149320 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d0a ---------------.\n- 0x01149330 0a604861 6e646c65 72206220 76602068 .`Handler b v` h\n- 0x01149340 61732061 20604d6f 6e616453 74617465 as a `MonadState\n- 0x01149350 20766020 696e7374 616e6365 2e202054 v` instance. T\n- 0x01149360 68697320 6d65616e 73207468 61742079 his means that y\n- 0x01149370 6f752063 616e2061 63636573 730a616c ou can access.al\n- 0x01149380 6c20796f 75722073 6e61706c 65742073 l your snaplet s\n- 0x01149390 74617465 20746872 6f756768 20746865 tate through the\n- 0x011493a0 20676574 2c207075 742c2067 6574732c get, put, gets,\n- 0x011493b0 20616e64 206d6f64 69667920 66756e63 and modify func\n- 0x011493c0 74696f6e 73207468 61740a61 72652070 tions that.are p\n- 0x011493d0 726f6261 626c7920 66616d69 6c696172 robably familiar\n- 0x011493e0 2066726f 6d207468 65207374 61746520 from the state \n- 0x011493f0 6d6f6e61 642e2020 496e206f 75722065 monad. In our e\n- 0x01149400 78616d70 6c652061 70706c69 63617469 xample applicati\n- 0x01149410 6f6e2077 650a6465 6d6f6e73 74726174 on we.demonstrat\n- 0x01149420 65207468 69732077 69746820 60636f6d e this with `com\n- 0x01149430 70616e79 48616e64 6c657260 2e0a0a3e panyHandler`...>\n- 0x01149440 20636f6d 70616e79 48616e64 6c657220 companyHandler \n- 0x01149450 3a3a2048 616e646c 65722041 70702041 :: Handler App A\n- 0x01149460 70702028 290a3e20 636f6d70 616e7948 pp ().> companyH\n- 0x01149470 616e646c 6572203d 206d6574 686f6420 andler = method \n- 0x01149480 47455420 67657474 6572203c 7c3e206d GET getter <|> m\n- 0x01149490 6574686f 6420504f 53542073 65747465 ethod POST sette\n- 0x011494a0 720a3e20 20207768 6572650a 3e202020 r.> where.> \n- 0x011494b0 20206765 74746572 203d2064 6f0a3e20 getter = do.> \n- 0x011494c0 20202020 20202020 6e616d65 52656620 nameRef \n- 0x011494d0 3c2d2067 65747320 5f636f6d 70616e79 <- gets _company\n- 0x011494e0 4e616d65 0a3e2020 20202020 2020206e Name.> n\n- 0x011494f0 616d6520 3c2d206c 69667449 4f202420 ame <- liftIO $ \n- 0x01149500 72656164 494f5265 66206e61 6d655265 readIORef nameRe\n- 0x01149510 660a3e20 20202020 20202020 77726974 f.> writ\n- 0x01149520 65425320 6e616d65 0a3e2020 20202073 eBS name.> s\n- 0x01149530 65747465 72203d20 646f0a3e 20202020 etter = do.> \n- 0x01149540 20202020 206d6e61 6d65203c 2d206765 mname <- ge\n- 0x01149550 74506172 616d2022 6e616d65 220a3e20 tParam \"name\".> \n- 0x01149560 20202020 20202020 6e616d65 52656620 nameRef \n- 0x01149570 3c2d2067 65747320 5f636f6d 70616e79 <- gets _company\n- 0x01149580 4e616d65 0a3e2020 20202020 2020206c Name.> l\n- 0x01149590 69667449 4f202420 6d617962 65202872 iftIO $ maybe (r\n- 0x011495a0 65747572 6e202829 29202877 72697465 eturn ()) (write\n- 0x011495b0 494f5265 66206e61 6d655265 6629206d IORef nameRef) m\n- 0x011495c0 6e616d65 0a3e2020 20202020 20202067 name.> g\n- 0x011495d0 65747465 720a0a49 6620796f 75207365 etter..If you se\n- 0x011495e0 74206120 47455420 72657175 65737420 t a GET request \n- 0x011495f0 746f2060 2f636f6d 70616e79 602c2079 to `/company`, y\n- 0x01149600 6f75276c 6c206765 74207468 65207374 ou'll get the st\n- 0x01149610 72696e67 2022666f 6f436f72 70222062 ring \"fooCorp\" b\n- 0x01149620 61636b2e 0a496620 796f7520 73656e64 ack..If you send\n- 0x01149630 20612050 4f535420 72657175 6573742c a POST request,\n- 0x01149640 20697420 77696c6c 20736574 20746865 it will set the\n- 0x01149650 20494f52 65662068 656c6420 696e2074 IORef held in t\n- 0x01149660 68652060 5f636f6d 70616e79 4e616d65 he `_companyName\n- 0x01149670 600a6669 656c6420 696e2074 68652060 `.field in the `\n- 0x01149680 41707060 20646174 61207374 72756374 App` data struct\n- 0x01149690 75726520 746f2074 68652076 616c7565 ure to the value\n- 0x011496a0 206f6620 74686520 606e616d 65602066 of the `name` f\n- 0x011496b0 69656c64 2e202054 68656e20 69740a63 ield. Then it.c\n- 0x011496c0 616c6c73 20746865 20676574 74657220 alls the getter \n- 0x011496d0 746f2072 65747572 6e207468 61742076 to return that v\n- 0x011496e0 616c7565 20626163 6b20746f 20796f75 alue back to you\n- 0x011496f0 20736f20 796f7520 63616e20 73656520 so you can see \n- 0x01149700 69742077 61730a61 63747561 6c6c7920 it was.actually \n- 0x01149710 6368616e 6765642e 20204167 61696e2c changed. Again,\n- 0x01149720 2072656d 656d6265 72207468 61742074 remember that t\n- 0x01149730 68697320 6368616e 6765206f 6e6c7920 his change only \n- 0x01149740 70657273 69737473 20616372 6f73730a persists across.\n- 0x01149750 72657175 65737473 20626563 61757365 requests because\n- 0x01149760 20776520 75736564 20616e20 494f5265 we used an IORe\n- 0x01149770 662e2020 49662060 5f636f6d 70616e79 f. If `_company\n- 0x01149780 4e616d65 60207761 73206a75 73742061 Name` was just a\n- 0x01149790 20706c61 696e2073 7472696e 670a616e plain string.an\n- 0x011497a0 64207765 20686164 20757365 64206d6f d we had used mo\n- 0x011497b0 64696679 2c207468 65206368 616e6765 dify, the change\n- 0x011497c0 64207265 73756c74 20776f75 6c64206f d result would o\n- 0x011497d0 6e6c7920 62652076 69736962 6c652069 nly be visible i\n- 0x011497e0 6e207468 65207265 73740a6f 66207468 n the rest.of th\n- 0x011497f0 65207072 6f636573 73696e67 20666f72 e processing for\n- 0x01149800 20746861 74207265 71756573 742e0a0a that request...\n- 0x01149810 54686520 48656973 7420536e 61706c65 The Heist Snaple\n- 0x01149820 740a3d3d 3d3d3d3d 3d3d3d3d 3d3d3d3d t.==============\n- 0x01149830 3d3d3d0a 0a546865 20617374 75746520 ===..The astute \n- 0x01149840 72656164 6572206d 69676874 2061736b reader might ask\n- 0x01149850 20776879 20746865 72652069 73206e6f why there is no\n- 0x01149860 20607769 74682068 65697374 6020696e `with heist` in\n- 0x01149870 2066726f 6e74206f 66207468 65206361 front of the ca\n- 0x01149880 6c6c0a74 6f206068 65697374 53657276 ll.to `heistServ\n- 0x01149890 65602e20 20416e64 20696e64 6565642c e`. And indeed,\n- 0x011498a0 20746861 7420776f 756c6420 6e6f726d that would norm\n- 0x011498b0 616c6c79 20626520 74686520 63617365 ally be the case\n- 0x011498c0 2e202042 75742077 65206465 63696465 . But we decide\n- 0x011498d0 640a7468 61742061 6e206170 706c6963 d.that an applic\n- 0x011498e0 6174696f 6e207769 6c6c206e 65766572 ation will never\n- 0x011498f0 206e6565 64206d6f 72652074 68616e20 need more than \n- 0x01149900 6f6e6520 696e7374 616e6365 206f6620 one instance of \n- 0x01149910 61204865 69737420 736e6170 6c65742e a Heist snaplet.\n- 0x01149920 0a536f20 77652070 726f7669 64656420 .So we provided \n- 0x01149930 61207479 70652063 6c617373 2063616c a type class cal\n- 0x01149940 6c656420 60486173 48656973 74602074 led `HasHeist` t\n- 0x01149950 68617420 616c6c6f 77732061 6e206170 hat allows an ap\n- 0x01149960 706c6963 6174696f 6e20746f 0a646566 plication to.def\n- 0x01149970 696e6520 74686520 676c6f62 616c2072 ine the global r\n- 0x01149980 65666572 656e6365 20746f20 69747320 eference to its \n- 0x01149990 48656973 7420736e 61706c65 74206279 Heist snaplet by\n- 0x011499a0 20777269 74696e67 20612060 48617348 writing a `HasH\n- 0x011499b0 65697374 600a696e 7374616e 63652e20 eist`.instance. \n- 0x011499c0 20496e20 74686973 20657861 6d706c65 In this example\n- 0x011499d0 20776520 64656669 6e652074 68652069 we define the i\n- 0x011499e0 6e737461 6e636520 61732066 6f6c6c6f nstance as follo\n- 0x011499f0 77733a0a 0a3e2069 6e737461 6e636520 ws:..> instance \n- 0x01149a00 48617348 65697374 20417070 20776865 HasHeist App whe\n- 0x01149a10 72652068 65697374 4c656e73 203d2073 re heistLens = s\n- 0x01149a20 7562536e 61706c65 74206865 6973740a ubSnaplet heist.\n- 0x01149a30 0a4e6f77 20616c6c 20776520 6e656564 .Now all we need\n- 0x01149a40 20697320 61207369 6d706c65 206d6169 is a simple mai\n- 0x01149a50 6e206675 6e637469 6f6e2074 6f207365 n function to se\n- 0x01149a60 72766520 6f757220 6170706c 69636174 rve our applicat\n- 0x01149a70 696f6e2e 0a0a3e20 6d61696e 203a3a20 ion...> main :: \n- 0x01149a80 494f2028 290a3e20 6d61696e 203d2073 IO ().> main = s\n- 0x01149a90 65727665 536e6170 6c657420 64656661 erveSnaplet defa\n- 0x01149aa0 756c7443 6f6e6669 67206170 70496e69 ultConfig appIni\n- 0x01149ab0 740a0a54 68697320 636f6d70 6c657465 t..This complete\n- 0x01149ac0 73206120 66756c6c 20776f72 6b696e67 s a full working\n- 0x01149ad0 20617070 6c696361 74696f6e 2e202057 application. W\n- 0x01149ae0 65206469 64206c65 61766520 6f757420 e did leave out \n- 0x01149af0 61206c69 74746c65 2064756d 6d790a63 a little dummy.c\n- 0x01149b00 6f646520 666f7220 74686520 466f6f20 ode for the Foo \n- 0x01149b10 616e6420 42617220 736e6170 6c657473 and Bar snaplets\n- 0x01149b20 2e202054 68697320 636f6465 20697320 . This code is \n- 0x01149b30 696e636c 75646564 20696e20 50617274 included in Part\n- 0x01149b40 322e6873 2e202046 6f720a6d 6f726520 2.hs. For.more \n- 0x01149b50 696e666f 726d6174 696f6e20 6c6f6f6b information look\n- 0x01149b60 20696e20 6f757220 5b415049 0a646f63 in our [API.doc\n- 0x01149b70 756d656e 74617469 6f6e5d28 68747470 umentation](http\n- 0x01149b80 3a2f2f68 61636b61 67652e68 61736b65 ://hackage.haske\n- 0x01149b90 6c6c2e6f 72672f70 61636b61 67652f73 ll.org/package/s\n- 0x01149ba0 6e617029 2c207370 65636966 6963616c nap), specifical\n- 0x01149bb0 6c792074 68650a53 6e61702e 536e6170 ly the.Snap.Snap\n- 0x01149bc0 6c657420 6d6f6475 6c652e20 204e6f20 let module. No \n- 0x01149bd0 7265616c 6c792c20 74686174 20776173 really, that was\n- 0x01149be0 6e277420 61206a6f 6b652e20 20546865 n't a joke. The\n- 0x01149bf0 20415049 20646f63 73206172 65207772 API docs are wr\n- 0x01149c00 69747465 6e0a6173 2070726f 73652e20 itten.as prose. \n- 0x01149c10 20546865 79207368 6f756c64 20626520 They should be \n- 0x01149c20 76657279 20656173 7920746f 20726561 very easy to rea\n- 0x01149c30 642c2077 68696c65 20686176 696e6720 d, while having \n- 0x01149c40 74686520 62656e65 66697420 6f660a69 the benefit of.i\n- 0x01149c50 6e636c75 64696e67 20616c6c 20746865 ncluding all the\n- 0x01149c60 20616374 75616c20 74797065 20736967 actual type sig\n- 0x01149c70 6e617475 7265732e 0a0a4669 6c657379 natures...Filesy\n- 0x01149c80 7374656d 20446174 6120616e 64204175 stem Data and Au\n- 0x01149c90 746f6d61 74696320 496e7374 616c6c61 tomatic Installa\n- 0x01149ca0 74696f6e 0a3d3d3d 3d3d3d3d 3d3d3d3d tion.===========\n- 0x01149cb0 3d3d3d3d 3d3d3d3d 3d3d3d3d 3d3d3d3d ================\n- 0x01149cc0 3d3d3d3d 3d3d3d3d 3d3d3d3d 3d3d3d0a ===============.\n- 0x01149cd0 0a536f6d 6520736e 61706c65 74732077 .Some snaplets w\n- 0x01149ce0 696c6c20 68617665 20646174 61207374 ill have data st\n- 0x01149cf0 6f726564 20696e20 74686520 66696c65 ored in the file\n- 0x01149d00 73797374 656d2074 68617420 73686f75 system that shou\n- 0x01149d10 6c642062 6520696e 7374616c 6c65640a ld be installed.\n- 0x01149d20 696e746f 20746865 20646972 6563746f into the directo\n- 0x01149d30 7279206f 6620616e 79207072 6f6a6563 ry of any projec\n- 0x01149d40 74207468 61742075 73657320 69742e20 t that uses it. \n- 0x01149d50 20486572 65277320 616e2065 78616d70 Here's an examp\n- 0x01149d60 6c65206f 66207768 61742061 0a736e61 le of what a.sna\n- 0x01149d70 706c6574 2066696c 65737973 74656d20 plet filesystem \n- 0x01149d80 6c61796f 7574206d 69676874 206c6f6f layout might loo\n- 0x01149d90 6b206c69 6b653a0a 0a202020 20666f6f k like:.. foo\n- 0x01149da0 736e6170 6c65742f 0a202020 2020207c snaplet/. |\n- 0x01149db0 2d2d202a 64657665 6c2e6366 672a0a20 -- *devel.cfg*. \n- 0x01149dc0 20202020 207c2d2d 2064622e 6366670a |-- db.cfg.\n- 0x01149dd0 20202020 20207c2d 2d207075 626c6963 |-- public\n- 0x01149de0 2f0a2020 20202020 20202020 7c2d2d20 /. |-- \n- 0x01149df0 7374796c 65736865 6574732f 0a202020 stylesheets/. \n- 0x01149e00 20202020 2020207c 2d2d2069 6d616765 |-- image\n- 0x01149e10 732f0a20 20202020 20202020 207c2d2d s/. |--\n- 0x01149e20 206a732f 0a202020 2020207c 2d2d202a js/. |-- *\n- 0x01149e30 736e6170 6c657473 2f2a0a20 20202020 snaplets/*. \n- 0x01149e40 20202020 207c2d2d 202a6865 6973742f |-- *heist/\n- 0x01149e50 2a0a2020 20202020 20202020 20202020 *. \n- 0x01149e60 7c2d2d20 74656d70 6c617465 732f0a20 |-- templates/. \n- 0x01149e70 20202020 20202020 207c2d2d 20737562 |-- sub\n- 0x01149e80 736e6170 6c657431 2f0a2020 20202020 snaplet1/. \n- 0x01149e90 20202020 7c2d2d20 73756273 6e61706c |-- subsnapl\n- 0x01149ea0 6574322f 0a0a4f6e 6c792074 68652073 et2/..Only the s\n- 0x01149eb0 74617272 65642069 74656d73 20617265 tarred items are\n- 0x01149ec0 20616374 75616c6c 7920656e 666f7263 actually enforc\n- 0x01149ed0 65642062 79206375 7272656e 7420636f ed by current co\n- 0x01149ee0 64652c20 62757420 77652077 616e7420 de, but we want \n- 0x01149ef0 746f0a65 73746162 6c697368 20746865 to.establish the\n- 0x01149f00 206f7468 65727320 61732061 20636f6e others as a con\n- 0x01149f10 76656e74 696f6e2e 20205468 65206669 vention. The fi\n- 0x01149f20 6c652064 6576656c 2e636667 20697320 le devel.cfg is \n- 0x01149f30 6175746f 6d617469 63616c6c 790a7265 automatically.re\n- 0x01149f40 61642062 79207468 6520736e 61706c65 ad by the snaple\n- 0x01149f50 7420696e 66726173 74727563 74757265 t infrastructure\n- 0x01149f60 2e202049 74206973 20617661 696c6162 . It is availab\n- 0x01149f70 6c652074 6f20796f 75207669 61207468 le to you via th\n- 0x01149f80 650a6067 6574536e 61706c65 74557365 e.`getSnapletUse\n- 0x01149f90 72436f6e 66696760 2066756e 6374696f rConfig` functio\n- 0x01149fa0 6e2e2020 436f6e66 69672066 696c6573 n. Config files\n- 0x01149fb0 20757365 20746865 20666f72 6d617420 use the format \n- 0x01149fc0 64656669 6e656420 62792042 7279616e defined by Bryan\n- 0x01149fd0 0a4f2753 756c6c69 76616e27 73206578 .O'Sullivan's ex\n- 0x01149fe0 63656c6c 656e7420 5b636f6e 66696775 cellent [configu\n- 0x01149ff0 7261746f 720a7061 636b6167 655d2868 rator.package](h\n- 0x0114a000 7474703a 2f2f6861 636b6167 652e6861 ttp://hackage.ha\n- 0x0114a010 736b656c 6c2e6f72 672f7061 636b6167 skell.org/packag\n- 0x0114a020 652f636f 6e666967 75726174 6f72292e e/configurator).\n- 0x0114a030 2020496e 20746869 73206578 616d706c In this exampl\n- 0x0114a040 652c0a74 68652075 73657220 68617320 e,.the user has \n- 0x0114a050 63686f73 656e2074 6f207075 74206462 chosen to put db\n- 0x0114a060 20636f6e 66696720 6974656d 7320696e config items in\n- 0x0114a070 20612073 65706172 61746520 66696c65 a separate file\n- 0x0114a080 20616e64 20757365 0a636f6e 66696775 and use.configu\n- 0x0114a090 7261746f 72277320 696d706f 72742066 rator's import f\n- 0x0114a0a0 756e6374 696f6e61 6c697479 20746f20 unctionality to \n- 0x0114a0b0 696e636c 75646520 69742069 6e206465 include it in de\n- 0x0114a0c0 76656c2e 6366672e 20204966 0a666f6f vel.cfg. If.foo\n- 0x0114a0d0 736e6170 6c657420 75736573 20606e65 snaplet uses `ne\n- 0x0114a0e0 7374536e 61706c65 7460206f 72206065 stSnaplet` or `e\n- 0x0114a0f0 6d626564 536e6170 6c657460 20746f20 mbedSnaplet` to \n- 0x0114a100 696e636c 75646520 616e7920 6f746865 include any othe\n- 0x0114a110 7220736e 61706c65 74732c0a 7468656e r snaplets,.then\n- 0x0114a120 2066696c 65737973 74656d20 64617461 filesystem data\n- 0x0114a130 20646566 696e6564 20627920 74686f73 defined by thos\n- 0x0114a140 6520736e 61706c65 74732077 696c6c20 e snaplets will \n- 0x0114a150 62652069 6e636c75 64656420 696e0a73 be included in.s\n- 0x0114a160 75626469 72656374 6f726965 7320756e ubdirectories un\n- 0x0114a170 64657220 74686520 60736e61 706c6574 der the `snaplet\n- 0x0114a180 732f6020 64697265 63746f72 792e0a0a s/` directory...\n- 0x0114a190 536f2068 6f772064 6f20796f 75207465 So how do you te\n- 0x0114a1a0 6c6c2074 68652073 6e61706c 65742069 ll the snaplet i\n- 0x0114a1b0 6e667261 73747275 63747572 65207468 nfrastructure th\n- 0x0114a1c0 61742079 6f757220 736e6170 6c657420 at your snaplet \n- 0x0114a1d0 68617320 66696c65 73797374 656d0a64 has filesystem.d\n- 0x0114a1e0 61746120 74686174 2073686f 756c6420 ata that should \n- 0x0114a1f0 62652069 6e737461 6c6c6564 3f20204c be installed? L\n- 0x0114a200 6f6f6b20 61742074 68652064 6566696e ook at the defin\n- 0x0114a210 6974696f 6e206f66 20617070 496e6974 ition of appInit\n- 0x0114a220 2061626f 76652e20 20546865 0a746869 above. The.thi\n- 0x0114a230 72642061 7267756d 656e7420 746f2074 rd argument to t\n- 0x0114a240 6865206d 616b6553 6e61706c 65742066 he makeSnaplet f\n- 0x0114a250 756e6374 696f6e20 69732077 68657265 unction is where\n- 0x0114a260 20776520 73706563 69667920 74686520 we specify the \n- 0x0114a270 66696c65 73797374 656d0a64 69726563 filesystem.direc\n- 0x0114a280 746f7279 20746861 74207368 6f756c64 tory that should\n- 0x0114a290 20626520 696e7374 616c6c65 642e2020 be installed. \n- 0x0114a2a0 54686174 20617267 756d656e 74206861 That argument ha\n- 0x0114a2b0 73207468 65207479 70652060 4d617962 s the type `Mayb\n- 0x0114a2c0 65202849 4f0a4669 6c655061 74682960 e (IO.FilePath)`\n- 0x0114a2d0 2e202049 6e207468 69732063 61736520 . In this case \n- 0x0114a2e0 77652075 73656420 604e6f74 68696e67 we used `Nothing\n- 0x0114a2f0 60206265 63617573 65206f75 72207369 ` because our si\n- 0x0114a300 6d706c65 20657861 6d706c65 20646f65 mple example doe\n- 0x0114a310 736e2774 0a686176 6520616e 79206669 sn't.have any fi\n- 0x0114a320 6c657379 7374656d 20646174 612e2020 lesystem data. \n- 0x0114a330 41732061 6e206578 616d706c 652c206c As an example, l\n- 0x0114a340 65742773 20736179 20796f75 20617265 et's say you are\n- 0x0114a350 20637265 6174696e 67206120 736e6170 creating a snap\n- 0x0114a360 6c65740a 63616c6c 6564206b 696c6c65 let.called kille\n- 0x0114a370 72617070 20746861 74207769 6c6c2062 rapp that will b\n- 0x0114a380 65206469 73747269 62757465 64206173 e distributed as\n- 0x0114a390 20612068 61636b61 67652070 726f6a65 a hackage proje\n- 0x0114a3a0 63742063 616c6c65 640a736e 61706c65 ct called.snaple\n- 0x0114a3b0 742d6b69 6c6c6572 6170702e 2020596f t-killerapp. Yo\n- 0x0114a3c0 75722070 726f6a65 63742064 69726563 ur project direc\n- 0x0114a3d0 746f7279 20737472 75637475 72652077 tory structure w\n- 0x0114a3e0 696c6c20 6c6f6f6b 20736f6d 65746869 ill look somethi\n- 0x0114a3f0 6e67206c 696b650a 74686973 3a0a0a20 ng like.this:.. \n- 0x0114a400 20202073 6e61706c 65742d6b 696c6c65 snaplet-kille\n- 0x0114a410 72617070 2f0a2020 20202020 7c2d2d20 rapp/. |-- \n- 0x0114a420 7265736f 75726365 732f0a20 20202020 resources/. \n- 0x0114a430 207c2d2d 20736e61 706c6574 2d6b696c |-- snaplet-kil\n- 0x0114a440 6c657261 70702e63 6162616c 0a202020 lerapp.cabal. \n- 0x0114a450 2020207c 2d2d2073 72632f0a 0a416c6c |-- src/..All\n- 0x0114a460 206f6620 74686520 66696c65 7320616e of the files an\n- 0x0114a470 64206469 72656374 6f726965 73206c69 d directories li\n- 0x0114a480 73746564 2061626f 76652075 6e646572 sted above under\n- 0x0114a490 20666f6f 736e6170 6c65742f 2077696c foosnaplet/ wil\n- 0x0114a4a0 6c206265 20696e0a 7265736f 75726365 l be in.resource\n- 0x0114a4b0 732f2e20 20536f6d 65776865 72652069 s/. Somewhere i\n- 0x0114a4c0 6e207468 6520636f 64652079 6f752077 n the code you w\n- 0x0114a4d0 696c6c20 64656669 6e652061 6e20696e ill define an in\n- 0x0114a4e0 69746961 6c697a65 7220666f 72207468 itializer for th\n- 0x0114a4f0 650a736e 61706c65 74207468 61742077 e.snaplet that w\n- 0x0114a500 696c6c20 6c6f6f6b 206c696b 65207468 ill look like th\n- 0x0114a510 69733a0a 0a202020 206b696c 6c657249 is:.. killerI\n- 0x0114a520 6e697420 3d206d61 6b65536e 61706c65 nit = makeSnaple\n- 0x0114a530 7420226b 696c6c65 72617070 22202234 t \"killerapp\" \"4\n- 0x0114a540 32222028 4a757374 20646174 61446972 2\" (Just dataDir\n- 0x0114a550 29202420 646f0a0a 54686520 7072696d ) $ do..The prim\n- 0x0114a560 61727920 66756e63 74696f6e 206f6620 ary function of \n- 0x0114a570 43616261 6c206973 20746f20 696e7374 Cabal is to inst\n- 0x0114a580 616c6c20 636f6465 2e202042 75742069 all code. But i\n- 0x0114a590 74206861 73207468 65206162 696c6974 t has the abilit\n- 0x0114a5a0 7920746f 0a696e73 74616c6c 20646174 y to.install dat\n- 0x0114a5b0 61206669 6c657320 616e6420 70726f76 a files and prov\n- 0x0114a5c0 69646573 20612066 756e6374 696f6e20 ides a function \n- 0x0114a5d0 63616c6c 65642060 67657444 61746144 called `getDataD\n- 0x0114a5e0 69726020 666f7220 72657472 69657669 ir` for retrievi\n- 0x0114a5f0 6e670a74 6865206c 6f636174 696f6e20 ng.the location \n- 0x0114a600 6f662074 68657365 2066696c 65732e20 of these files. \n- 0x0114a610 2053696e 63652069 74207265 7475726e Since it return\n- 0x0114a620 73206120 64696666 6572656e 74207265 s a different re\n- 0x0114a630 73756c74 20646570 656e6469 6e67206f sult depending o\n- 0x0114a640 6e0a7768 6174206d 61636869 6e652079 n.what machine y\n- 0x0114a650 6f752772 65207573 696e672c 20746865 ou're using, the\n- 0x0114a660 20746869 72642061 7267756d 656e7420 third argument \n- 0x0114a670 746f2060 6d616b65 536e6170 6c657460 to `makeSnaplet`\n- 0x0114a680 20686173 20746f20 62652060 4d617962 has to be `Mayb\n- 0x0114a690 650a2849 4f204669 6c655061 74682960 e.(IO FilePath)`\n- 0x0114a6a0 20696e73 74656164 206f6620 74686520 instead of the \n- 0x0114a6b0 6d6f7265 206e6174 7572616c 20707572 more natural pur\n- 0x0114a6c0 65207665 7273696f 6e2e2020 546f206d e version. To m\n- 0x0114a6d0 616b6520 7468696e 6773206d 6f72650a ake things more.\n- 0x0114a6e0 6f726761 6e697a65 642c2077 65207573 organized, we us\n- 0x0114a6f0 65207468 6520636f 6e76656e 74696f6e e the convention\n- 0x0114a700 206f6620 70757474 696e6720 616c6c20 of putting all \n- 0x0114a710 796f7572 20736e61 706c6574 27732064 your snaplet's d\n- 0x0114a720 61746120 66696c65 7320696e 20610a73 ata files in a.s\n- 0x0114a730 75626469 72656374 6f727920 63616c6c ubdirectory call\n- 0x0114a740 65642072 65736f75 72636573 2e202053 ed resources. S\n- 0x0114a750 6f207765 206e6565 6420746f 20637265 o we need to cre\n- 0x0114a760 61746520 6120736d 616c6c20 66756e63 ate a small func\n- 0x0114a770 74696f6e 20746861 740a6170 70656e64 tion that.append\n- 0x0114a780 7320602f 7265736f 75726365 73602074 s `/resources` t\n- 0x0114a790 6f207468 65207265 73756c74 206f6620 o the result of \n- 0x0114a7a0 60676574 44617461 44697260 2e0a0a20 `getDataDir`... \n- 0x0114a7b0 20202069 6d706f72 74205061 7468735f import Paths_\n- 0x0114a7c0 736e6170 6c65745f 6b696c6c 65726170 snaplet_killerap\n- 0x0114a7d0 700a2020 20206461 74614469 72203d20 p. dataDir = \n- 0x0114a7e0 6c696674 4d20282b 2b222f72 65736f75 liftM (++\"/resou\n- 0x0114a7f0 72636573 22292067 65744461 74614469 rces\") getDataDi\n- 0x0114a800 720a0a49 66206f75 72207072 6f6a6563 r..If our projec\n- 0x0114a810 74206973 206e616d 65642073 6e61706c t is named snapl\n- 0x0114a820 65742d6b 696c6c65 72617070 2c207468 et-killerapp, th\n- 0x0114a830 65206067 65744461 74614469 72602066 e `getDataDir` f\n- 0x0114a840 756e6374 696f6e20 69730a64 6566696e unction is.defin\n- 0x0114a850 65642069 6e207468 65206d6f 64756c65 ed in the module\n- 0x0114a860 20506174 68735f73 6e61706c 65745f6b Paths_snaplet_k\n- 0x0114a870 696c6c65 72617070 2c207768 69636820 illerapp, which \n- 0x0114a880 77652068 61766520 746f2069 6d706f72 we have to impor\n- 0x0114a890 742e2020 546f0a6d 616b6520 65766572 t. To.make ever\n- 0x0114a8a0 79746869 6e672077 6f726b2c 20796f75 ything work, you\n- 0x0114a8b0 20686176 6520746f 2074656c 6c204361 have to tell Ca\n- 0x0114a8c0 62616c20 61626f75 7420796f 75722064 bal about your d\n- 0x0114a8d0 61746120 66696c65 73206279 0a696e63 ata files by.inc\n- 0x0114a8e0 6c756469 6e672061 20736563 74696f6e luding a section\n- 0x0114a8f0 206c696b 65207468 6520666f 6c6c6f77 like the follow\n- 0x0114a900 696e6720 696e2073 6e61706c 65742d6b ing in snaplet-k\n- 0x0114a910 696c6c65 72617070 2e636162 616c3a0a illerapp.cabal:.\n- 0x0114a920 0a202020 20646174 612d6669 6c65733a . data-files:\n- 0x0114a930 0a202020 20202072 65736f75 72636573 . resources\n- 0x0114a940 2f646576 656c2e63 66672c0a 20202020 /devel.cfg,. \n- 0x0114a950 20207265 736f7572 6365732f 7075626c resources/publ\n- 0x0114a960 69632f73 74796c65 73686565 74732f73 ic/stylesheets/s\n- 0x0114a970 74796c65 2e637373 2c0a2020 20202020 tyle.css,. \n- 0x0114a980 7265736f 75726365 732f736e 61706c65 resources/snaple\n- 0x0114a990 74732f68 65697374 2f74656d 706c6174 ts/heist/templat\n- 0x0114a9a0 65732f70 6167652e 74706c0a 0a4e6f77 es/page.tpl..Now\n- 0x0114a9b0 20776865 6e657665 7220796f 75722073 whenever your s\n- 0x0114a9c0 6e61706c 65742069 73207573 65642c20 naplet is used, \n- 0x0114a9d0 69747320 66696c65 73797374 656d2064 its filesystem d\n- 0x0114a9e0 61746120 77696c6c 20626520 6175746f ata will be auto\n- 0x0114a9f0 6d616769 63616c6c 790a636f 70696564 magically.copied\n- 0x0114aa00 20696e74 6f207468 65206c6f 63616c20 into the local \n- 0x0114aa10 70726f6a 65637420 74686174 20697320 project that is \n- 0x0114aa20 7573696e 67206974 2c207768 656e6576 using it, whenev\n- 0x0114aa30 65722074 68652061 70706c69 63617469 er the applicati\n- 0x0114aa40 6f6e2069 730a7275 6e20616e 64206974 on is.run and it\n- 0x0114aa50 20736565 73207468 61742074 68652073 sees that the s\n- 0x0114aa60 6e61706c 65742773 20646972 6563746f naplet's directo\n- 0x0114aa70 72792064 6f657320 6e6f7420 616c7265 ry does not alre\n- 0x0114aa80 61647920 65786973 742e2020 49662074 ady exist. If t\n- 0x0114aa90 68650a75 73657220 75706772 61646573 he.user upgrades\n- 0x0114aaa0 20746f20 61206e65 77207665 7273696f to a new versio\n- 0x0114aab0 6e206f66 20746865 20736e61 706c6574 n of the snaplet\n- 0x0114aac0 20616e64 20746865 206e6577 20766572 and the new ver\n- 0x0114aad0 73696f6e 206d6164 65206368 616e6765 sion made change\n- 0x0114aae0 730a746f 20746865 2066696c 65737973 s.to the filesys\n- 0x0114aaf0 74656d20 7265736f 75726365 732c2074 tem resources, t\n- 0x0114ab00 686f7365 20726573 6f757263 65732077 hose resources w\n- 0x0114ab10 696c6c20 4e4f5420 62652061 75746f6d ill NOT be autom\n- 0x0114ab20 61746963 616c6c79 20636f70 6965640a atically copied.\n- 0x0114ab30 696e2062 79206465 6661756c 742e2020 in by default. \n- 0x0114ab40 5265736f 75726365 20696e73 74616c6c Resource install\n- 0x0114ab50 6174696f 6e202a6f 6e6c792a 20686170 ation *only* hap\n- 0x0114ab60 70656e73 20776865 6e207468 65206073 pens when the `s\n- 0x0114ab70 6e61706c 6574732f 666f6f60 0a646972 naplets/foo`.dir\n- 0x0114ab80 6563746f 72792064 6f657320 6e6f7420 ectory does not \n- 0x0114ab90 65786973 742e2020 49662079 6f752077 exist. If you w\n- 0x0114aba0 616e7420 746f2067 65742074 6865206c ant to get the l\n- 0x0114abb0 61746573 74207665 7273696f 6e206f66 atest version of\n- 0x0114abc0 20746865 0a66696c 65737973 74656d20 the.filesystem \n- 0x0114abd0 7265736f 75726365 732c2072 656d6f76 resources, remov\n- 0x0114abe0 65207468 65206073 6e61706c 6574732f e the `snaplets/\n- 0x0114abf0 666f6f60 20646972 6563746f 72792c20 foo` directory, \n- 0x0114ac00 616e6420 72657374 61727420 796f7572 and restart your\n- 0x0114ac10 0a617070 2e0a002e 2f737263 2f547574 .app..../src/Tut\n- 0x0114ac20 6f726961 6c2e6c68 73004e61 6d653a20 orial.lhs.Name: \n+ 0x01146760 6b737461 72746572 00576861 74204172 kstarter.What Ar\n+ 0x01146770 6520536e 61706c65 74733f0a 3d3d3d3d e Snaplets?.====\n+ 0x01146780 3d3d3d3d 3d3d3d3d 3d3d3d3d 3d3d0a0a ==============..\n+ 0x01146790 4120736e 61706c65 74206973 20612063 A snaplet is a c\n+ 0x011467a0 6f6d706f 7361626c 65207765 62206170 omposable web ap\n+ 0x011467b0 706c6963 6174696f 6e2e2020 536e6170 plication. Snap\n+ 0x011467c0 6c657473 20616c6c 6f772079 6f752074 lets allow you t\n+ 0x011467d0 6f206275 696c640a 73656c66 2d636f6e o build.self-con\n+ 0x011467e0 7461696e 65642070 69656365 73206f66 tained pieces of\n+ 0x011467f0 2066756e 6374696f 6e616c69 74792061 functionality a\n+ 0x01146800 6e642067 6c756520 7468656d 20746f67 nd glue them tog\n+ 0x01146810 65746865 7220746f 206d616b 65206c61 ether to make la\n+ 0x01146820 72676572 0a617070 6c696361 74696f6e rger.application\n+ 0x01146830 732e2020 48657265 20617265 20736f6d s. Here are som\n+ 0x01146840 65206f66 20746865 20746869 6e677320 e of the things \n+ 0x01146850 70726f76 69646564 20627920 74686520 provided by the \n+ 0x01146860 736e6170 6c657420 4150493a 0a0a2020 snaplet API:.. \n+ 0x01146870 2d20496e 66726173 74727563 74757265 - Infrastructure\n+ 0x01146880 20666f72 20617070 6c696361 74696f6e for application\n+ 0x01146890 20737461 74652f65 6e766972 6f6e6d65 state/environme\n+ 0x011468a0 6e740a0a 20202d20 536e6170 6c657420 nt.. - Snaplet \n+ 0x011468b0 696e6974 69616c69 7a617469 6f6e2c20 initialization, \n+ 0x011468c0 72656c6f 61642c20 616e6420 636c6561 reload, and clea\n+ 0x011468d0 6e75700a 0a20202d 204d616e 6167656d nup.. - Managem\n+ 0x011468e0 656e7420 6f662066 696c6573 79737465 ent of filesyste\n+ 0x011468f0 6d206461 74612061 6e642061 75746f6d m data and autom\n+ 0x01146900 61746963 20736e61 706c6574 20696e73 atic snaplet ins\n+ 0x01146910 74616c6c 6174696f 6e0a0a20 202d2055 tallation.. - U\n+ 0x01146920 6e696669 65642063 6f6e6669 67206669 nified config fi\n+ 0x01146930 6c652069 6e667261 73747275 63747572 le infrastructur\n+ 0x01146940 650a0a4f 6e652065 78616d70 6c65206d e..One example m\n+ 0x01146950 69676874 20626520 61207769 6b692073 ight be a wiki s\n+ 0x01146960 6e61706c 65742e20 20497420 776f756c naplet. It woul\n+ 0x01146970 64206265 20646973 74726962 75746564 d be distributed\n+ 0x01146980 20617320 61206861 736b656c 6c0a7061 as a haskell.pa\n+ 0x01146990 636b6167 65207468 61742077 6f756c64 ckage that would\n+ 0x011469a0 20626520 696e7374 616c6c65 64207769 be installed wi\n+ 0x011469b0 74682063 6162616c 20616e64 20776f75 th cabal and wou\n+ 0x011469c0 6c642070 726f6261 626c7920 696e636c ld probably incl\n+ 0x011469d0 75646520 636f6465 2c0a636f 6e666967 ude code,.config\n+ 0x011469e0 2066696c 65732c20 48544d4c 2074656d files, HTML tem\n+ 0x011469f0 706c6174 65732c20 7374796c 65736865 plates, styleshe\n+ 0x01146a00 6574732c 204a6176 61536372 6970742c ets, JavaScript,\n+ 0x01146a10 20696d61 6765732c 20657463 2e202054 images, etc. T\n+ 0x01146a20 68650a73 6e61706c 65742773 20636f64 he.snaplet's cod\n+ 0x01146a30 6520776f 756c6420 70726f76 69646520 e would provide \n+ 0x01146a40 74686520 6e656365 73736172 79204150 the necessary AP\n+ 0x01146a50 4920746f 206c6574 20796f75 72206170 I to let your ap\n+ 0x01146a60 706c6963 6174696f 6e0a696e 74657261 plication.intera\n+ 0x01146a70 63742073 65616d6c 6573736c 79207769 ct seamlessly wi\n+ 0x01146a80 74682074 68652077 696b6920 66756e63 th the wiki func\n+ 0x01146a90 74696f6e 616c6974 792e2020 5768656e tionality. When\n+ 0x01146aa0 20796f75 2072756e 20796f75 720a6170 you run your.ap\n+ 0x01146ab0 706c6963 6174696f 6e20666f 72207468 plication for th\n+ 0x01146ac0 65206669 72737420 74696d65 2c20616c e first time, al\n+ 0x01146ad0 6c206f66 20746865 2077696b 6920736e l of the wiki sn\n+ 0x01146ae0 61706c65 74277320 66696c65 73797374 aplet's filesyst\n+ 0x01146af0 656d2072 65736f75 72636573 0a77696c em resources.wil\n+ 0x01146b00 6c206175 746f6d61 74696361 6c6c7920 l automatically \n+ 0x01146b10 62652063 6f706965 6420696e 746f2074 be copied into t\n+ 0x01146b20 68652061 7070726f 70726961 74652070 he appropriate p\n+ 0x01146b30 6c616365 732e2020 5468656e 20796f75 laces. Then you\n+ 0x01146b40 2077696c 6c0a696d 6d656469 6174656c will.immediatel\n+ 0x01146b50 79206265 2061626c 6520746f 20637573 y be able to cus\n+ 0x01146b60 746f6d69 7a652074 68652077 696b6920 tomize the wiki \n+ 0x01146b70 746f2066 69742079 6f757220 6e656564 to fit your need\n+ 0x01146b80 73206279 20656469 74696e67 20636f6e s by editing con\n+ 0x01146b90 6669670a 66696c65 732c2070 726f7669 fig.files, provi\n+ 0x01146ba0 64696e67 20796f75 72206f77 6e207374 ding your own st\n+ 0x01146bb0 796c6573 68656574 732c2065 74632e20 ylesheets, etc. \n+ 0x01146bc0 20576520 77696c6c 20646973 63757373 We will discuss\n+ 0x01146bd0 20746869 7320696e 206d6f72 650a6465 this in more.de\n+ 0x01146be0 7461696c 206c6174 65722e0a 0a412073 tail later...A s\n+ 0x01146bf0 6e61706c 65742063 616e2072 65707265 naplet can repre\n+ 0x01146c00 73656e74 20616e79 7468696e 67206672 sent anything fr\n+ 0x01146c10 6f6d2062 61636b65 6e642048 61736b65 om backend Haske\n+ 0x01146c20 6c6c2069 6e667261 73747275 63747572 ll infrastructur\n+ 0x01146c30 65207769 7468206e 6f0a7573 65722066 e with no.user f\n+ 0x01146c40 6163696e 67206675 6e637469 6f6e616c acing functional\n+ 0x01146c50 69747920 746f2061 20736d61 6c6c2077 ity to a small w\n+ 0x01146c60 69646765 74206c69 6b652061 20636861 idget like a cha\n+ 0x01146c70 7420626f 78207468 61742067 6f657320 t box that goes \n+ 0x01146c80 696e2074 68650a63 6f726e65 72206f66 in the.corner of\n+ 0x01146c90 20612077 65622070 61676520 746f2061 a web page to a\n+ 0x01146ca0 6e20656e 74697265 20737461 6e64616c n entire standal\n+ 0x01146cb0 6f6e6520 77656273 69746520 6c696b65 one website like\n+ 0x01146cc0 20612062 6c6f6720 6f722066 6f72756d a blog or forum\n+ 0x01146cd0 2e0a5468 6520706f 73736962 696c6974 ..The possibilit\n+ 0x01146ce0 69657320 61726520 656e646c 6573732e ies are endless.\n+ 0x01146cf0 20204120 736e6170 6c657420 69732061 A snaplet is a\n+ 0x01146d00 20776562 20617070 6c696361 74696f6e web application\n+ 0x01146d10 2c20616e 64207765 620a6170 706c6963 , and web.applic\n+ 0x01146d20 6174696f 6e732061 72652073 6e61706c ations are snapl\n+ 0x01146d30 6574732e 20205468 6973206d 65616e73 ets. This means\n+ 0x01146d40 20746861 74207573 696e6720 736e6170 that using snap\n+ 0x01146d50 6c657473 20616e64 20777269 74696e67 lets and writing\n+ 0x01146d60 0a736e61 706c6574 73206172 6520616c .snaplets are al\n+ 0x01146d70 6d6f7374 20746865 2073616d 65207468 most the same th\n+ 0x01146d80 696e672c 20616e64 20697427 73207472 ing, and it's tr\n+ 0x01146d90 69766961 6c20746f 2064726f 70206120 ivial to drop a \n+ 0x01146da0 77686f6c 65207765 62736974 650a696e whole website.in\n+ 0x01146db0 746f2061 6e6f7468 6572206f 6e652e0a to another one..\n+ 0x01146dc0 0a576527 72652072 65616c6c 79206578 .We're really ex\n+ 0x01146dd0 63697465 64206162 6f757420 74686520 cited about the \n+ 0x01146de0 706f7373 6962696c 69746965 73206176 possibilities av\n+ 0x01146df0 61696c61 626c6520 77697468 20736e61 ailable with sna\n+ 0x01146e00 706c6574 732e2020 496e0a66 6163742c plets. In.fact,\n+ 0x01146e10 20536e61 7020616c 72656164 79207368 Snap already sh\n+ 0x01146e20 69707320 77697468 20736e61 706c6574 ips with snaplet\n+ 0x01146e30 7320666f 72207365 7373696f 6e732c20 s for sessions, \n+ 0x01146e40 61757468 656e7469 63617469 6f6e2c20 authentication, \n+ 0x01146e50 616e640a 74656d70 6c617469 6e672028 and.templating (\n+ 0x01146e60 77697468 20486569 7374292c 20205468 with Heist), Th\n+ 0x01146e70 69732067 69766573 20796f75 20757365 is gives you use\n+ 0x01146e80 66756c20 66756e63 74696f6e 616c6974 ful functionalit\n+ 0x01146e90 79206f75 74206f66 20746865 20626f78 y out of the box\n+ 0x01146ea0 2c0a616e 64206a75 6d702073 74617274 ,.and jump start\n+ 0x01146eb0 7320796f 7572206f 776e2073 6e61706c s your own snapl\n+ 0x01146ec0 65742064 6576656c 6f706d65 6e742062 et development b\n+ 0x01146ed0 79206465 6d6f6e73 74726174 696e6720 y demonstrating \n+ 0x01146ee0 736f6d65 20757365 66756c0a 64657369 some useful.desi\n+ 0x01146ef0 676e2070 61747465 726e732e 2020536f gn patterns. So\n+ 0x01146f00 20776974 686f7574 20667572 74686572 without further\n+ 0x01146f10 2061646f 2c206c65 74277320 67657420 ado, let's get \n+ 0x01146f20 73746172 7465642e 0a0a536e 61706c65 started...Snaple\n+ 0x01146f30 74204f76 65727669 65770a3d 3d3d3d3d t Overview.=====\n+ 0x01146f40 3d3d3d3d 3d3d3d3d 3d3d3d0a 0a546865 ===========..The\n+ 0x01146f50 20686561 7274206f 66207468 6520736e heart of the sn\n+ 0x01146f60 61706c65 74732069 6e667261 73747275 aplets infrastru\n+ 0x01146f70 63747572 65206973 20737461 7465206d cture is state m\n+ 0x01146f80 616e6167 656d656e 742e2020 4d6f7374 anagement. Most\n+ 0x01146f90 206e6f6e 74726976 69616c0a 70696563 nontrivial.piec\n+ 0x01146fa0 6573206f 66206120 77656220 61707020 es of a web app \n+ 0x01146fb0 6e656564 20736f6d 65206b69 6e64206f need some kind o\n+ 0x01146fc0 66207374 61746520 6f722065 6e766972 f state or envir\n+ 0x01146fd0 6f6e6d65 6e742064 6174612e 2020436f onment data. Co\n+ 0x01146fe0 6d706f6e 656e7473 0a746861 7420646f mponents.that do\n+ 0x01146ff0 206e6f74 206e6565 6420616e 79206b69 not need any ki\n+ 0x01147000 6e64206f 66207374 61746520 6f722065 nd of state or e\n+ 0x01147010 6e766972 6f6e6d65 6e742061 72652070 nvironment are p\n+ 0x01147020 726f6261 626c7920 6d6f7265 0a617070 robably more.app\n+ 0x01147030 726f7072 69617465 20617320 61207374 ropriate as a st\n+ 0x01147040 616e6461 6c6f6e65 206c6962 72617279 andalone library\n+ 0x01147050 20746861 6e206173 20612073 6e61706c than as a snapl\n+ 0x01147060 65742e0a 0a426566 6f726520 77652063 et...Before we c\n+ 0x01147070 6f6e7469 6e75652c 20776520 6d757374 ontinue, we must\n+ 0x01147080 20636c61 72696679 20616e20 696d706f clarify an impo\n+ 0x01147090 7274616e 7420706f 696e742e 20205468 rtant point. Th\n+ 0x011470a0 6520536e 61702077 65622073 65727665 e Snap web serve\n+ 0x011470b0 720a7072 6f636573 73657320 65616368 r.processes each\n+ 0x011470c0 20726571 75657374 20696e20 69747320 request in its \n+ 0x011470d0 6f776e20 67726565 6e207468 72656164 own green thread\n+ 0x011470e0 2e202054 68697320 6d65616e 73207468 . This means th\n+ 0x011470f0 61742065 61636820 72657175 6573740a at each request.\n+ 0x01147100 77696c6c 20726563 65697665 20612073 will receive a s\n+ 0x01147110 65706172 61746520 636f7079 206f6620 eparate copy of \n+ 0x01147120 74686520 73746174 65206465 66696e65 the state define\n+ 0x01147130 64206279 20796f75 72206170 706c6963 d by your applic\n+ 0x01147140 6174696f 6e20616e 640a736e 61706c65 ation and.snaple\n+ 0x01147150 74732c20 616e6420 6d6f6469 66696361 ts, and modifica\n+ 0x01147160 74696f6e 7320746f 20746861 74207374 tions to that st\n+ 0x01147170 61746520 6f6e6c79 20616666 65637420 ate only affect \n+ 0x01147180 74686520 6c6f6361 6c207468 72656164 the local thread\n+ 0x01147190 20746861 740a6765 6e657261 74657320 that.generates \n+ 0x011471a0 61207369 6e676c65 20726573 706f6e73 a single respons\n+ 0x011471b0 652e2020 46726f6d 206e6f77 206f6e2c e. From now on,\n+ 0x011471c0 20776865 6e207765 2074616c 6b206162 when we talk ab\n+ 0x011471d0 6f757420 73746174 65207468 69732069 out state this i\n+ 0x011471e0 730a7768 61742077 65206172 65207461 s.what we are ta\n+ 0x011471f0 6c6b696e 67206162 6f75742e 20204966 lking about. If\n+ 0x01147200 20796f75 206e6565 6420676c 6f62616c you need global\n+ 0x01147210 20617070 6c696361 74696f6e 20737461 application sta\n+ 0x01147220 74652c20 796f7520 68617665 20746f0a te, you have to.\n+ 0x01147230 75736520 61207468 72656164 2d736166 use a thread-saf\n+ 0x01147240 6520636f 6e737472 75637420 73756368 e construct such\n+ 0x01147250 20617320 616e204d 56617220 6f722049 as an MVar or I\n+ 0x01147260 4f526566 2e0a0a54 68697320 706f7374 ORef...This post\n+ 0x01147270 20697320 77726974 74656e20 696e206c is written in l\n+ 0x01147280 69746572 61746520 4861736b 656c6c2e iterate Haskell.\n+ 0x01147290 20204974 20757365 73206120 736d616c It uses a smal\n+ 0x011472a0 6c206578 7465726e 616c206d 6f64756c l external modul\n+ 0x011472b0 650a6361 6c6c6564 20506172 74322074 e.called Part2 t\n+ 0x011472c0 68617420 6973205b 61766169 6c61626c hat is [availabl\n+ 0x011472d0 650a6865 72655d28 68747470 733a2f2f e.here](https://\n+ 0x011472e0 67697468 75622e63 6f6d2f73 6e617066 github.com/snapf\n+ 0x011472f0 72616d65 776f726b 2f736e61 702d7465 ramework/snap-te\n+ 0x01147300 6d706c61 7465732f 626c6f62 2f6d6173 mplates/blob/mas\n+ 0x01147310 7465722f 70726f6a 6563745f 74656d70 ter/project_temp\n+ 0x01147320 6c617465 2f747574 6f726961 6c2f7372 late/tutorial/sr\n+ 0x01147330 632f5061 7274322e 6c687329 2e0a596f c/Part2.lhs)..Yo\n+ 0x01147340 75206361 6e20616c 736f2069 6e737461 u can also insta\n+ 0x01147350 6c6c2074 68652066 756c6c20 636f6465 ll the full code\n+ 0x01147360 20696e20 74686520 63757272 656e7420 in the current \n+ 0x01147370 64697265 63746f72 79207769 74682074 directory with t\n+ 0x01147380 68652063 6f6d6d61 6e640a60 736e6170 he command.`snap\n+ 0x01147390 20696e69 74207475 746f7269 616c602e init tutorial`.\n+ 0x011473a0 20204669 72737420 7765206e 65656420 First we need \n+ 0x011473b0 746f2067 65742069 6d706f72 7473206f to get imports o\n+ 0x011473c0 7574206f 66207468 65207761 792e0a0a ut of the way...\n+ 0x011473d0 3e207b2d 23204c41 4e475541 47452054 > {-# LANGUAGE T\n+ 0x011473e0 656d706c 61746548 61736b65 6c6c2023 emplateHaskell #\n+ 0x011473f0 2d7d0a3e 207b2d23 204c414e 47554147 -}.> {-# LANGUAG\n+ 0x01147400 45204f76 65726c6f 61646564 53747269 E OverloadedStri\n+ 0x01147410 6e677320 232d7d0a 3e0a3e20 6d6f6475 ngs #-}.>.> modu\n+ 0x01147420 6c65204d 61696e20 77686572 650a3e0a le Main where.>.\n+ 0x01147430 3e20696d 706f7274 20202020 20202020 > import \n+ 0x01147440 20202043 6f6e7472 6f6c2e41 70706c69 Control.Appli\n+ 0x01147450 63617469 76652028 283c7c3e 29290a3e cative ((<|>)).>\n+ 0x01147460 20696d70 6f727420 20202020 20202020 import \n+ 0x01147470 2020436f 6e74726f 6c2e4c65 6e732e54 Control.Lens.T\n+ 0x01147480 480a3e20 696d706f 72742020 20202020 H.> import \n+ 0x01147490 20202020 20436f6e 74726f6c 2e4d6f6e Control.Mon\n+ 0x011474a0 61642e49 4f2e436c 61737320 286c6966 ad.IO.Class (lif\n+ 0x011474b0 74494f29 0a3e2069 6d706f72 74202020 tIO).> import \n+ 0x011474c0 20202020 20202020 436f6e74 726f6c2e Control.\n+ 0x011474d0 4d6f6e61 642e5374 6174652e 436c6173 Monad.State.Clas\n+ 0x011474e0 73202867 65747329 0a3e2069 6d706f72 s (gets).> impor\n+ 0x011474f0 74202020 20202020 20202020 44617461 t Data\n+ 0x01147500 2e494f52 65660a3e 20696d70 6f727420 .IORef.> import \n+ 0x01147510 7175616c 69666965 64204461 74612e42 qualified Data.B\n+ 0x01147520 79746553 7472696e 672e4368 61723820 yteString.Char8 \n+ 0x01147530 61732042 0a3e2069 6d706f72 74202020 as B.> import \n+ 0x01147540 20202020 20202020 44617461 2e4d6179 Data.May\n+ 0x01147550 62650a3e 20696d70 6f727420 20202020 be.> import \n+ 0x01147560 20202020 2020536e 61700a3e 20696d70 Snap.> imp\n+ 0x01147570 6f727420 20202020 20202020 2020536e ort Sn\n+ 0x01147580 61702e53 6e61706c 65742e48 65697374 ap.Snaplet.Heist\n+ 0x01147590 0a3e2069 6d706f72 74202020 20202020 .> import \n+ 0x011475a0 20202020 50617274 320a0a57 65207374 Part2..We st\n+ 0x011475b0 61727420 6f757220 6170706c 69636174 art our applicat\n+ 0x011475c0 696f6e20 62792064 6566696e 696e6720 ion by defining \n+ 0x011475d0 61206461 74612073 74727563 74757265 a data structure\n+ 0x011475e0 20746f20 686f6c64 20746865 20737461 to hold the sta\n+ 0x011475f0 74652e20 20546869 730a6461 74612073 te. This.data s\n+ 0x01147600 74727563 74757265 20696e63 6c756465 tructure include\n+ 0x01147610 73207468 65207374 61746520 6f662061 s the state of a\n+ 0x01147620 6c6c2073 6e61706c 65747320 28777261 ll snaplets (wra\n+ 0x01147630 70706564 20696e20 6120536e 61706c65 pped in a Snaple\n+ 0x01147640 74292075 7365640a 6279206f 75722061 t) used.by our a\n+ 0x01147650 70706c69 63617469 6f6e2061 73207765 pplication as we\n+ 0x01147660 6c6c2061 7320616e 79206f74 68657220 ll as any other \n+ 0x01147670 73746174 65207765 206d6967 68742077 state we might w\n+ 0x01147680 616e742e 0a0a3e20 64617461 20417070 ant...> data App\n+ 0x01147690 203d2041 70700a3e 20202020 207b205f = App.> { _\n+ 0x011476a0 68656973 74202020 20202020 3a3a2053 heist :: S\n+ 0x011476b0 6e61706c 65742028 48656973 74204170 naplet (Heist Ap\n+ 0x011476c0 70290a3e 20202020 202c205f 666f6f20 p).> , _foo \n+ 0x011476d0 20202020 20202020 3a3a2053 6e61706c :: Snapl\n+ 0x011476e0 65742046 6f6f0a3e 20202020 202c205f et Foo.> , _\n+ 0x011476f0 62617220 20202020 20202020 3a3a2053 bar :: S\n+ 0x01147700 6e61706c 65742042 61720a3e 20202020 naplet Bar.> \n+ 0x01147710 202c205f 636f6d70 616e794e 616d6520 , _companyName \n+ 0x01147720 3a3a2049 4f526566 20422e42 79746553 :: IORef B.ByteS\n+ 0x01147730 7472696e 670a3e20 20202020 7d0a3e0a tring.> }.>.\n+ 0x01147740 3e206d61 6b654c65 6e736573 20272741 > makeLenses ''A\n+ 0x01147750 70700a0a 54686520 6669656c 64206e61 pp..The field na\n+ 0x01147760 6d657320 62656769 6e207769 74682061 mes begin with a\n+ 0x01147770 6e20756e 64657273 636f7265 20626563 n underscore bec\n+ 0x01147780 61757365 206f6620 736f6d65 206d6f72 ause of some mor\n+ 0x01147790 6520636f 6d706c69 63617465 640a7468 e complicated.th\n+ 0x011477a0 696e6773 20676f69 6e67206f 6e20756e ings going on un\n+ 0x011477b0 64657220 74686520 686f6f64 2e202048 der the hood. H\n+ 0x011477c0 6f776576 65722c20 616c6c20 796f7520 owever, all you \n+ 0x011477d0 6e656564 20746f20 6b6e6f77 20726967 need to know rig\n+ 0x011477e0 6874206e 6f772069 730a7468 61742079 ht now is.that y\n+ 0x011477f0 6f752073 686f756c 64207072 65666978 ou should prefix\n+ 0x01147800 20746869 6e677320 77697468 20616e20 things with an \n+ 0x01147810 756e6465 7273636f 72652061 6e642074 underscore and t\n+ 0x01147820 68656e20 63616c6c 20606d61 6b654c65 hen call `makeLe\n+ 0x01147830 6e736573 602e0a54 68697320 6c657473 nses`..This lets\n+ 0x01147840 20796f75 20757365 20746865 206e616d you use the nam\n+ 0x01147850 65732077 6974686f 75742061 6e20756e es without an un\n+ 0x01147860 64657273 636f7265 20696e20 74686520 derscore in the \n+ 0x01147870 72657374 206f6620 796f7572 0a617070 rest of your.app\n+ 0x01147880 6c696361 74696f6e 2e0a0a54 6865206e lication...The n\n+ 0x01147890 65787420 7468696e 67207765 206e6565 ext thing we nee\n+ 0x011478a0 6420746f 20646f20 69732064 6566696e d to do is defin\n+ 0x011478b0 6520616e 20696e69 7469616c 697a6572 e an initializer\n+ 0x011478c0 2e0a0a3e 20617070 496e6974 203a3a20 ...> appInit :: \n+ 0x011478d0 536e6170 6c657449 6e697420 41707020 SnapletInit App \n+ 0x011478e0 4170700a 3e206170 70496e69 74203d20 App.> appInit = \n+ 0x011478f0 6d616b65 536e6170 6c657420 226d7961 makeSnaplet \"mya\n+ 0x01147900 70702220 224d7920 6578616d 706c6520 pp\" \"My example \n+ 0x01147910 6170706c 69636174 696f6e22 204e6f74 application\" Not\n+ 0x01147920 68696e67 20242064 6f0a3e20 20202020 hing $ do.> \n+ 0x01147930 6873203c 2d206e65 7374536e 61706c65 hs <- nestSnaple\n+ 0x01147940 74202268 65697374 22206865 69737420 t \"heist\" heist \n+ 0x01147950 24206865 69737449 6e697420 2274656d $ heistInit \"tem\n+ 0x01147960 706c6174 6573220a 3e202020 20206673 plates\".> fs\n+ 0x01147970 203c2d20 6e657374 536e6170 6c657420 <- nestSnaplet \n+ 0x01147980 22666f6f 2220666f 6f202420 666f6f49 \"foo\" foo $ fooI\n+ 0x01147990 6e69740a 3e202020 20206273 203c2d20 nit.> bs <- \n+ 0x011479a0 6e657374 536e6170 6c657420 22222062 nestSnaplet \"\" b\n+ 0x011479b0 61722024 206e616d 65536e61 706c6574 ar $ nameSnaplet\n+ 0x011479c0 20226e65 776e616d 65222024 20626172 \"newname\" $ bar\n+ 0x011479d0 496e6974 20666f6f 0a3e2020 20202061 Init foo.> a\n+ 0x011479e0 6464526f 75746573 205b2028 2268656c ddRoutes [ (\"hel\n+ 0x011479f0 6c6f222c 20777269 74655465 78742022 lo\", writeText \"\n+ 0x01147a00 68656c6c 6f20776f 726c6422 290a3e20 hello world\").> \n+ 0x01147a10 20202020 20202020 20202020 20202c20 , \n+ 0x01147a20 2822666f 6f6e616d 65222c20 77697468 (\"fooname\", with\n+ 0x01147a30 20666f6f 206e616d 65506167 65290a3e foo namePage).>\n+ 0x01147a40 20202020 20202020 20202020 2020202c ,\n+ 0x01147a50 20282262 61726e61 6d65222c 20776974 (\"barname\", wit\n+ 0x01147a60 68206261 72206e61 6d655061 6765290a h bar namePage).\n+ 0x01147a70 3e202020 20202020 20202020 20202020 > \n+ 0x01147a80 2c202822 636f6d70 616e7922 2c20636f , (\"company\", co\n+ 0x01147a90 6d70616e 7948616e 646c6572 290a3e20 mpanyHandler).> \n+ 0x01147aa0 20202020 20202020 20202020 20205d0a ].\n+ 0x01147ab0 3e202020 20207772 61705369 74652028 > wrapSite (\n+ 0x01147ac0 3c7c3e20 68656973 74536572 7665290a <|> heistServe).\n+ 0x01147ad0 3e202020 20207265 66203c2d 206c6966 > ref <- lif\n+ 0x01147ae0 74494f20 24206e65 77494f52 65662022 tIO $ newIORef \"\n+ 0x01147af0 666f6f43 6f727022 0a3e2020 20202072 fooCorp\".> r\n+ 0x01147b00 65747572 6e202420 41707020 68732066 eturn $ App hs f\n+ 0x01147b10 73206273 20726566 0a0a466f 72206e6f s bs ref..For no\n+ 0x01147b20 7720646f 6e277420 776f7272 79206162 w don't worry ab\n+ 0x01147b30 6f757420 616c6c20 74686520 64657461 out all the deta\n+ 0x01147b40 696c7320 6f662074 68697320 636f6465 ils of this code\n+ 0x01147b50 2e202057 65276c6c 20776f72 6b207468 . We'll work th\n+ 0x01147b60 726f7567 68207468 650a696e 64697669 rough the.indivi\n+ 0x01147b70 6475616c 20706965 63657320 6f6e6520 dual pieces one \n+ 0x01147b80 61742061 2074696d 652e2020 54686520 at a time. The \n+ 0x01147b90 62617369 63206964 65612068 65726520 basic idea here \n+ 0x01147ba0 69732074 68617420 746f2069 6e697469 is that to initi\n+ 0x01147bb0 616c697a 6520616e 0a617070 6c696361 alize an.applica\n+ 0x01147bc0 74696f6e 2c207765 20666972 73742069 tion, we first i\n+ 0x01147bd0 6e697469 616c697a 65206561 6368206f nitialize each o\n+ 0x01147be0 66207468 6520736e 61706c65 74732c20 f the snaplets, \n+ 0x01147bf0 61646420 736f6d65 20726f75 7465732c add some routes,\n+ 0x01147c00 2072756e 20610a66 756e6374 696f6e20 run a.function \n+ 0x01147c10 77726170 70696e67 20616c6c 20746865 wrapping all the\n+ 0x01147c20 20726f75 7465732c 20616e64 20726574 routes, and ret\n+ 0x01147c30 75726e20 74686520 72657375 6c74696e urn the resultin\n+ 0x01147c40 67207374 61746520 64617461 0a737472 g state data.str\n+ 0x01147c50 75637475 72652e20 20546869 73206578 ucture. This ex\n+ 0x01147c60 616d706c 65206465 6d6f6e73 74726174 ample demonstrat\n+ 0x01147c70 65732074 68652075 7365206f 66206120 es the use of a \n+ 0x01147c80 66657720 6f662074 6865206d 6f737420 few of the most \n+ 0x01147c90 636f6d6d 6f6e0a73 6e61706c 65742066 common.snaplet f\n+ 0x01147ca0 756e6374 696f6e73 2e0a0a6e 65737453 unctions...nestS\n+ 0x01147cb0 6e61706c 65740a2d 2d2d2d2d 2d2d2d2d naplet.---------\n+ 0x01147cc0 2d2d0a0a 416c6c20 63616c6c 7320746f --..All calls to\n+ 0x01147cd0 20636869 6c642073 6e61706c 65742069 child snaplet i\n+ 0x01147ce0 6e697469 616c697a 65722066 756e6374 nitializer funct\n+ 0x01147cf0 696f6e73 206d7573 74206265 20777261 ions must be wra\n+ 0x01147d00 70706564 20696e20 61206361 6c6c2074 pped in a call t\n+ 0x01147d10 6f0a6e65 7374536e 61706c65 742e2020 o.nestSnaplet. \n+ 0x01147d20 54686520 66697273 74207061 72616d65 The first parame\n+ 0x01147d30 74657220 69732061 2055524c 20706174 ter is a URL pat\n+ 0x01147d40 68207365 676d656e 74207468 61742069 h segment that i\n+ 0x01147d50 73207573 65642074 6f207072 65666978 s used to prefix\n+ 0x01147d60 0a616c6c 20726f75 74657320 64656669 .all routes defi\n+ 0x01147d70 6e656420 62792074 68652073 6e61706c ned by the snapl\n+ 0x01147d80 65742e20 20546869 73206c65 74732079 et. This lets y\n+ 0x01147d90 6f752065 6e737572 65207468 61742074 ou ensure that t\n+ 0x01147da0 68657265 2077696c 6c206265 206e6f0a here will be no.\n+ 0x01147db0 70726f62 6c656d73 20776974 68206475 problems with du\n+ 0x01147dc0 706c6963 61746520 726f7574 65732064 plicate routes d\n+ 0x01147dd0 6566696e 65642069 6e206469 66666572 efined in differ\n+ 0x01147de0 656e7420 736e6170 6c657473 2e202049 ent snaplets. I\n+ 0x01147df0 66207468 6520666f 6f0a736e 61706c65 f the foo.snaple\n+ 0x01147e00 74206465 66696e65 73206120 726f7574 t defines a rout\n+ 0x01147e10 6520602f 666f6f70 61676560 2c207468 e `/foopage`, th\n+ 0x01147e20 656e2069 6e207468 65206162 6f766520 en in the above \n+ 0x01147e30 6578616d 706c652c 20746861 74207061 example, that pa\n+ 0x01147e40 67652077 696c6c0a 62652061 7661696c ge will.be avail\n+ 0x01147e50 61626c65 20617420 602f666f 6f2f666f able at `/foo/fo\n+ 0x01147e60 6f706167 65602e20 20536f6d 6574696d opage`. Sometim\n+ 0x01147e70 65732074 686f7567 682c2079 6f75206d es though, you m\n+ 0x01147e80 69676874 2077616e 74206120 736e6170 ight want a snap\n+ 0x01147e90 6c657427 730a726f 75746573 20746f20 let's.routes to \n+ 0x01147ea0 62652061 7661696c 61626c65 20617420 be available at \n+ 0x01147eb0 74686520 746f7020 6c657665 6c2e2020 the top level. \n+ 0x01147ec0 546f2064 6f207468 61742c20 6a757374 To do that, just\n+ 0x01147ed0 20706173 7320616e 20656d70 74792073 pass an empty s\n+ 0x01147ee0 7472696e 670a746f 206e6573 74536e61 tring.to nestSna\n+ 0x01147ef0 706c6574 20617320 73686f77 6e206162 plet as shown ab\n+ 0x01147f00 6f766520 77697468 20746865 20626172 ove with the bar\n+ 0x01147f10 20736e61 706c6574 2e0a0a49 6e206f75 snaplet...In ou\n+ 0x01147f20 72206578 616d706c 65206162 6f76652c r example above,\n+ 0x01147f30 20746865 20626172 20736e61 706c6574 the bar snaplet\n+ 0x01147f40 20646f65 7320736f 6d657468 696e6720 does something \n+ 0x01147f50 74686174 206e6565 64732074 6f206b6e that needs to kn\n+ 0x01147f60 6f772061 626f7574 0a746865 20666f6f ow about.the foo\n+ 0x01147f70 20736e61 706c6574 2e20204d 61796265 snaplet. Maybe\n+ 0x01147f80 20666f6f 20697320 61206461 74616261 foo is a databa\n+ 0x01147f90 73652073 6e61706c 65742061 6e642062 se snaplet and b\n+ 0x01147fa0 61722077 616e7473 20746f20 73746f72 ar wants to stor\n+ 0x01147fb0 65206f72 0a726561 6420736f 6d657468 e or.read someth\n+ 0x01147fc0 696e672e 2020496e 206f7264 65722074 ing. In order t\n+ 0x01147fd0 6f206d61 6b652074 68617420 68617070 o make that happ\n+ 0x01147fe0 656e2c20 6974206e 65656473 20746f20 en, it needs to \n+ 0x01147ff0 68617665 20612022 68616e64 6c652220 have a \"handle\" \n+ 0x01148000 746f0a74 68652073 6e61706c 65742e20 to.the snaplet. \n+ 0x01148010 204f7572 2068616e 646c6573 20617265 Our handles are\n+ 0x01148020 20776861 74657665 72206669 656c6420 whatever field \n+ 0x01148030 6e616d65 73207765 20757365 6420696e names we used in\n+ 0x01148040 20746865 20417070 20646174 610a7374 the App data.st\n+ 0x01148050 72756374 75726520 6d696e75 73207468 ructure minus th\n+ 0x01148060 6520696e 69746961 6c20756e 64657273 e initial unders\n+ 0x01148070 636f7265 20636861 72616374 65722e20 core character. \n+ 0x01148080 20546865 79206172 65206175 746f6d61 They are automa\n+ 0x01148090 74696361 6c6c790a 67656e65 72617465 tically.generate\n+ 0x011480a0 64206279 20746865 20606d61 6b654c65 d by the `makeLe\n+ 0x011480b0 6e736573 60206675 6e637469 6f6e2e20 nses` function. \n+ 0x011480c0 20466f72 206e6f77 20697427 73207375 For now it's su\n+ 0x011480d0 66666963 69656e74 20746f20 7468696e fficient to thin\n+ 0x011480e0 6b206f66 0a746865 6d206173 20612067 k of.them as a g\n+ 0x011480f0 65747465 7220616e 64206120 73657474 etter and a sett\n+ 0x01148100 65722063 6f6d6269 6e656420 28746f20 er combined (to \n+ 0x01148110 75736520 616e204f 4f206d65 74617068 use an OO metaph\n+ 0x01148120 6f72292e 0a0a5468 65207365 636f6e64 or)...The second\n+ 0x01148130 20706172 616d6574 65722074 6f206e65 parameter to ne\n+ 0x01148140 7374536e 61706c65 74206973 20746865 stSnaplet is the\n+ 0x01148150 206c656e 7320746f 20746865 20736e61 lens to the sna\n+ 0x01148160 706c6574 20796f75 27726520 6e657374 plet you're nest\n+ 0x01148170 696e672e 0a496e20 6f726465 7220746f ing..In order to\n+ 0x01148180 20706c61 63652061 20706965 63652069 place a piece i\n+ 0x01148190 6e746f20 74686520 70757a7a 6c652c20 nto the puzzle, \n+ 0x011481a0 796f7520 6e656564 20746f20 6b6e6f77 you need to know\n+ 0x011481b0 20776865 72652069 7420676f 65732e0a where it goes..\n+ 0x011481c0 0a6e616d 65536e61 706c6574 0a2d2d2d .nameSnaplet.---\n+ 0x011481d0 2d2d2d2d 2d2d2d2d 0a0a5468 65206175 --------..The au\n+ 0x011481e0 74686f72 206f6620 6120736e 61706c65 thor of a snaple\n+ 0x011481f0 74206465 66696e65 73206120 64656661 t defines a defa\n+ 0x01148200 756c7420 6e616d65 20666f72 20746865 ult name for the\n+ 0x01148210 20736e61 706c6574 20696e20 74686520 snaplet in the \n+ 0x01148220 66697273 740a6172 67756d65 6e742074 first.argument t\n+ 0x01148230 6f207468 65206d61 6b65536e 61706c65 o the makeSnaple\n+ 0x01148240 74206675 6e637469 6f6e2e20 20546869 t function. Thi\n+ 0x01148250 73206e61 6d652069 73207573 65642066 s name is used f\n+ 0x01148260 6f722074 68652073 6e61706c 65742773 or the snaplet's\n+ 0x01148270 0a646972 6563746f 72792069 6e207468 .directory in th\n+ 0x01148280 65206669 6c657379 7374656d 2e202049 e filesystem. I\n+ 0x01148290 6620796f 7520646f 6e277420 77616e74 f you don't want\n+ 0x011482a0 20746f20 75736520 74686520 64656661 to use the defa\n+ 0x011482b0 756c7420 6e616d65 2c20796f 750a6361 ult name, you.ca\n+ 0x011482c0 6e206f76 65727269 64652069 74207769 n override it wi\n+ 0x011482d0 74682074 68652060 6e616d65 536e6170 th the `nameSnap\n+ 0x011482e0 6c657460 2066756e 6374696f 6e2e2020 let` function. \n+ 0x011482f0 416c736f 2c206966 20796f75 2077616e Also, if you wan\n+ 0x01148300 7420746f 20686176 65207477 6f0a696e t to have two.in\n+ 0x01148310 7374616e 63657320 6f662074 68652073 stances of the s\n+ 0x01148320 616d6520 736e6170 6c65742c 20746865 ame snaplet, the\n+ 0x01148330 6e20796f 75207769 6c6c206e 65656420 n you will need \n+ 0x01148340 746f2075 73652060 6e616d65 536e6170 to use `nameSnap\n+ 0x01148350 6c657460 20746f20 67697665 0a617420 let` to give.at \n+ 0x01148360 6c656173 74206f6e 65206f66 20746865 least one of the\n+ 0x01148370 6d206120 756e6971 7565206e 616d652e m a unique name.\n+ 0x01148380 0a0a6164 64526f75 7465730a 2d2d2d2d ..addRoutes.----\n+ 0x01148390 2d2d2d2d 2d0a0a54 68652060 61646452 -----..The `addR\n+ 0x011483a0 6f757465 73602066 756e6374 696f6e20 outes` function \n+ 0x011483b0 69732068 6f772061 6e206170 706c6963 is how an applic\n+ 0x011483c0 6174696f 6e20286f 7220736e 61706c65 ation (or snaple\n+ 0x011483d0 74292064 6566696e 65732069 74730a72 t) defines its.r\n+ 0x011483e0 6f757465 732e2020 556e6465 72207468 outes. Under th\n+ 0x011483f0 6520686f 6f642074 68652073 6e61706c e hood the snapl\n+ 0x01148400 65742069 6e667261 73747275 63747572 et infrastructur\n+ 0x01148410 65206d65 72676573 20616c6c 20746865 e merges all the\n+ 0x01148420 20726f75 74657320 66726f6d 0a616c6c routes from.all\n+ 0x01148430 20736e61 706c6574 732c2070 72657065 snaplets, prepe\n+ 0x01148440 6e647320 70726566 69786573 2066726f nds prefixes fro\n+ 0x01148450 6d20606e 65737453 6e61706c 65746020 m `nestSnaplet` \n+ 0x01148460 63616c6c 732c2061 6e642070 61737365 calls, and passe\n+ 0x01148470 73207468 65206c69 73740a74 6f20536e s the list.to Sn\n+ 0x01148480 61702773 0a5b726f 7574655d 28687474 ap's.[route](htt\n+ 0x01148490 703a2f2f 6861636b 6167652e 6861736b p://hackage.hask\n+ 0x011484a0 656c6c2e 6f72672f 7061636b 61676573 ell.org/packages\n+ 0x011484b0 2f617263 68697665 2f736e61 702d636f /archive/snap-co\n+ 0x011484c0 72652f30 2e352e31 2e342f64 6f632f68 re/0.5.1.4/doc/h\n+ 0x011484d0 746d6c2f 536e6170 2d547970 65732e68 tml/Snap-Types.h\n+ 0x011484e0 746d6c23 763a726f 75746529 0a66756e tml#v:route).fun\n+ 0x011484f0 6374696f 6e2e0a0a 4120726f 75746520 ction...A route \n+ 0x01148500 69732061 20747570 6c65206f 66206120 is a tuple of a \n+ 0x01148510 55524c20 616e6420 61206861 6e646c65 URL and a handle\n+ 0x01148520 72206675 6e637469 6f6e2074 68617420 r function that \n+ 0x01148530 77696c6c 20626520 63616c6c 65642077 will be called w\n+ 0x01148540 68656e0a 74686520 55524c20 69732072 hen.the URL is r\n+ 0x01148550 65717565 73746564 2e202048 616e646c equested. Handl\n+ 0x01148560 65722069 73206120 77726170 70657220 er is a wrapper \n+ 0x01148570 61726f75 6e642074 68652053 6e617020 around the Snap \n+ 0x01148580 6d6f6e61 64207468 61742068 616e646c monad that handl\n+ 0x01148590 65730a74 68652073 6e61706c 65742773 es.the snaplet's\n+ 0x011485a0 20696e66 72617374 72756374 7572652e infrastructure.\n+ 0x011485b0 20204475 72696e67 20696e69 7469616c During initial\n+ 0x011485c0 697a6174 696f6e2c 20736e61 706c6574 ization, snaplet\n+ 0x011485d0 73207573 65207468 650a6049 6e697469 s use the.`Initi\n+ 0x011485e0 616c697a 65726020 6d6f6e61 642e2020 alizer` monad. \n+ 0x011485f0 44757269 6e672072 756e7469 6d652c20 During runtime, \n+ 0x01148600 74686579 20757365 20746865 20604861 they use the `Ha\n+ 0x01148610 6e646c65 7260206d 6f6e6164 2e202057 ndler` monad. W\n+ 0x01148620 65276c6c 0a646973 63757373 20604861 e'll.discuss `Ha\n+ 0x01148630 6e646c65 72602069 6e206d6f 72652064 ndler` in more d\n+ 0x01148640 65746169 6c206c61 7465722e 20204966 etail later. If\n+ 0x01148650 20796f75 27726520 66616d69 6c696172 you're familiar\n+ 0x01148660 20776974 6820536e 61702773 206f6c64 with Snap's old\n+ 0x01148670 0a657874 656e7369 6f6e2073 79737465 .extension syste\n+ 0x01148680 6d2c2079 6f752063 616e2074 68696e6b m, you can think\n+ 0x01148690 206f6620 69742061 7320726f 7567686c of it as roughl\n+ 0x011486a0 79206571 75697661 6c656e74 20746f20 y equivalent to \n+ 0x011486b0 74686520 4170706c 69636174 696f6e0a the Application.\n+ 0x011486c0 6d6f6e61 642e2020 49742068 61732061 monad. It has a\n+ 0x011486d0 20604d6f 6e616453 74617465 6020696e `MonadState` in\n+ 0x011486e0 7374616e 63652074 68617420 6c657473 stance that lets\n+ 0x011486f0 20796f75 20616363 65737320 616e6420 you access and \n+ 0x01148700 6d6f6469 66792074 68650a63 75727265 modify the.curre\n+ 0x01148710 6e742073 6e61706c 65742773 20737461 nt snaplet's sta\n+ 0x01148720 74652c20 616e6420 6120604d 6f6e6164 te, and a `Monad\n+ 0x01148730 536e6170 6020696e 7374616e 63652070 Snap` instance p\n+ 0x01148740 726f7669 64696e67 20746865 0a726571 roviding the.req\n+ 0x01148750 75657374 2d70726f 63657373 696e6720 uest-processing \n+ 0x01148760 66756e63 74696f6e 73206465 66696e65 functions define\n+ 0x01148770 6420696e 20536e61 702e5479 7065732e d in Snap.Types.\n+ 0x01148780 0a0a7772 61705369 74650a2d 2d2d2d2d ..wrapSite.-----\n+ 0x01148790 2d2d2d2d 2d2d2d0a 0a607772 61705369 -------..`wrapSi\n+ 0x011487a0 74656020 616c6c6f 77732079 6f752074 te` allows you t\n+ 0x011487b0 6f206170 706c7920 616e2061 72626974 o apply an arbit\n+ 0x011487c0 72617279 20604861 6e646c65 72602074 rary `Handler` t\n+ 0x011487d0 72616e73 666f726d 6174696f 6e20746f ransformation to\n+ 0x011487e0 0a746865 20746f70 2d6c6576 656c2068 .the top-level h\n+ 0x011487f0 616e646c 65722e20 20546869 73206973 andler. This is\n+ 0x01148800 20757365 66756c20 69662079 6f752077 useful if you w\n+ 0x01148810 616e7420 746f2064 6f20736f 6d652067 ant to do some g\n+ 0x01148820 656e6572 69630a70 726f6365 7373696e eneric.processin\n+ 0x01148830 67206174 20746865 20626567 696e6e69 g at the beginni\n+ 0x01148840 6e67206f 7220656e 64206f66 20657665 ng or end of eve\n+ 0x01148850 72792072 65717565 73742e20 20466f72 ry request. For\n+ 0x01148860 20696e73 74616e63 652c2061 20736573 instance, a ses\n+ 0x01148870 73696f6e 0a736e61 706c6574 206d6967 sion.snaplet mig\n+ 0x01148880 68742075 73652069 7420746f 20746f75 ht use it to tou\n+ 0x01148890 63682061 20736573 73696f6e 20616374 ch a session act\n+ 0x011488a0 69766974 7920746f 6b656e20 6265666f ivity token befo\n+ 0x011488b0 72652072 6f757469 6e672068 61707065 re routing happe\n+ 0x011488c0 6e732e0a 49742063 6f756c64 20616c73 ns..It could als\n+ 0x011488d0 6f206265 20757365 6420746f 20696d70 o be used to imp\n+ 0x011488e0 6c656d65 6e742063 7573746f 6d206c6f lement custom lo\n+ 0x011488f0 6767696e 672e2020 54686520 6578616d gging. The exam\n+ 0x01148900 706c6520 61626f76 65207573 65732069 ple above uses i\n+ 0x01148910 740a746f 20646566 696e6520 68656973 t.to define heis\n+ 0x01148920 74536572 76652028 70726f76 69646564 tServe (provided\n+ 0x01148930 20627920 74686520 48656973 7420736e by the Heist sn\n+ 0x01148940 61706c65 74292061 73207468 65206465 aplet) as the de\n+ 0x01148950 6661756c 74206861 6e646c65 7220746f fault handler to\n+ 0x01148960 0a626520 74726965 64206966 206e6f20 .be tried if no \n+ 0x01148970 6f746865 72206861 6e646c65 72206d61 other handler ma\n+ 0x01148980 74636865 642e2020 54686973 206d6179 tched. This may\n+ 0x01148990 20736565 6d206c69 6b652061 6e206561 seem like an ea\n+ 0x011489a0 73792077 61792074 6f206465 66696e65 sy way to define\n+ 0x011489b0 0a726f75 7465732c 20627574 20696620 .routes, but if \n+ 0x011489c0 796f7520 73747269 6e672074 68656d20 you string them \n+ 0x011489d0 616c6c20 746f6765 74686572 20696e20 all together in \n+ 0x011489e0 74686973 20776179 20656163 68206861 this way each ha\n+ 0x011489f0 6e646c65 72207769 6c6c2062 650a6576 ndler will be.ev\n+ 0x01148a00 616c7561 74656420 73657175 656e7469 aluated sequenti\n+ 0x01148a10 616c6c79 20616e64 20796f75 276c6c20 ally and you'll \n+ 0x01148a20 67657420 4f286e29 2074696d 6520636f get O(n) time co\n+ 0x01148a30 6d706c65 78697479 2c207768 65726561 mplexity, wherea\n+ 0x01148a40 7320726f 75746573 0a646566 696e6564 s routes.defined\n+ 0x01148a50 20776974 68206061 6464526f 75746573 with `addRoutes\n+ 0x01148a60 60206861 7665204f 286c6f67 206e2920 ` have O(log n) \n+ 0x01148a70 74696d65 20636f6d 706c6578 6974792e time complexity.\n+ 0x01148a80 20205468 65726566 6f72652c 20696e20 Therefore, in \n+ 0x01148a90 610a7265 616c2d77 6f726c64 20617070 a.real-world app\n+ 0x01148aa0 6c696361 74696f6e 20796f75 20776f75 lication you wou\n+ 0x01148ab0 6c642070 726f6261 626c7920 77616e74 ld probably want\n+ 0x01148ac0 20746f20 68617665 20602822 222c2068 to have `(\"\", h\n+ 0x01148ad0 65697374 53657276 65296020 696e0a74 eistServe)` in.t\n+ 0x01148ae0 6865206c 69737420 70617373 65642074 he list passed t\n+ 0x01148af0 6f206061 6464526f 75746573 602e0a0a o `addRoutes`...\n+ 0x01148b00 77697468 0a2d2d2d 2d0a0a54 6865206c with.----..The l\n+ 0x01148b10 61737420 756e6661 6d696c69 61722066 ast unfamiliar f\n+ 0x01148b20 756e6374 696f6e20 696e2074 68652065 unction in the e\n+ 0x01148b30 78616d70 6c652069 73206077 69746860 xample is `with`\n+ 0x01148b40 2e202048 65726520 69742061 63636f6d . Here it accom\n+ 0x01148b50 70616e69 65732061 0a63616c 6c20746f panies a.call to\n+ 0x01148b60 20746865 2066756e 6374696f 6e20606e the function `n\n+ 0x01148b70 616d6550 61676560 2e202060 6e616d65 amePage`. `name\n+ 0x01148b80 50616765 60206973 20612073 696d706c Page` is a simpl\n+ 0x01148b90 65206578 616d706c 65206861 6e646c65 e example handle\n+ 0x01148ba0 7220616e 640a6c6f 6f6b7320 6c696b65 r and.looks like\n+ 0x01148bb0 20746869 732e0a0a 3e206e61 6d655061 this...> namePa\n+ 0x01148bc0 6765203a 3a204861 6e646c65 72206220 ge :: Handler b \n+ 0x01148bd0 76202829 0a3e206e 616d6550 61676520 v ().> namePage \n+ 0x01148be0 3d20646f 0a3e2020 2020206d 6e616d65 = do.> mname\n+ 0x01148bf0 203c2d20 67657453 6e61706c 65744e61 <- getSnapletNa\n+ 0x01148c00 6d650a3e 20202020 20777269 74655465 me.> writeTe\n+ 0x01148c10 78742024 2066726f 6d4d6179 62652022 xt $ fromMaybe \"\n+ 0x01148c20 54686973 2073686f 756c646e 27742068 This shouldn't h\n+ 0x01148c30 61707065 6e22206d 6e616d65 0a0a5468 appen\" mname..Th\n+ 0x01148c40 69732066 756e6374 696f6e20 69732061 is function is a\n+ 0x01148c50 2067656e 65726963 2068616e 646c6572 generic handler\n+ 0x01148c60 20746861 74206765 74732074 6865206e that gets the n\n+ 0x01148c70 616d6520 6f662074 68652063 75727265 ame of the curre\n+ 0x01148c80 6e742073 6e61706c 65740a61 6e642077 nt snaplet.and w\n+ 0x01148c90 72697465 73206974 20696e74 6f207468 rites it into th\n+ 0x01148ca0 65207265 73706f6e 73652077 69746820 e response with \n+ 0x01148cb0 74686520 60777269 74655465 78746020 the `writeText` \n+ 0x01148cc0 66756e63 74696f6e 20646566 696e6564 function defined\n+ 0x01148cd0 20627920 7468650a 736e6170 2d636f72 by the.snap-cor\n+ 0x01148ce0 65207072 6f6a6563 742e2020 54686520 e project. The \n+ 0x01148cf0 74797065 20766172 6961626c 65732027 type variables '\n+ 0x01148d00 62272061 6e642027 76272069 6e646963 b' and 'v' indic\n+ 0x01148d10 61746520 74686174 20746869 73206675 ate that this fu\n+ 0x01148d20 6e637469 6f6e0a77 696c6c20 776f726b nction.will work\n+ 0x01148d30 20696e20 616e7920 736e6170 6c657420 in any snaplet \n+ 0x01148d40 77697468 20616e79 20626173 65206170 with any base ap\n+ 0x01148d50 706c6963 6174696f 6e2e2020 54686520 plication. The \n+ 0x01148d60 27776974 68272066 756e6374 696f6e20 'with' function \n+ 0x01148d70 69730a75 73656420 746f2072 756e2060 is.used to run `\n+ 0x01148d80 6e616d65 50616765 6020696e 20746865 namePage` in the\n+ 0x01148d90 20636f6e 74657874 206f6620 74686520 context of the \n+ 0x01148da0 736e6170 6c657473 20666f6f 20616e64 snaplets foo and\n+ 0x01148db0 20626172 20666f72 20746865 0a636f72 bar for the.cor\n+ 0x01148dc0 72657370 6f6e6469 6e672072 6f757465 responding route\n+ 0x01148dd0 732e0a0a 53697465 2052656c 6f616469 s...Site Reloadi\n+ 0x01148de0 6e670a2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ng.-------------\n+ 0x01148df0 2d0a0a53 6e61706c 65742049 6e697469 -..Snaplet Initi\n+ 0x01148e00 616c697a 65727320 73657276 65206475 alizers serve du\n+ 0x01148e10 616c2070 7572706f 73652061 7320626f al purpose as bo\n+ 0x01148e20 74682069 6e697469 616c697a 65727320 th initializers \n+ 0x01148e30 616e6420 72656c6f 61646572 732e0a52 and reloaders..R\n+ 0x01148e40 656c6f61 64732061 72652074 72696767 eloads are trigg\n+ 0x01148e50 65726564 20627920 61207370 65636961 ered by a specia\n+ 0x01148e60 6c206861 6e646c65 72207468 61742069 l handler that i\n+ 0x01148e70 7320626f 756e6420 746f2074 68650a60 s bound to the.`\n+ 0x01148e80 2f61646d 696e2f72 656c6f61 64602072 /admin/reload` r\n+ 0x01148e90 6f757465 2e202054 68697320 68616e64 oute. This hand\n+ 0x01148ea0 6c657220 72652d72 756e7320 74686520 ler re-runs the \n+ 0x01148eb0 73697465 20696e69 7469616c 697a6572 site initializer\n+ 0x01148ec0 20616e64 20696620 69742069 730a7375 and if it is.su\n+ 0x01148ed0 63636573 7366756c 2c206c6f 61647320 ccessful, loads \n+ 0x01148ee0 74686520 6e65776c 79206765 6e657261 the newly genera\n+ 0x01148ef0 74656420 696e2d6d 656d6f72 79207374 ted in-memory st\n+ 0x01148f00 6174652e 2020546f 20707265 76656e74 ate. To prevent\n+ 0x01148f10 2064656e 69616c20 6f660a73 65727669 denial of.servi\n+ 0x01148f20 63652061 74746163 6b732c20 74686520 ce attacks, the \n+ 0x01148f30 72656c6f 61642072 6f757465 20697320 reload route is \n+ 0x01148f40 6f6e6c79 20616363 65737369 626c6520 only accessible \n+ 0x01148f50 66726f6d 206c6f63 616c686f 73742e0a from localhost..\n+ 0x01148f60 0a496620 74686572 65206172 6520616e .If there are an\n+ 0x01148f70 79206572 726f7273 20647572 696e6720 y errors during \n+ 0x01148f80 72656c6f 61642c20 796f7520 776f756c reload, you woul\n+ 0x01148f90 64206e61 74757261 6c6c7920 77616e74 d naturally want\n+ 0x01148fa0 20746f20 73656520 7468656d 20696e0a to see them in.\n+ 0x01148fb0 74686520 48545450 20726573 706f6e73 the HTTP respons\n+ 0x01148fc0 65207265 7475726e 65642062 79207468 e returned by th\n+ 0x01148fd0 65207365 72766572 2e202048 6f776576 e server. Howev\n+ 0x01148fe0 65722c20 7768656e 20746865 73652073 er, when these s\n+ 0x01148ff0 616d650a 696e6974 69616c69 7a657273 ame.initializers\n+ 0x01149000 20617265 2072756e 20776865 6e20796f are run when yo\n+ 0x01149010 75206669 72737420 73746172 7420796f u first start yo\n+ 0x01149020 75722061 70702c20 796f7520 77696c6c ur app, you will\n+ 0x01149030 2077616e 7420746f 20736565 0a737461 want to see.sta\n+ 0x01149040 74757320 6d657373 61676573 20707269 tus messages pri\n+ 0x01149050 6e746564 20746f20 74686520 636f6e73 nted to the cons\n+ 0x01149060 6f6c652e 2020546f 206d616b 65207468 ole. To make th\n+ 0x01149070 69732070 6f737369 626c6520 77652070 is possible we p\n+ 0x01149080 726f7669 64652074 68650a60 7072696e rovide the.`prin\n+ 0x01149090 74496e66 6f602066 756e6374 696f6e2e tInfo` function.\n+ 0x011490a0 2020596f 75207368 6f756c64 20757365 You should use\n+ 0x011490b0 20697420 746f206f 75747075 7420616e it to output an\n+ 0x011490c0 7920696e 666f726d 6174696f 6e616c20 y informational \n+ 0x011490d0 6d657373 61676573 0a67656e 65726174 messages.generat\n+ 0x011490e0 65642062 7920796f 75722069 6e697469 ed by your initi\n+ 0x011490f0 616c697a 6572732e 20204966 20796f75 alizers. If you\n+ 0x01149100 20707269 6e742064 69726563 746c7920 print directly \n+ 0x01149110 746f2073 74616e64 61726420 6f757470 to standard outp\n+ 0x01149120 7574206f 720a7374 616e6461 72642065 ut or.standard e\n+ 0x01149130 72726f72 2c207468 656e2074 686f7365 rror, then those\n+ 0x01149140 206d6573 73616765 73207769 6c6c206e messages will n\n+ 0x01149150 6f742062 65206176 61696c61 626c6520 ot be available \n+ 0x01149160 696e2079 6f757220 62726f77 73657220 in your browser \n+ 0x01149170 7768656e 0a796f75 2072656c 6f616420 when.you reload \n+ 0x01149180 74686520 73697465 2e0a0a57 6f726b69 the site...Worki\n+ 0x01149190 6e672077 69746820 73746174 650a2d2d ng with state.--\n+ 0x011491a0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x011491b0 0a0a6048 616e646c 65722062 20766020 ..`Handler b v` \n+ 0x011491c0 68617320 6120604d 6f6e6164 53746174 has a `MonadStat\n+ 0x011491d0 65207660 20696e73 74616e63 652e2020 e v` instance. \n+ 0x011491e0 54686973 206d6561 6e732074 68617420 This means that \n+ 0x011491f0 796f7520 63616e20 61636365 73730a61 you can access.a\n+ 0x01149200 6c6c2079 6f757220 736e6170 6c657420 ll your snaplet \n+ 0x01149210 73746174 65207468 726f7567 68207468 state through th\n+ 0x01149220 65206765 742c2070 75742c20 67657473 e get, put, gets\n+ 0x01149230 2c20616e 64206d6f 64696679 2066756e , and modify fun\n+ 0x01149240 6374696f 6e732074 6861740a 61726520 ctions that.are \n+ 0x01149250 70726f62 61626c79 2066616d 696c6961 probably familia\n+ 0x01149260 72206672 6f6d2074 68652073 74617465 r from the state\n+ 0x01149270 206d6f6e 61642e20 20496e20 6f757220 monad. In our \n+ 0x01149280 6578616d 706c6520 6170706c 69636174 example applicat\n+ 0x01149290 696f6e20 77650a64 656d6f6e 73747261 ion we.demonstra\n+ 0x011492a0 74652074 68697320 77697468 2060636f te this with `co\n+ 0x011492b0 6d70616e 7948616e 646c6572 602e0a0a mpanyHandler`...\n+ 0x011492c0 3e20636f 6d70616e 7948616e 646c6572 > companyHandler\n+ 0x011492d0 203a3a20 48616e64 6c657220 41707020 :: Handler App \n+ 0x011492e0 41707020 28290a3e 20636f6d 70616e79 App ().> company\n+ 0x011492f0 48616e64 6c657220 3d206d65 74686f64 Handler = method\n+ 0x01149300 20474554 20676574 74657220 3c7c3e20 GET getter <|> \n+ 0x01149310 6d657468 6f642050 4f535420 73657474 method POST sett\n+ 0x01149320 65720a3e 20202077 68657265 0a3e2020 er.> where.> \n+ 0x01149330 20202067 65747465 72203d20 646f0a3e getter = do.>\n+ 0x01149340 20202020 20202020 206e616d 65526566 nameRef\n+ 0x01149350 203c2d20 67657473 205f636f 6d70616e <- gets _compan\n+ 0x01149360 794e616d 650a3e20 20202020 20202020 yName.> \n+ 0x01149370 6e616d65 203c2d20 6c696674 494f2024 name <- liftIO $\n+ 0x01149380 20726561 64494f52 6566206e 616d6552 readIORef nameR\n+ 0x01149390 65660a3e 20202020 20202020 20777269 ef.> wri\n+ 0x011493a0 74654253 206e616d 650a3e20 20202020 teBS name.> \n+ 0x011493b0 73657474 6572203d 20646f0a 3e202020 setter = do.> \n+ 0x011493c0 20202020 20206d6e 616d6520 3c2d2067 mname <- g\n+ 0x011493d0 65745061 72616d20 226e616d 65220a3e etParam \"name\".>\n+ 0x011493e0 20202020 20202020 206e616d 65526566 nameRef\n+ 0x011493f0 203c2d20 67657473 205f636f 6d70616e <- gets _compan\n+ 0x01149400 794e616d 650a3e20 20202020 20202020 yName.> \n+ 0x01149410 6c696674 494f2024 206d6179 62652028 liftIO $ maybe (\n+ 0x01149420 72657475 726e2028 29292028 77726974 return ()) (writ\n+ 0x01149430 65494f52 6566206e 616d6552 65662920 eIORef nameRef) \n+ 0x01149440 6d6e616d 650a3e20 20202020 20202020 mname.> \n+ 0x01149450 67657474 65720a0a 49662079 6f752073 getter..If you s\n+ 0x01149460 65742061 20474554 20726571 75657374 et a GET request\n+ 0x01149470 20746f20 602f636f 6d70616e 79602c20 to `/company`, \n+ 0x01149480 796f7527 6c6c2067 65742074 68652073 you'll get the s\n+ 0x01149490 7472696e 67202266 6f6f436f 72702220 tring \"fooCorp\" \n+ 0x011494a0 6261636b 2e0a4966 20796f75 2073656e back..If you sen\n+ 0x011494b0 64206120 504f5354 20726571 75657374 d a POST request\n+ 0x011494c0 2c206974 2077696c 6c207365 74207468 , it will set th\n+ 0x011494d0 6520494f 52656620 68656c64 20696e20 e IORef held in \n+ 0x011494e0 74686520 605f636f 6d70616e 794e616d the `_companyNam\n+ 0x011494f0 65600a66 69656c64 20696e20 74686520 e`.field in the \n+ 0x01149500 60417070 60206461 74612073 74727563 `App` data struc\n+ 0x01149510 74757265 20746f20 74686520 76616c75 ture to the valu\n+ 0x01149520 65206f66 20746865 20606e61 6d656020 e of the `name` \n+ 0x01149530 6669656c 642e2020 5468656e 2069740a field. Then it.\n+ 0x01149540 63616c6c 73207468 65206765 74746572 calls the getter\n+ 0x01149550 20746f20 72657475 726e2074 68617420 to return that \n+ 0x01149560 76616c75 65206261 636b2074 6f20796f value back to yo\n+ 0x01149570 7520736f 20796f75 2063616e 20736565 u so you can see\n+ 0x01149580 20697420 7761730a 61637475 616c6c79 it was.actually\n+ 0x01149590 20636861 6e676564 2e202041 6761696e changed. Again\n+ 0x011495a0 2c207265 6d656d62 65722074 68617420 , remember that \n+ 0x011495b0 74686973 20636861 6e676520 6f6e6c79 this change only\n+ 0x011495c0 20706572 73697374 73206163 726f7373 persists across\n+ 0x011495d0 0a726571 75657374 73206265 63617573 .requests becaus\n+ 0x011495e0 65207765 20757365 6420616e 20494f52 e we used an IOR\n+ 0x011495f0 65662e20 20496620 605f636f 6d70616e ef. If `_compan\n+ 0x01149600 794e616d 65602077 6173206a 75737420 yName` was just \n+ 0x01149610 6120706c 61696e20 73747269 6e670a61 a plain string.a\n+ 0x01149620 6e642077 65206861 64207573 6564206d nd we had used m\n+ 0x01149630 6f646966 792c2074 68652063 68616e67 odify, the chang\n+ 0x01149640 65642072 6573756c 7420776f 756c6420 ed result would \n+ 0x01149650 6f6e6c79 20626520 76697369 626c6520 only be visible \n+ 0x01149660 696e2074 68652072 6573740a 6f662074 in the rest.of t\n+ 0x01149670 68652070 726f6365 7373696e 6720666f he processing fo\n+ 0x01149680 72207468 61742072 65717565 73742e0a r that request..\n+ 0x01149690 0a546865 20486569 73742053 6e61706c .The Heist Snapl\n+ 0x011496a0 65740a3d 3d3d3d3d 3d3d3d3d 3d3d3d3d et.=============\n+ 0x011496b0 3d3d3d3d 0a0a5468 65206173 74757465 ====..The astute\n+ 0x011496c0 20726561 64657220 6d696768 74206173 reader might as\n+ 0x011496d0 6b207768 79207468 65726520 6973206e k why there is n\n+ 0x011496e0 6f206077 69746820 68656973 74602069 o `with heist` i\n+ 0x011496f0 6e206672 6f6e7420 6f662074 68652063 n front of the c\n+ 0x01149700 616c6c0a 746f2060 68656973 74536572 all.to `heistSer\n+ 0x01149710 7665602e 2020416e 6420696e 64656564 ve`. And indeed\n+ 0x01149720 2c207468 61742077 6f756c64 206e6f72 , that would nor\n+ 0x01149730 6d616c6c 79206265 20746865 20636173 mally be the cas\n+ 0x01149740 652e2020 42757420 77652064 65636964 e. But we decid\n+ 0x01149750 65640a74 68617420 616e2061 70706c69 ed.that an appli\n+ 0x01149760 63617469 6f6e2077 696c6c20 6e657665 cation will neve\n+ 0x01149770 72206e65 6564206d 6f726520 7468616e r need more than\n+ 0x01149780 206f6e65 20696e73 74616e63 65206f66 one instance of\n+ 0x01149790 20612048 65697374 20736e61 706c6574 a Heist snaplet\n+ 0x011497a0 2e0a536f 20776520 70726f76 69646564 ..So we provided\n+ 0x011497b0 20612074 79706520 636c6173 73206361 a type class ca\n+ 0x011497c0 6c6c6564 20604861 73486569 73746020 lled `HasHeist` \n+ 0x011497d0 74686174 20616c6c 6f777320 616e2061 that allows an a\n+ 0x011497e0 70706c69 63617469 6f6e2074 6f0a6465 pplication to.de\n+ 0x011497f0 66696e65 20746865 20676c6f 62616c20 fine the global \n+ 0x01149800 72656665 72656e63 6520746f 20697473 reference to its\n+ 0x01149810 20486569 73742073 6e61706c 65742062 Heist snaplet b\n+ 0x01149820 79207772 6974696e 67206120 60486173 y writing a `Has\n+ 0x01149830 48656973 74600a69 6e737461 6e63652e Heist`.instance.\n+ 0x01149840 2020496e 20746869 73206578 616d706c In this exampl\n+ 0x01149850 65207765 20646566 696e6520 74686520 e we define the \n+ 0x01149860 696e7374 616e6365 20617320 666f6c6c instance as foll\n+ 0x01149870 6f77733a 0a0a3e20 696e7374 616e6365 ows:..> instance\n+ 0x01149880 20486173 48656973 74204170 70207768 HasHeist App wh\n+ 0x01149890 65726520 68656973 744c656e 73203d20 ere heistLens = \n+ 0x011498a0 73756253 6e61706c 65742068 65697374 subSnaplet heist\n+ 0x011498b0 0a0a4e6f 7720616c 6c207765 206e6565 ..Now all we nee\n+ 0x011498c0 64206973 20612073 696d706c 65206d61 d is a simple ma\n+ 0x011498d0 696e2066 756e6374 696f6e20 746f2073 in function to s\n+ 0x011498e0 65727665 206f7572 20617070 6c696361 erve our applica\n+ 0x011498f0 74696f6e 2e0a0a3e 206d6169 6e203a3a tion...> main ::\n+ 0x01149900 20494f20 28290a3e 206d6169 6e203d20 IO ().> main = \n+ 0x01149910 73657276 65536e61 706c6574 20646566 serveSnaplet def\n+ 0x01149920 61756c74 436f6e66 69672061 7070496e aultConfig appIn\n+ 0x01149930 69740a0a 54686973 20636f6d 706c6574 it..This complet\n+ 0x01149940 65732061 2066756c 6c20776f 726b696e es a full workin\n+ 0x01149950 67206170 706c6963 6174696f 6e2e2020 g application. \n+ 0x01149960 57652064 6964206c 65617665 206f7574 We did leave out\n+ 0x01149970 2061206c 6974746c 65206475 6d6d790a a little dummy.\n+ 0x01149980 636f6465 20666f72 20746865 20466f6f code for the Foo\n+ 0x01149990 20616e64 20426172 20736e61 706c6574 and Bar snaplet\n+ 0x011499a0 732e2020 54686973 20636f64 65206973 s. This code is\n+ 0x011499b0 20696e63 6c756465 6420696e 20506172 included in Par\n+ 0x011499c0 74322e68 732e2020 466f720a 6d6f7265 t2.hs. For.more\n+ 0x011499d0 20696e66 6f726d61 74696f6e 206c6f6f information loo\n+ 0x011499e0 6b20696e 206f7572 205b4150 490a646f k in our [API.do\n+ 0x011499f0 63756d65 6e746174 696f6e5d 28687474 cumentation](htt\n+ 0x01149a00 703a2f2f 6861636b 6167652e 6861736b p://hackage.hask\n+ 0x01149a10 656c6c2e 6f72672f 7061636b 6167652f ell.org/package/\n+ 0x01149a20 736e6170 292c2073 70656369 66696361 snap), specifica\n+ 0x01149a30 6c6c7920 7468650a 536e6170 2e536e61 lly the.Snap.Sna\n+ 0x01149a40 706c6574 206d6f64 756c652e 20204e6f plet module. No\n+ 0x01149a50 20726561 6c6c792c 20746861 74207761 really, that wa\n+ 0x01149a60 736e2774 2061206a 6f6b652e 20205468 sn't a joke. Th\n+ 0x01149a70 65204150 4920646f 63732061 72652077 e API docs are w\n+ 0x01149a80 72697474 656e0a61 73207072 6f73652e ritten.as prose.\n+ 0x01149a90 20205468 65792073 686f756c 64206265 They should be\n+ 0x01149aa0 20766572 79206561 73792074 6f207265 very easy to re\n+ 0x01149ab0 61642c20 7768696c 65206861 76696e67 ad, while having\n+ 0x01149ac0 20746865 2062656e 65666974 206f660a the benefit of.\n+ 0x01149ad0 696e636c 7564696e 6720616c 6c207468 including all th\n+ 0x01149ae0 65206163 7475616c 20747970 65207369 e actual type si\n+ 0x01149af0 676e6174 75726573 2e0a0a46 696c6573 gnatures...Files\n+ 0x01149b00 79737465 6d204461 74612061 6e642041 ystem Data and A\n+ 0x01149b10 75746f6d 61746963 20496e73 74616c6c utomatic Install\n+ 0x01149b20 6174696f 6e0a3d3d 3d3d3d3d 3d3d3d3d ation.==========\n+ 0x01149b30 3d3d3d3d 3d3d3d3d 3d3d3d3d 3d3d3d3d ================\n+ 0x01149b40 3d3d3d3d 3d3d3d3d 3d3d3d3d 3d3d3d3d ================\n+ 0x01149b50 0a0a536f 6d652073 6e61706c 65747320 ..Some snaplets \n+ 0x01149b60 77696c6c 20686176 65206461 74612073 will have data s\n+ 0x01149b70 746f7265 6420696e 20746865 2066696c tored in the fil\n+ 0x01149b80 65737973 74656d20 74686174 2073686f esystem that sho\n+ 0x01149b90 756c6420 62652069 6e737461 6c6c6564 uld be installed\n+ 0x01149ba0 0a696e74 6f207468 65206469 72656374 .into the direct\n+ 0x01149bb0 6f727920 6f662061 6e792070 726f6a65 ory of any proje\n+ 0x01149bc0 63742074 68617420 75736573 2069742e ct that uses it.\n+ 0x01149bd0 20204865 72652773 20616e20 6578616d Here's an exam\n+ 0x01149be0 706c6520 6f662077 68617420 610a736e ple of what a.sn\n+ 0x01149bf0 61706c65 74206669 6c657379 7374656d aplet filesystem\n+ 0x01149c00 206c6179 6f757420 6d696768 74206c6f layout might lo\n+ 0x01149c10 6f6b206c 696b653a 0a0a2020 2020666f ok like:.. fo\n+ 0x01149c20 6f736e61 706c6574 2f0a2020 20202020 osnaplet/. \n+ 0x01149c30 7c2d2d20 2a646576 656c2e63 66672a0a |-- *devel.cfg*.\n+ 0x01149c40 20202020 20207c2d 2d206462 2e636667 |-- db.cfg\n+ 0x01149c50 0a202020 2020207c 2d2d2070 75626c69 . |-- publi\n+ 0x01149c60 632f0a20 20202020 20202020 207c2d2d c/. |--\n+ 0x01149c70 20737479 6c657368 65657473 2f0a2020 stylesheets/. \n+ 0x01149c80 20202020 20202020 7c2d2d20 696d6167 |-- imag\n+ 0x01149c90 65732f0a 20202020 20202020 20207c2d es/. |-\n+ 0x01149ca0 2d206a73 2f0a2020 20202020 7c2d2d20 - js/. |-- \n+ 0x01149cb0 2a736e61 706c6574 732f2a0a 20202020 *snaplets/*. \n+ 0x01149cc0 20202020 20207c2d 2d202a68 65697374 |-- *heist\n+ 0x01149cd0 2f2a0a20 20202020 20202020 20202020 /*. \n+ 0x01149ce0 207c2d2d 2074656d 706c6174 65732f0a |-- templates/.\n+ 0x01149cf0 20202020 20202020 20207c2d 2d207375 |-- su\n+ 0x01149d00 62736e61 706c6574 312f0a20 20202020 bsnaplet1/. \n+ 0x01149d10 20202020 207c2d2d 20737562 736e6170 |-- subsnap\n+ 0x01149d20 6c657432 2f0a0a4f 6e6c7920 74686520 let2/..Only the \n+ 0x01149d30 73746172 72656420 6974656d 73206172 starred items ar\n+ 0x01149d40 65206163 7475616c 6c792065 6e666f72 e actually enfor\n+ 0x01149d50 63656420 62792063 75727265 6e742063 ced by current c\n+ 0x01149d60 6f64652c 20627574 20776520 77616e74 ode, but we want\n+ 0x01149d70 20746f0a 65737461 626c6973 68207468 to.establish th\n+ 0x01149d80 65206f74 68657273 20617320 6120636f e others as a co\n+ 0x01149d90 6e76656e 74696f6e 2e202054 68652066 nvention. The f\n+ 0x01149da0 696c6520 64657665 6c2e6366 67206973 ile devel.cfg is\n+ 0x01149db0 20617574 6f6d6174 6963616c 6c790a72 automatically.r\n+ 0x01149dc0 65616420 62792074 68652073 6e61706c ead by the snapl\n+ 0x01149dd0 65742069 6e667261 73747275 63747572 et infrastructur\n+ 0x01149de0 652e2020 49742069 73206176 61696c61 e. It is availa\n+ 0x01149df0 626c6520 746f2079 6f752076 69612074 ble to you via t\n+ 0x01149e00 68650a60 67657453 6e61706c 65745573 he.`getSnapletUs\n+ 0x01149e10 6572436f 6e666967 60206675 6e637469 erConfig` functi\n+ 0x01149e20 6f6e2e20 20436f6e 66696720 66696c65 on. Config file\n+ 0x01149e30 73207573 65207468 6520666f 726d6174 s use the format\n+ 0x01149e40 20646566 696e6564 20627920 42727961 defined by Brya\n+ 0x01149e50 6e0a4f27 53756c6c 6976616e 27732065 n.O'Sullivan's e\n+ 0x01149e60 7863656c 6c656e74 205b636f 6e666967 xcellent [config\n+ 0x01149e70 75726174 6f720a70 61636b61 67655d28 urator.package](\n+ 0x01149e80 68747470 3a2f2f68 61636b61 67652e68 http://hackage.h\n+ 0x01149e90 61736b65 6c6c2e6f 72672f70 61636b61 askell.org/packa\n+ 0x01149ea0 67652f63 6f6e6669 67757261 746f7229 ge/configurator)\n+ 0x01149eb0 2e202049 6e207468 69732065 78616d70 . In this examp\n+ 0x01149ec0 6c652c0a 74686520 75736572 20686173 le,.the user has\n+ 0x01149ed0 2063686f 73656e20 746f2070 75742064 chosen to put d\n+ 0x01149ee0 6220636f 6e666967 20697465 6d732069 b config items i\n+ 0x01149ef0 6e206120 73657061 72617465 2066696c n a separate fil\n+ 0x01149f00 6520616e 64207573 650a636f 6e666967 e and use.config\n+ 0x01149f10 75726174 6f722773 20696d70 6f727420 urator's import \n+ 0x01149f20 66756e63 74696f6e 616c6974 7920746f functionality to\n+ 0x01149f30 20696e63 6c756465 20697420 696e2064 include it in d\n+ 0x01149f40 6576656c 2e636667 2e202049 660a666f evel.cfg. If.fo\n+ 0x01149f50 6f736e61 706c6574 20757365 7320606e osnaplet uses `n\n+ 0x01149f60 65737453 6e61706c 65746020 6f722060 estSnaplet` or `\n+ 0x01149f70 656d6265 64536e61 706c6574 6020746f embedSnaplet` to\n+ 0x01149f80 20696e63 6c756465 20616e79 206f7468 include any oth\n+ 0x01149f90 65722073 6e61706c 6574732c 0a746865 er snaplets,.the\n+ 0x01149fa0 6e206669 6c657379 7374656d 20646174 n filesystem dat\n+ 0x01149fb0 61206465 66696e65 64206279 2074686f a defined by tho\n+ 0x01149fc0 73652073 6e61706c 65747320 77696c6c se snaplets will\n+ 0x01149fd0 20626520 696e636c 75646564 20696e0a be included in.\n+ 0x01149fe0 73756264 69726563 746f7269 65732075 subdirectories u\n+ 0x01149ff0 6e646572 20746865 2060736e 61706c65 nder the `snaple\n+ 0x0114a000 74732f60 20646972 6563746f 72792e0a ts/` directory..\n+ 0x0114a010 0a536f20 686f7720 646f2079 6f752074 .So how do you t\n+ 0x0114a020 656c6c20 74686520 736e6170 6c657420 ell the snaplet \n+ 0x0114a030 696e6672 61737472 75637475 72652074 infrastructure t\n+ 0x0114a040 68617420 796f7572 20736e61 706c6574 hat your snaplet\n+ 0x0114a050 20686173 2066696c 65737973 74656d0a has filesystem.\n+ 0x0114a060 64617461 20746861 74207368 6f756c64 data that should\n+ 0x0114a070 20626520 696e7374 616c6c65 643f2020 be installed? \n+ 0x0114a080 4c6f6f6b 20617420 74686520 64656669 Look at the defi\n+ 0x0114a090 6e697469 6f6e206f 66206170 70496e69 nition of appIni\n+ 0x0114a0a0 74206162 6f76652e 20205468 650a7468 t above. The.th\n+ 0x0114a0b0 69726420 61726775 6d656e74 20746f20 ird argument to \n+ 0x0114a0c0 74686520 6d616b65 536e6170 6c657420 the makeSnaplet \n+ 0x0114a0d0 66756e63 74696f6e 20697320 77686572 function is wher\n+ 0x0114a0e0 65207765 20737065 63696679 20746865 e we specify the\n+ 0x0114a0f0 2066696c 65737973 74656d0a 64697265 filesystem.dire\n+ 0x0114a100 63746f72 79207468 61742073 686f756c ctory that shoul\n+ 0x0114a110 64206265 20696e73 74616c6c 65642e20 d be installed. \n+ 0x0114a120 20546861 74206172 67756d65 6e742068 That argument h\n+ 0x0114a130 61732074 68652074 79706520 604d6179 as the type `May\n+ 0x0114a140 62652028 494f0a46 696c6550 61746829 be (IO.FilePath)\n+ 0x0114a150 602e2020 496e2074 68697320 63617365 `. In this case\n+ 0x0114a160 20776520 75736564 20604e6f 7468696e we used `Nothin\n+ 0x0114a170 67602062 65636175 7365206f 75722073 g` because our s\n+ 0x0114a180 696d706c 65206578 616d706c 6520646f imple example do\n+ 0x0114a190 65736e27 740a6861 76652061 6e792066 esn't.have any f\n+ 0x0114a1a0 696c6573 79737465 6d206461 74612e20 ilesystem data. \n+ 0x0114a1b0 20417320 616e2065 78616d70 6c652c20 As an example, \n+ 0x0114a1c0 6c657427 73207361 7920796f 75206172 let's say you ar\n+ 0x0114a1d0 65206372 65617469 6e672061 20736e61 e creating a sna\n+ 0x0114a1e0 706c6574 0a63616c 6c656420 6b696c6c plet.called kill\n+ 0x0114a1f0 65726170 70207468 61742077 696c6c20 erapp that will \n+ 0x0114a200 62652064 69737472 69627574 65642061 be distributed a\n+ 0x0114a210 73206120 6861636b 61676520 70726f6a s a hackage proj\n+ 0x0114a220 65637420 63616c6c 65640a73 6e61706c ect called.snapl\n+ 0x0114a230 65742d6b 696c6c65 72617070 2e202059 et-killerapp. Y\n+ 0x0114a240 6f757220 70726f6a 65637420 64697265 our project dire\n+ 0x0114a250 63746f72 79207374 72756374 75726520 ctory structure \n+ 0x0114a260 77696c6c 206c6f6f 6b20736f 6d657468 will look someth\n+ 0x0114a270 696e6720 6c696b65 0a746869 733a0a0a ing like.this:..\n+ 0x0114a280 20202020 736e6170 6c65742d 6b696c6c snaplet-kill\n+ 0x0114a290 65726170 702f0a20 20202020 207c2d2d erapp/. |--\n+ 0x0114a2a0 20726573 6f757263 65732f0a 20202020 resources/. \n+ 0x0114a2b0 20207c2d 2d20736e 61706c65 742d6b69 |-- snaplet-ki\n+ 0x0114a2c0 6c6c6572 6170702e 63616261 6c0a2020 llerapp.cabal. \n+ 0x0114a2d0 20202020 7c2d2d20 7372632f 0a0a416c |-- src/..Al\n+ 0x0114a2e0 6c206f66 20746865 2066696c 65732061 l of the files a\n+ 0x0114a2f0 6e642064 69726563 746f7269 6573206c nd directories l\n+ 0x0114a300 69737465 64206162 6f766520 756e6465 isted above unde\n+ 0x0114a310 7220666f 6f736e61 706c6574 2f207769 r foosnaplet/ wi\n+ 0x0114a320 6c6c2062 6520696e 0a726573 6f757263 ll be in.resourc\n+ 0x0114a330 65732f2e 2020536f 6d657768 65726520 es/. Somewhere \n+ 0x0114a340 696e2074 68652063 6f646520 796f7520 in the code you \n+ 0x0114a350 77696c6c 20646566 696e6520 616e2069 will define an i\n+ 0x0114a360 6e697469 616c697a 65722066 6f722074 nitializer for t\n+ 0x0114a370 68650a73 6e61706c 65742074 68617420 he.snaplet that \n+ 0x0114a380 77696c6c 206c6f6f 6b206c69 6b652074 will look like t\n+ 0x0114a390 6869733a 0a0a2020 20206b69 6c6c6572 his:.. killer\n+ 0x0114a3a0 496e6974 203d206d 616b6553 6e61706c Init = makeSnapl\n+ 0x0114a3b0 65742022 6b696c6c 65726170 70222022 et \"killerapp\" \"\n+ 0x0114a3c0 34322220 284a7573 74206461 74614469 42\" (Just dataDi\n+ 0x0114a3d0 72292024 20646f0a 0a546865 20707269 r) $ do..The pri\n+ 0x0114a3e0 6d617279 2066756e 6374696f 6e206f66 mary function of\n+ 0x0114a3f0 20436162 616c2069 7320746f 20696e73 Cabal is to ins\n+ 0x0114a400 74616c6c 20636f64 652e2020 42757420 tall code. But \n+ 0x0114a410 69742068 61732074 68652061 62696c69 it has the abili\n+ 0x0114a420 74792074 6f0a696e 7374616c 6c206461 ty to.install da\n+ 0x0114a430 74612066 696c6573 20616e64 2070726f ta files and pro\n+ 0x0114a440 76696465 73206120 66756e63 74696f6e vides a function\n+ 0x0114a450 2063616c 6c656420 60676574 44617461 called `getData\n+ 0x0114a460 44697260 20666f72 20726574 72696576 Dir` for retriev\n+ 0x0114a470 696e670a 74686520 6c6f6361 74696f6e ing.the location\n+ 0x0114a480 206f6620 74686573 65206669 6c65732e of these files.\n+ 0x0114a490 20205369 6e636520 69742072 65747572 Since it retur\n+ 0x0114a4a0 6e732061 20646966 66657265 6e742072 ns a different r\n+ 0x0114a4b0 6573756c 74206465 70656e64 696e6720 esult depending \n+ 0x0114a4c0 6f6e0a77 68617420 6d616368 696e6520 on.what machine \n+ 0x0114a4d0 796f7527 72652075 73696e67 2c207468 you're using, th\n+ 0x0114a4e0 65207468 69726420 61726775 6d656e74 e third argument\n+ 0x0114a4f0 20746f20 606d616b 65536e61 706c6574 to `makeSnaplet\n+ 0x0114a500 60206861 7320746f 20626520 604d6179 ` has to be `May\n+ 0x0114a510 62650a28 494f2046 696c6550 61746829 be.(IO FilePath)\n+ 0x0114a520 6020696e 73746561 64206f66 20746865 ` instead of the\n+ 0x0114a530 206d6f72 65206e61 74757261 6c207075 more natural pu\n+ 0x0114a540 72652076 65727369 6f6e2e20 20546f20 re version. To \n+ 0x0114a550 6d616b65 20746869 6e677320 6d6f7265 make things more\n+ 0x0114a560 0a6f7267 616e697a 65642c20 77652075 .organized, we u\n+ 0x0114a570 73652074 68652063 6f6e7665 6e74696f se the conventio\n+ 0x0114a580 6e206f66 20707574 74696e67 20616c6c n of putting all\n+ 0x0114a590 20796f75 7220736e 61706c65 74277320 your snaplet's \n+ 0x0114a5a0 64617461 2066696c 65732069 6e20610a data files in a.\n+ 0x0114a5b0 73756264 69726563 746f7279 2063616c subdirectory cal\n+ 0x0114a5c0 6c656420 7265736f 75726365 732e2020 led resources. \n+ 0x0114a5d0 536f2077 65206e65 65642074 6f206372 So we need to cr\n+ 0x0114a5e0 65617465 20612073 6d616c6c 2066756e eate a small fun\n+ 0x0114a5f0 6374696f 6e207468 61740a61 7070656e ction that.appen\n+ 0x0114a600 64732060 2f726573 6f757263 65736020 ds `/resources` \n+ 0x0114a610 746f2074 68652072 6573756c 74206f66 to the result of\n+ 0x0114a620 20606765 74446174 61446972 602e0a0a `getDataDir`...\n+ 0x0114a630 20202020 696d706f 72742050 61746873 import Paths\n+ 0x0114a640 5f736e61 706c6574 5f6b696c 6c657261 _snaplet_killera\n+ 0x0114a650 70700a20 20202064 61746144 6972203d pp. dataDir =\n+ 0x0114a660 206c6966 744d2028 2b2b222f 7265736f liftM (++\"/reso\n+ 0x0114a670 75726365 73222920 67657444 61746144 urces\") getDataD\n+ 0x0114a680 69720a0a 4966206f 75722070 726f6a65 ir..If our proje\n+ 0x0114a690 63742069 73206e61 6d656420 736e6170 ct is named snap\n+ 0x0114a6a0 6c65742d 6b696c6c 65726170 702c2074 let-killerapp, t\n+ 0x0114a6b0 68652060 67657444 61746144 69726020 he `getDataDir` \n+ 0x0114a6c0 66756e63 74696f6e 2069730a 64656669 function is.defi\n+ 0x0114a6d0 6e656420 696e2074 6865206d 6f64756c ned in the modul\n+ 0x0114a6e0 65205061 7468735f 736e6170 6c65745f e Paths_snaplet_\n+ 0x0114a6f0 6b696c6c 65726170 702c2077 68696368 killerapp, which\n+ 0x0114a700 20776520 68617665 20746f20 696d706f we have to impo\n+ 0x0114a710 72742e20 20546f0a 6d616b65 20657665 rt. To.make eve\n+ 0x0114a720 72797468 696e6720 776f726b 2c20796f rything work, yo\n+ 0x0114a730 75206861 76652074 6f207465 6c6c2043 u have to tell C\n+ 0x0114a740 6162616c 2061626f 75742079 6f757220 abal about your \n+ 0x0114a750 64617461 2066696c 65732062 790a696e data files by.in\n+ 0x0114a760 636c7564 696e6720 61207365 6374696f cluding a sectio\n+ 0x0114a770 6e206c69 6b652074 68652066 6f6c6c6f n like the follo\n+ 0x0114a780 77696e67 20696e20 736e6170 6c65742d wing in snaplet-\n+ 0x0114a790 6b696c6c 65726170 702e6361 62616c3a killerapp.cabal:\n+ 0x0114a7a0 0a0a2020 20206461 74612d66 696c6573 .. data-files\n+ 0x0114a7b0 3a0a2020 20202020 7265736f 75726365 :. resource\n+ 0x0114a7c0 732f6465 76656c2e 6366672c 0a202020 s/devel.cfg,. \n+ 0x0114a7d0 20202072 65736f75 72636573 2f707562 resources/pub\n+ 0x0114a7e0 6c69632f 7374796c 65736865 6574732f lic/stylesheets/\n+ 0x0114a7f0 7374796c 652e6373 732c0a20 20202020 style.css,. \n+ 0x0114a800 20726573 6f757263 65732f73 6e61706c resources/snapl\n+ 0x0114a810 6574732f 68656973 742f7465 6d706c61 ets/heist/templa\n+ 0x0114a820 7465732f 70616765 2e74706c 0a0a4e6f tes/page.tpl..No\n+ 0x0114a830 77207768 656e6576 65722079 6f757220 w whenever your \n+ 0x0114a840 736e6170 6c657420 69732075 7365642c snaplet is used,\n+ 0x0114a850 20697473 2066696c 65737973 74656d20 its filesystem \n+ 0x0114a860 64617461 2077696c 6c206265 20617574 data will be aut\n+ 0x0114a870 6f6d6167 6963616c 6c790a63 6f706965 omagically.copie\n+ 0x0114a880 6420696e 746f2074 6865206c 6f63616c d into the local\n+ 0x0114a890 2070726f 6a656374 20746861 74206973 project that is\n+ 0x0114a8a0 20757369 6e672069 742c2077 68656e65 using it, whene\n+ 0x0114a8b0 76657220 74686520 6170706c 69636174 ver the applicat\n+ 0x0114a8c0 696f6e20 69730a72 756e2061 6e642069 ion is.run and i\n+ 0x0114a8d0 74207365 65732074 68617420 74686520 t sees that the \n+ 0x0114a8e0 736e6170 6c657427 73206469 72656374 snaplet's direct\n+ 0x0114a8f0 6f727920 646f6573 206e6f74 20616c72 ory does not alr\n+ 0x0114a900 65616479 20657869 73742e20 20496620 eady exist. If \n+ 0x0114a910 7468650a 75736572 20757067 72616465 the.user upgrade\n+ 0x0114a920 7320746f 2061206e 65772076 65727369 s to a new versi\n+ 0x0114a930 6f6e206f 66207468 6520736e 61706c65 on of the snaple\n+ 0x0114a940 7420616e 64207468 65206e65 77207665 t and the new ve\n+ 0x0114a950 7273696f 6e206d61 64652063 68616e67 rsion made chang\n+ 0x0114a960 65730a74 6f207468 65206669 6c657379 es.to the filesy\n+ 0x0114a970 7374656d 20726573 6f757263 65732c20 stem resources, \n+ 0x0114a980 74686f73 65207265 736f7572 63657320 those resources \n+ 0x0114a990 77696c6c 204e4f54 20626520 6175746f will NOT be auto\n+ 0x0114a9a0 6d617469 63616c6c 7920636f 70696564 matically copied\n+ 0x0114a9b0 0a696e20 62792064 65666175 6c742e20 .in by default. \n+ 0x0114a9c0 20526573 6f757263 6520696e 7374616c Resource instal\n+ 0x0114a9d0 6c617469 6f6e202a 6f6e6c79 2a206861 lation *only* ha\n+ 0x0114a9e0 7070656e 73207768 656e2074 68652060 ppens when the `\n+ 0x0114a9f0 736e6170 6c657473 2f666f6f 600a6469 snaplets/foo`.di\n+ 0x0114aa00 72656374 6f727920 646f6573 206e6f74 rectory does not\n+ 0x0114aa10 20657869 73742e20 20496620 796f7520 exist. If you \n+ 0x0114aa20 77616e74 20746f20 67657420 74686520 want to get the \n+ 0x0114aa30 6c617465 73742076 65727369 6f6e206f latest version o\n+ 0x0114aa40 66207468 650a6669 6c657379 7374656d f the.filesystem\n+ 0x0114aa50 20726573 6f757263 65732c20 72656d6f resources, remo\n+ 0x0114aa60 76652074 68652060 736e6170 6c657473 ve the `snaplets\n+ 0x0114aa70 2f666f6f 60206469 72656374 6f72792c /foo` directory,\n+ 0x0114aa80 20616e64 20726573 74617274 20796f75 and restart you\n+ 0x0114aa90 720a6170 702e0a00 2e2f7372 632f5475 r.app..../src/Tu\n+ 0x0114aaa0 746f7269 616c2e6c 6873003e 207b2d23 torial.lhs.> {-#\n+ 0x0114aab0 204c414e 47554147 45204f76 65726c6f LANGUAGE Overlo\n+ 0x0114aac0 61646564 53747269 6e677320 232d7d0a adedStrings #-}.\n+ 0x0114aad0 3e206d6f 64756c65 20506172 74322077 > module Part2 w\n+ 0x0114aae0 68657265 0a0a3e20 696d706f 72742020 here..> import \n+ 0x0114aaf0 20202020 20202020 20536e61 702e536e Snap.Sn\n+ 0x0114ab00 61706c65 740a0a3e 20646174 6120466f aplet..> data Fo\n+ 0x0114ab10 6f203d20 466f6f0a 3e0a3e20 64617461 o = Foo.>.> data\n+ 0x0114ab20 20426172 203d2042 61720a3e 0a3e2066 Bar = Bar.>.> f\n+ 0x0114ab30 6f6f496e 6974203a 3a20536e 61706c65 ooInit :: Snaple\n+ 0x0114ab40 74496e69 74206220 466f6f0a 3e20666f tInit b Foo.> fo\n+ 0x0114ab50 6f496e69 74203d20 6d616b65 536e6170 oInit = makeSnap\n+ 0x0114ab60 6c657420 22666f6f 22202246 6f6f2073 let \"foo\" \"Foo s\n+ 0x0114ab70 6e61706c 65742220 4e6f7468 696e6720 naplet\" Nothing \n+ 0x0114ab80 2420646f 0a3e2020 20202072 65747572 $ do.> retur\n+ 0x0114ab90 6e20466f 6f0a3e0a 3e206261 72496e69 n Foo.>.> barIni\n+ 0x0114aba0 74203a3a 20536e61 706c6574 4c656e73 t :: SnapletLens\n+ 0x0114abb0 20622046 6f6f202d 3e20536e 61706c65 b Foo -> Snaple\n+ 0x0114abc0 74496e69 74206220 4261720a 3e206261 tInit b Bar.> ba\n+ 0x0114abd0 72496e69 74205f68 203d206d 616b6553 rInit _h = makeS\n+ 0x0114abe0 6e61706c 65742022 62617222 20224261 naplet \"bar\" \"Ba\n+ 0x0114abf0 7220736e 61706c65 7422204e 6f746869 r snaplet\" Nothi\n+ 0x0114ac00 6e672024 20646f0a 3e202020 20207265 ng $ do.> re\n+ 0x0114ac10 7475726e 20426172 0a002e2f 7372632f turn Bar.../src/\n+ 0x0114ac20 50617274 322e6c68 73004e61 6d653a20 Part2.lhs.Name: \n 0x0114ac30 20202020 20202020 20202020 20202070 p\n 0x0114ac40 726f6a6e 616d650a 56657273 696f6e3a rojname.Version:\n 0x0114ac50 20202020 20202020 20202020 20302e31 0.1\n 0x0114ac60 0a53796e 6f707369 733a2020 20202020 .Synopsis: \n 0x0114ac70 20202020 20205072 6f6a6563 74205379 Project Sy\n 0x0114ac80 6e6f7073 69732048 6572650a 44657363 nopsis Here.Desc\n 0x0114ac90 72697074 696f6e3a 20202020 20202020 ription: \n@@ -1217,835 +1217,835 @@\n 0x0114b020 20202020 20202020 202d666e 6f2d7761 -fno-wa\n 0x0114b030 726e2d75 6e757365 642d646f 2d62696e rn-unused-do-bin\n 0x0114b040 640a2020 656c7365 0a202020 20676863 d. else. ghc\n 0x0114b050 2d6f7074 696f6e73 3a202d74 68726561 -options: -threa\n 0x0114b060 64656420 2d57616c 6c202d66 7761726e ded -Wall -fwarn\n 0x0114b070 2d746162 73202d66 756e626f 782d7374 -tabs -funbox-st\n 0x0114b080 72696374 2d666965 6c647320 2d4f320a rict-fields -O2.\n- 0x0114b090 007b2d23 204c414e 47554147 45205465 .{-# LANGUAGE Te\n- 0x0114b0a0 6d706c61 74654861 736b656c 6c20232d mplateHaskell #-\n- 0x0114b0b0 7d0a0a2d 2d2d2d2d 2d2d2d2d 2d2d2d2d }..-------------\n+ 0x0114b090 007b2d23 204c414e 47554147 45204f76 .{-# LANGUAGE Ov\n+ 0x0114b0a0 65726c6f 61646564 53747269 6e677320 erloadedStrings \n+ 0x0114b0b0 232d7d0a 0a2d2d2d 2d2d2d2d 2d2d2d2d #-}..-----------\n 0x0114b0c0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n 0x0114b0d0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n 0x0114b0e0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n 0x0114b0f0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b100 2d0a2d2d 207c2054 68697320 6d6f6475 -.-- | This modu\n- 0x0114b110 6c652064 6566696e 6573206f 75722061 le defines our a\n- 0x0114b120 70706c69 63617469 6f6e2773 20737461 pplication's sta\n- 0x0114b130 74652074 79706520 616e6420 616e2061 te type and an a\n- 0x0114b140 6c696173 20666f72 20697473 0a2d2d20 lias for its.-- \n- 0x0114b150 68616e64 6c657220 6d6f6e61 642e0a6d handler monad..m\n- 0x0114b160 6f64756c 65204170 706c6963 6174696f odule Applicatio\n- 0x0114b170 6e207768 6572650a 0a2d2d2d 2d2d2d2d n where..-------\n- 0x0114b180 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b190 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b1a0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b1b0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b1c0 2d2d2d2d 2d2d2d0a 696d706f 72742043 -------.import C\n- 0x0114b1d0 6f6e7472 6f6c2e4c 656e730a 696d706f ontrol.Lens.impo\n- 0x0114b1e0 72742053 6e61702e 536e6170 6c65740a rt Snap.Snaplet.\n- 0x0114b1f0 696d706f 72742053 6e61702e 536e6170 import Snap.Snap\n- 0x0114b200 6c65742e 48656973 740a696d 706f7274 let.Heist.import\n- 0x0114b210 20536e61 702e536e 61706c65 742e4175 Snap.Snaplet.Au\n- 0x0114b220 74680a69 6d706f72 7420536e 61702e53 th.import Snap.S\n- 0x0114b230 6e61706c 65742e53 65737369 6f6e0a0a naplet.Session..\n- 0x0114b240 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b250 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b260 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b270 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b280 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d0a64 --------------.d\n- 0x0114b290 61746120 41707020 3d204170 700a2020 ata App = App. \n- 0x0114b2a0 20207b20 5f686569 7374203a 3a20536e { _heist :: Sn\n- 0x0114b2b0 61706c65 74202848 65697374 20417070 aplet (Heist App\n- 0x0114b2c0 290a2020 20202c20 5f736573 73203a3a ). , _sess ::\n- 0x0114b2d0 20536e61 706c6574 20536573 73696f6e Snaplet Session\n- 0x0114b2e0 4d616e61 6765720a 20202020 2c205f61 Manager. , _a\n- 0x0114b2f0 75746820 3a3a2053 6e61706c 65742028 uth :: Snaplet (\n- 0x0114b300 41757468 4d616e61 67657220 41707029 AuthManager App)\n- 0x0114b310 0a202020 207d0a0a 6d616b65 4c656e73 . }..makeLens\n- 0x0114b320 65732027 27417070 0a0a696e 7374616e es ''App..instan\n- 0x0114b330 63652048 61734865 69737420 41707020 ce HasHeist App \n- 0x0114b340 77686572 650a2020 20206865 6973744c where. heistL\n- 0x0114b350 656e7320 3d207375 62536e61 706c6574 ens = subSnaplet\n- 0x0114b360 20686569 73740a0a 0a2d2d2d 2d2d2d2d heist...-------\n- 0x0114b370 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b380 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b390 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b3a0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b3b0 2d2d2d2d 2d2d2d0a 74797065 20417070 -------.type App\n- 0x0114b3c0 48616e64 6c657220 3d204861 6e646c65 Handler = Handle\n- 0x0114b3d0 72204170 70204170 700a0a0a 002e2f73 r App App...../s\n- 0x0114b3e0 72632f41 70706c69 63617469 6f6e2e68 rc/Application.h\n- 0x0114b3f0 73007b2d 23204c41 4e475541 47452043 s.{-# LANGUAGE C\n- 0x0114b400 50502020 20202020 20202020 20202023 PP #\n- 0x0114b410 2d7d0a7b 2d23204c 414e4755 41474520 -}.{-# LANGUAGE \n- 0x0114b420 54656d70 6c617465 4861736b 656c6c20 TemplateHaskell \n- 0x0114b430 232d7d0a 0a7b2d0a 0a4e4f54 453a2044 #-}..{-..NOTE: D\n- 0x0114b440 6f6e2774 206d6f64 69667920 74686973 on't modify this\n- 0x0114b450 2066696c 6520756e 6c657373 20796f75 file unless you\n- 0x0114b460 206b6e6f 77207768 61742079 6f752061 know what you a\n- 0x0114b470 72652064 6f696e67 2e202049 6620796f re doing. If yo\n- 0x0114b480 75206172 650a6e65 7720746f 20736e61 u are.new to sna\n- 0x0114b490 702c2073 74617274 20776974 68205369 p, start with Si\n- 0x0114b4a0 74652e68 7320616e 64204170 706c6963 te.hs and Applic\n- 0x0114b4b0 6174696f 6e2e6873 2e202054 68697320 ation.hs. This \n- 0x0114b4c0 66696c65 20636f6e 7461696e 730a626f file contains.bo\n- 0x0114b4d0 696c6572 706c6174 65206e65 65646564 ilerplate needed\n- 0x0114b4e0 20666f72 2064796e 616d6963 2072656c for dynamic rel\n- 0x0114b4f0 6f616469 6e672061 6e642069 73206e6f oading and is no\n- 0x0114b500 74206d65 616e7420 666f7220 67656e65 t meant for gene\n- 0x0114b510 72616c0a 636f6e73 756d7074 696f6e2e ral.consumption.\n- 0x0114b520 0a0a4f63 63617369 6f6e616c 6c792069 ..Occasionally i\n- 0x0114b530 66207765 206d6f64 69667920 74686520 f we modify the \n- 0x0114b540 77617920 74686520 64796e61 6d696320 way the dynamic \n- 0x0114b550 72656c6f 61646572 20776f72 6b732061 reloader works a\n- 0x0114b560 6e642079 6f752077 616e7420 746f0a75 nd you want to.u\n- 0x0114b570 70677261 64652c20 796f7520 6d696768 pgrade, you migh\n- 0x0114b580 74206861 76652074 6f207377 6170206f t have to swap o\n- 0x0114b590 75742074 68697320 66696c65 20666f72 ut this file for\n- 0x0114b5a0 2061206e 65776572 20766572 73696f6e a newer version\n- 0x0114b5b0 2e202042 75742069 6e0a6d6f 73742063 . But in.most c\n- 0x0114b5c0 61736573 20796f75 276c6c20 6e657665 ases you'll neve\n- 0x0114b5d0 72206e65 65642074 6f206d6f 64696679 r need to modify\n- 0x0114b5e0 20746869 7320636f 64652e0a 0a2d7d0a this code...-}.\n- 0x0114b5f0 6d6f6475 6c65204d 61696e20 77686572 module Main wher\n- 0x0114b600 650a0a2d 2d2d2d2d 2d2d2d2d 2d2d2d2d e..-------------\n- 0x0114b610 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b620 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b630 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b640 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b650 2d0a696d 706f7274 20202020 20202020 -.import \n- 0x0114b660 20202043 6f6e7472 6f6c2e45 78636570 Control.Excep\n- 0x0114b670 74696f6e 2028536f 6d654578 63657074 tion (SomeExcept\n- 0x0114b680 696f6e2c 20747279 290a696d 706f7274 ion, try).import\n- 0x0114b690 20717561 6c696669 65642044 6174612e qualified Data.\n- 0x0114b6a0 54657874 20617320 540a696d 706f7274 Text as T.import\n- 0x0114b6b0 20202020 20202020 20202053 6e61702e Snap.\n- 0x0114b6c0 48747470 2e536572 7665720a 696d706f Http.Server.impo\n- 0x0114b6d0 72742020 20202020 20202020 20536e61 rt Sna\n- 0x0114b6e0 702e536e 61706c65 740a696d 706f7274 p.Snaplet.import\n- 0x0114b6f0 20202020 20202020 20202053 6e61702e Snap.\n- 0x0114b700 536e6170 6c65742e 436f6e66 69670a69 Snaplet.Config.i\n- 0x0114b710 6d706f72 74202020 20202020 20202020 mport \n- 0x0114b720 536e6170 2e436f72 650a696d 706f7274 Snap.Core.import\n- 0x0114b730 20202020 20202020 20202053 79737465 Syste\n- 0x0114b740 6d2e494f 0a696d70 6f727420 20202020 m.IO.import \n- 0x0114b750 20202020 20205369 74650a0a 23696664 Site..#ifd\n- 0x0114b760 65662044 4556454c 4f504d45 4e540a69 ef DEVELOPMENT.i\n- 0x0114b770 6d706f72 74202020 20202020 20202020 mport \n- 0x0114b780 536e6170 2e4c6f61 6465722e 44796e61 Snap.Loader.Dyna\n- 0x0114b790 6d69630a 23656c73 650a696d 706f7274 mic.#else.import\n- 0x0114b7a0 20202020 20202020 20202053 6e61702e Snap.\n- 0x0114b7b0 4c6f6164 65722e53 74617469 630a2365 Loader.Static.#e\n- 0x0114b7c0 6e646966 0a0a0a2d 2d2d2d2d 2d2d2d2d ndif...---------\n- 0x0114b7d0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b7e0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b7f0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b100 2d2d2d0a 2d2d207c 20546869 73206d6f ---.-- | This mo\n+ 0x0114b110 64756c65 20697320 77686572 6520616c dule is where al\n+ 0x0114b120 6c207468 6520726f 75746573 20616e64 l the routes and\n+ 0x0114b130 2068616e 646c6572 73206172 65206465 handlers are de\n+ 0x0114b140 66696e65 6420666f 7220796f 75720a2d fined for your.-\n+ 0x0114b150 2d207369 74652e20 54686520 27617070 - site. The 'app\n+ 0x0114b160 27206675 6e637469 6f6e2069 73207468 ' function is th\n+ 0x0114b170 6520696e 69746961 6c697a65 72207468 e initializer th\n+ 0x0114b180 61742063 6f6d6269 6e657320 65766572 at combines ever\n+ 0x0114b190 79746869 6e670a2d 2d20746f 67657468 ything.-- togeth\n+ 0x0114b1a0 65722061 6e642069 73206578 706f7274 er and is export\n+ 0x0114b1b0 65642062 79207468 6973206d 6f64756c ed by this modul\n+ 0x0114b1c0 652e0a6d 6f64756c 65205369 74650a20 e..module Site. \n+ 0x0114b1d0 20282061 70700a20 20292077 68657265 ( app. ) where\n+ 0x0114b1e0 0a0a2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ..--------------\n+ 0x0114b1f0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b200 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b210 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b220 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b230 0a696d70 6f727420 20202020 20202020 .import \n+ 0x0114b240 2020436f 6e74726f 6c2e4170 706c6963 Control.Applic\n+ 0x0114b250 61746976 650a696d 706f7274 20202020 ative.import \n+ 0x0114b260 20202020 20202044 6174612e 42797465 Data.Byte\n+ 0x0114b270 53747269 6e672028 42797465 53747269 String (ByteStri\n+ 0x0114b280 6e67290a 696d706f 72742020 20202020 ng).import \n+ 0x0114b290 20202020 20446174 612e4d61 702e5379 Data.Map.Sy\n+ 0x0114b2a0 6e746178 20282823 2329290a 696d706f ntax ((##)).impo\n+ 0x0114b2b0 72742071 75616c69 66696564 20446174 rt qualified Dat\n+ 0x0114b2c0 612e5465 78742061 7320540a 696d706f a.Text as T.impo\n+ 0x0114b2d0 72742020 20202020 20202020 20536e61 rt Sna\n+ 0x0114b2e0 702e436f 72650a69 6d706f72 74202020 p.Core.import \n+ 0x0114b2f0 20202020 20202020 536e6170 2e536e61 Snap.Sna\n+ 0x0114b300 706c6574 0a696d70 6f727420 20202020 plet.import \n+ 0x0114b310 20202020 2020536e 61702e53 6e61706c Snap.Snapl\n+ 0x0114b320 65742e41 7574680a 696d706f 72742020 et.Auth.import \n+ 0x0114b330 20202020 20202020 20536e61 702e536e Snap.Sn\n+ 0x0114b340 61706c65 742e4175 74682e42 61636b65 aplet.Auth.Backe\n+ 0x0114b350 6e64732e 4a736f6e 46696c65 0a696d70 nds.JsonFile.imp\n+ 0x0114b360 6f727420 20202020 20202020 2020536e ort Sn\n+ 0x0114b370 61702e53 6e61706c 65742e48 65697374 ap.Snaplet.Heist\n+ 0x0114b380 0a696d70 6f727420 20202020 20202020 .import \n+ 0x0114b390 2020536e 61702e53 6e61706c 65742e53 Snap.Snaplet.S\n+ 0x0114b3a0 65737369 6f6e2e42 61636b65 6e64732e ession.Backends.\n+ 0x0114b3b0 436f6f6b 69655365 7373696f 6e0a696d CookieSession.im\n+ 0x0114b3c0 706f7274 20202020 20202020 20202053 port S\n+ 0x0114b3d0 6e61702e 5574696c 2e46696c 65536572 nap.Util.FileSer\n+ 0x0114b3e0 76650a69 6d706f72 74207175 616c6966 ve.import qualif\n+ 0x0114b3f0 69656420 48656973 742e496e 74657270 ied Heist.Interp\n+ 0x0114b400 72657465 64206173 20490a2d 2d2d2d2d reted as I.-----\n+ 0x0114b410 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b420 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b430 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b440 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b450 2d2d2d2d 2d2d2d2d 2d0a696d 706f7274 ---------.import\n+ 0x0114b460 20202020 20202020 20202041 70706c69 Appli\n+ 0x0114b470 63617469 6f6e0a0a 0a2d2d2d 2d2d2d2d cation...-------\n+ 0x0114b480 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b490 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b4a0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b4b0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b4c0 2d2d2d2d 2d2d2d0a 2d2d207c 2052656e -------.-- | Ren\n+ 0x0114b4d0 64657220 6c6f6769 6e20666f 726d0a68 der login form.h\n+ 0x0114b4e0 616e646c 654c6f67 696e203a 3a204d61 andleLogin :: Ma\n+ 0x0114b4f0 79626520 542e5465 7874202d 3e204861 ybe T.Text -> Ha\n+ 0x0114b500 6e646c65 72204170 70202841 7574684d ndler App (AuthM\n+ 0x0114b510 616e6167 65722041 70702920 28290a68 anager App) ().h\n+ 0x0114b520 616e646c 654c6f67 696e2061 75746845 andleLogin authE\n+ 0x0114b530 72726f72 203d2068 65697374 4c6f6361 rror = heistLoca\n+ 0x0114b540 6c202849 2e62696e 6453706c 69636573 l (I.bindSplices\n+ 0x0114b550 20657272 73292024 2072656e 64657220 errs) $ render \n+ 0x0114b560 226c6f67 696e220a 20207768 6572650a \"login\". where.\n+ 0x0114b570 20202020 65727273 203d206d 61796265 errs = maybe\n+ 0x0114b580 206d656d 70747920 73706c69 63652061 mempty splice a\n+ 0x0114b590 75746845 72726f72 0a202020 2073706c uthError. spl\n+ 0x0114b5a0 69636520 65727220 3d20226c 6f67696e ice err = \"login\n+ 0x0114b5b0 4572726f 72222023 2320492e 74657874 Error\" ## I.text\n+ 0x0114b5c0 53706c69 63652065 72720a0a 0a2d2d2d Splice err...---\n+ 0x0114b5d0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b5e0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b5f0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b600 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b610 2d2d2d2d 2d2d2d2d 2d2d2d0a 2d2d207c -----------.-- |\n+ 0x0114b620 2048616e 646c6520 6c6f6769 6e207375 Handle login su\n+ 0x0114b630 626d6974 0a68616e 646c654c 6f67696e bmit.handleLogin\n+ 0x0114b640 5375626d 6974203a 3a204861 6e646c65 Submit :: Handle\n+ 0x0114b650 72204170 70202841 7574684d 616e6167 r App (AuthManag\n+ 0x0114b660 65722041 70702920 28290a68 616e646c er App) ().handl\n+ 0x0114b670 654c6f67 696e5375 626d6974 203d0a20 eLoginSubmit =. \n+ 0x0114b680 2020206c 6f67696e 55736572 20226c6f loginUser \"lo\n+ 0x0114b690 67696e22 20227061 7373776f 72642220 gin\" \"password\" \n+ 0x0114b6a0 4e6f7468 696e670a 20202020 20202020 Nothing. \n+ 0x0114b6b0 20202020 2020285c 5f202d3e 2068616e (\\_ -> han\n+ 0x0114b6c0 646c654c 6f67696e 20657272 29202872 dleLogin err) (r\n+ 0x0114b6d0 65646972 65637420 222f2229 0a202077 edirect \"/\"). w\n+ 0x0114b6e0 68657265 0a202020 20657272 203d204a here. err = J\n+ 0x0114b6f0 75737420 22556e6b 6e6f776e 20757365 ust \"Unknown use\n+ 0x0114b700 72206f72 20706173 73776f72 64220a0a r or password\"..\n+ 0x0114b710 0a2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d .---------------\n+ 0x0114b720 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b730 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b740 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b750 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d0a ---------------.\n+ 0x0114b760 2d2d207c 204c6f67 73206f75 7420616e -- | Logs out an\n+ 0x0114b770 64207265 64697265 63747320 74686520 d redirects the \n+ 0x0114b780 75736572 20746f20 74686520 73697465 user to the site\n+ 0x0114b790 20696e64 65782e0a 68616e64 6c654c6f index..handleLo\n+ 0x0114b7a0 676f7574 203a3a20 48616e64 6c657220 gout :: Handler \n+ 0x0114b7b0 41707020 28417574 684d616e 61676572 App (AuthManager\n+ 0x0114b7c0 20417070 29202829 0a68616e 646c654c App) ().handleL\n+ 0x0114b7d0 6f676f75 74203d20 6c6f676f 7574203e ogout = logout >\n+ 0x0114b7e0 3e207265 64697265 63742022 2f220a0a > redirect \"/\"..\n+ 0x0114b7f0 0a2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d .---------------\n 0x0114b800 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114b810 2d2d2d2d 2d0a2d2d 207c2054 68697320 -----.-- | This \n- 0x0114b820 69732074 68652065 6e747279 20706f69 is the entry poi\n- 0x0114b830 6e742066 6f722074 68697320 77656220 nt for this web \n- 0x0114b840 73657276 65722061 70706c69 63617469 server applicati\n- 0x0114b850 6f6e2e20 49742073 7570706f 7274730a on. It supports.\n- 0x0114b860 2d2d2065 6173696c 79207377 69746368 -- easily switch\n- 0x0114b870 696e6720 62657477 65656e20 696e7465 ing between inte\n- 0x0114b880 72707265 74696e67 20736f75 72636520 rpreting source \n- 0x0114b890 616e6420 72756e6e 696e6720 73746174 and running stat\n- 0x0114b8a0 6963616c 6c792063 6f6d7069 6c65640a ically compiled.\n- 0x0114b8b0 2d2d2063 6f64652e 0a2d2d0a 2d2d2049 -- code..--.-- I\n- 0x0114b8c0 6e206569 74686572 206d6f64 652c2074 n either mode, t\n- 0x0114b8d0 68652067 656e6572 61746564 2070726f he generated pro\n- 0x0114b8e0 6772616d 2073686f 756c6420 62652072 gram should be r\n- 0x0114b8f0 756e2066 726f6d20 74686520 726f6f74 un from the root\n- 0x0114b900 206f6620 7468650a 2d2d2070 726f6a65 of the.-- proje\n- 0x0114b910 63742074 7265652e 20576865 6e206974 ct tree. When it\n- 0x0114b920 20697320 72756e2c 20697420 6c6f6361 is run, it loca\n- 0x0114b930 74657320 69747320 74656d70 6c617465 tes its template\n- 0x0114b940 732c2073 74617469 6320636f 6e74656e s, static conten\n- 0x0114b950 742c2061 6e640a2d 2d20736f 75726365 t, and.-- source\n- 0x0114b960 2066696c 65732069 6e206465 76656c6f files in develo\n- 0x0114b970 706d656e 74206d6f 64652c20 72656c61 pment mode, rela\n- 0x0114b980 74697665 20746f20 74686520 63757272 tive to the curr\n- 0x0114b990 656e7420 776f726b 696e6720 64697265 ent working dire\n- 0x0114b9a0 63746f72 792e0a2d 2d0a2d2d 20576865 ctory..--.-- Whe\n- 0x0114b9b0 6e20636f 6d70696c 65642077 69746820 n compiled with \n- 0x0114b9c0 74686520 64657665 6c6f706d 656e7420 the development \n- 0x0114b9d0 666c6167 2c206f6e 6c792063 68616e67 flag, only chang\n- 0x0114b9e0 65732074 6f207468 65206c69 62726172 es to the librar\n- 0x0114b9f0 6965732c 20796f75 720a2d2d 20636162 ies, your.-- cab\n- 0x0114ba00 616c2066 696c652c 206f7220 74686973 al file, or this\n- 0x0114ba10 2066696c 65207368 6f756c64 20726571 file should req\n- 0x0114ba20 75697265 20612072 65636f6d 70696c65 uire a recompile\n- 0x0114ba30 20746f20 62652070 69636b65 64207570 to be picked up\n- 0x0114ba40 2e0a2d2d 20457665 72797468 696e6720 ..-- Everything \n- 0x0114ba50 656c7365 20697320 696e7465 72707265 else is interpre\n- 0x0114ba60 74656420 61742072 756e7469 6d652e20 ted at runtime. \n- 0x0114ba70 54686572 65206172 65206120 66657720 There are a few \n- 0x0114ba80 636f6e73 65717565 6e636573 206f660a consequences of.\n- 0x0114ba90 2d2d2074 6869732e 0a2d2d0a 2d2d2046 -- this..--.-- F\n- 0x0114baa0 69727374 2c207468 69732069 73206d75 irst, this is mu\n- 0x0114bab0 63682073 6c6f7765 722e2052 756e6e69 ch slower. Runni\n- 0x0114bac0 6e672074 68652069 6e746572 70726574 ng the interpret\n- 0x0114bad0 65722074 616b6573 20612073 69676e69 er takes a signi\n- 0x0114bae0 66696361 6e740a2d 2d206368 756e6b20 ficant.-- chunk \n- 0x0114baf0 6f662074 696d6520 28612063 6f75706c of time (a coupl\n- 0x0114bb00 65207465 6e746873 206f6620 61207365 e tenths of a se\n- 0x0114bb10 636f6e64 206f6e20 74686520 61757468 cond on the auth\n- 0x0114bb20 6f722773 206d6163 68696e65 2c206174 or's machine, at\n- 0x0114bb30 20746869 730a2d2d 2074696d 65292c20 this.-- time), \n- 0x0114bb40 72656761 72646c65 7373206f 66207468 regardless of th\n- 0x0114bb50 65207369 6d706c69 63697479 206f6620 e simplicity of \n- 0x0114bb60 74686520 6c6f6164 65642063 6f64652e the loaded code.\n- 0x0114bb70 20496e20 6f726465 7220746f 0a2d2d20 In order to.-- \n- 0x0114bb80 7265636f 6d70696c 6520616e 64207265 recompile and re\n- 0x0114bb90 2d6c6f61 64207365 72766572 20737461 -load server sta\n- 0x0114bba0 74652061 7320696e 66726571 75656e74 te as infrequent\n- 0x0114bbb0 6c792061 7320706f 73736962 6c652c20 ly as possible, \n- 0x0114bbc0 74686520 736f7572 63650a2d 2d206469 the source.-- di\n- 0x0114bbd0 72656374 6f726965 73206172 65207761 rectories are wa\n- 0x0114bbe0 74636865 6420666f 72207570 64617465 tched for update\n- 0x0114bbf0 732c2061 73206172 6520616e 79206578 s, as are any ex\n- 0x0114bc00 74726120 64697265 63746f72 69657320 tra directories \n- 0x0114bc10 73706563 69666965 640a2d2d 2062656c specified.-- bel\n- 0x0114bc20 6f772e0a 2d2d0a2d 2d205365 636f6e64 ow..--.-- Second\n- 0x0114bc30 2c207468 65206765 6e657261 74656420 , the generated \n- 0x0114bc40 73657276 65722062 696e6172 79206973 server binary is\n- 0x0114bc50 204d5543 48206c61 72676572 2c207369 MUCH larger, si\n- 0x0114bc60 6e636520 6974206c 696e6b73 20696e20 nce it links in \n- 0x0114bc70 7468650a 2d2d2047 48432041 50492028 the.-- GHC API (\n- 0x0114bc80 76696120 74686520 68696e74 206c6962 via the hint lib\n- 0x0114bc90 72617279 292e0a2d 2d0a2d2d 20546869 rary)..--.-- Thi\n- 0x0114bca0 72642c20 616e6420 74686520 72656173 rd, and the reas\n- 0x0114bcb0 6f6e2079 6f752077 6f756c64 20657665 on you would eve\n- 0x0114bcc0 72207761 6e742074 6f206163 7475616c r want to actual\n- 0x0114bcd0 6c792063 6f6d7069 6c652077 6974680a ly compile with.\n- 0x0114bce0 2d2d2064 6576656c 6f706d65 6e74206d -- development m\n- 0x0114bcf0 6f64652c 20697320 74686174 20697420 ode, is that it \n- 0x0114bd00 656e6162 6c657320 61206661 73746572 enables a faster\n- 0x0114bd10 20646576 656c6f70 6d656e74 20637963 development cyc\n- 0x0114bd20 6c652e20 596f7520 63616e0a 2d2d2073 le. You can.-- s\n- 0x0114bd30 696d706c 79206564 69742061 2066696c imply edit a fil\n- 0x0114bd40 652c2073 61766520 796f7572 20636861 e, save your cha\n- 0x0114bd50 6e676573 2c20616e 64206869 74207265 nges, and hit re\n- 0x0114bd60 6c6f6164 20746f20 73656520 796f7572 load to see your\n- 0x0114bd70 20636861 6e676573 0a2d2d20 7265666c changes.-- refl\n- 0x0114bd80 65637465 6420696d 6d656469 6174656c ected immediatel\n- 0x0114bd90 792e0a2d 2d0a2d2d 20576865 6e207468 y..--.-- When th\n- 0x0114bda0 69732069 7320636f 6d70696c 65642077 is is compiled w\n- 0x0114bdb0 6974686f 75742074 68652064 6576656c ithout the devel\n- 0x0114bdc0 6f706d65 6e742066 6c61672c 20616c6c opment flag, all\n- 0x0114bdd0 20746865 20616374 696f6e73 20617265 the actions are\n- 0x0114bde0 0a2d2d20 73746174 6963616c 6c792063 .-- statically c\n- 0x0114bdf0 6f6d7069 6c656420 696e2e20 54686973 ompiled in. This\n- 0x0114be00 20726573 756c7473 20696e20 66617374 results in fast\n- 0x0114be10 65722065 78656375 74696f6e 2c206120 er execution, a \n- 0x0114be20 736d616c 6c657220 62696e61 72790a2d smaller binary.-\n- 0x0114be30 2d207369 7a652c20 616e6420 68617669 - size, and havi\n- 0x0114be40 6e672074 6f207265 636f6d70 696c6520 ng to recompile \n- 0x0114be50 74686520 73657276 65722066 6f722061 the server for a\n- 0x0114be60 6e792063 6f646520 6368616e 67652e0a ny code change..\n- 0x0114be70 2d2d0a6d 61696e20 3a3a2049 4f202829 --.main :: IO ()\n- 0x0114be80 0a6d6169 6e203d20 646f0a20 2020202d .main = do. -\n- 0x0114be90 2d204465 70656e64 696e6720 6f6e2074 - Depending on t\n- 0x0114bea0 68652076 65727369 6f6e206f 66206c6f he version of lo\n- 0x0114beb0 6164536e 61705448 20696e20 73636f70 adSnapTH in scop\n- 0x0114bec0 652c2074 68697320 65697468 65722065 e, this either e\n- 0x0114bed0 6e61626c 65730a20 2020202d 2d206479 nables. -- dy\n- 0x0114bee0 6e616d69 63207265 6c6f6164 696e672c namic reloading,\n- 0x0114bef0 206f7220 636f6d70 696c6573 20697420 or compiles it \n- 0x0114bf00 77697468 6f75742e 20546865 206c6173 without. The las\n- 0x0114bf10 74206172 67756d65 6e742074 6f0a2020 t argument to. \n- 0x0114bf20 20202d2d 206c6f61 64536e61 70544820 -- loadSnapTH \n- 0x0114bf30 69732061 206c6973 74206f66 20616464 is a list of add\n- 0x0114bf40 6974696f 6e616c20 64697265 63746f72 itional director\n- 0x0114bf50 69657320 746f2077 61746368 20666f72 ies to watch for\n- 0x0114bf60 20636861 6e676573 20746f0a 20202020 changes to. \n- 0x0114bf70 2d2d2074 72696767 65722072 656c6f61 -- trigger reloa\n- 0x0114bf80 64732069 6e206465 76656c6f 706d656e ds in developmen\n- 0x0114bf90 74206d6f 64652e20 49742064 6f65736e t mode. It doesn\n- 0x0114bfa0 2774206e 65656420 746f2069 6e636c75 't need to inclu\n- 0x0114bfb0 64652073 6f757263 650a2020 20202d2d de source. --\n- 0x0114bfc0 20646972 6563746f 72696573 2c207468 directories, th\n- 0x0114bfd0 6f736520 61726520 7069636b 65642075 ose are picked u\n- 0x0114bfe0 70206175 746f6d61 74696361 6c6c7920 p automatically \n- 0x0114bff0 62792074 68652073 706c6963 652e0a20 by the splice.. \n- 0x0114c000 20202028 636f6e66 2c207369 74652c20 (conf, site, \n- 0x0114c010 636c6561 6e757029 203c2d20 24286c6f cleanup) <- $(lo\n- 0x0114c020 6164536e 61705448 205b7c20 67657443 adSnapTH [| getC\n- 0x0114c030 6f6e6620 7c5d0a20 20202020 20202020 onf |]. \n- 0x0114c040 20202020 20202020 20202020 20202020 \n- 0x0114c050 20202020 20202020 20202020 20202020 \n- 0x0114c060 20276765 74416374 696f6e73 0a202020 'getActions. \n- 0x0114c070 20202020 20202020 20202020 20202020 \n- 0x0114c080 20202020 20202020 20202020 20202020 \n- 0x0114c090 20202020 2020205b 22736e61 706c6574 [\"snaplet\n- 0x0114c0a0 732f6865 6973742f 74656d70 6c617465 s/heist/template\n- 0x0114c0b0 73225d29 0a0a2020 20205f20 3c2d2074 s\"]).. _ <- t\n- 0x0114c0c0 72792024 20687474 70536572 76652063 ry $ httpServe c\n- 0x0114c0d0 6f6e6620 73697465 203a3a20 494f2028 onf site :: IO (\n- 0x0114c0e0 45697468 65722053 6f6d6545 78636570 Either SomeExcep\n- 0x0114c0f0 74696f6e 20282929 0a202020 20636c65 tion ()). cle\n- 0x0114c100 616e7570 0a0a0a2d 2d2d2d2d 2d2d2d2d anup...---------\n- 0x0114c110 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114c120 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114c130 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114c140 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114c150 2d2d2d2d 2d0a2d2d 207c2054 68697320 -----.-- | This \n- 0x0114c160 61637469 6f6e206c 6f616473 20746865 action loads the\n- 0x0114c170 20636f6e 66696720 75736564 20627920 config used by \n- 0x0114c180 74686973 20617070 6c696361 74696f6e this application\n- 0x0114c190 2e205468 65206c6f 61646564 20636f6e . The loaded con\n- 0x0114c1a0 6669670a 2d2d2069 73207265 7475726e fig.-- is return\n- 0x0114c1b0 65642061 73207468 65206669 72737420 ed as the first \n- 0x0114c1c0 656c656d 656e7420 6f662074 68652074 element of the t\n- 0x0114c1d0 75706c65 2070726f 64756365 64206279 uple produced by\n- 0x0114c1e0 20746865 206c6f61 64536e61 7054480a the loadSnapTH.\n- 0x0114c1f0 2d2d2053 706c6963 652e2054 68652074 -- Splice. The t\n- 0x0114c200 79706520 6973206e 6f742073 6f6c6964 ype is not solid\n- 0x0114c210 6c792066 69786564 2c207468 6f756768 ly fixed, though\n- 0x0114c220 20697420 6d757374 20626520 616e2049 it must be an I\n- 0x0114c230 4f206163 74696f6e 20746861 740a2d2d O action that.--\n- 0x0114c240 2070726f 64756365 73207468 65207361 produces the sa\n- 0x0114c250 6d652074 79706520 61732027 67657441 me type as 'getA\n- 0x0114c260 6374696f 6e732720 74616b65 732e2049 ctions' takes. I\n- 0x0114c270 7420616c 736f206d 75737420 62652061 t also must be a\n- 0x0114c280 6e20696e 7374616e 6365206f 660a2d2d n instance of.--\n- 0x0114c290 20547970 6561626c 652e2049 66207468 Typeable. If th\n- 0x0114c2a0 65207479 7065206f 66207468 69732069 e type of this i\n- 0x0114c2b0 73206368 616e6765 642c2061 2066756c s changed, a ful\n- 0x0114c2c0 6c207265 636f6d70 696c6520 77696c6c l recompile will\n- 0x0114c2d0 20626520 6e656564 65642074 6f0a2d2d be needed to.--\n- 0x0114c2e0 20706963 6b207570 20746865 20636861 pick up the cha\n- 0x0114c2f0 6e67652c 20657665 6e20696e 20646576 nge, even in dev\n- 0x0114c300 656c6f70 6d656e74 206d6f64 652e0a2d elopment mode..-\n- 0x0114c310 2d0a2d2d 20546869 73206163 74696f6e -.-- This action\n- 0x0114c320 20697320 6f6e6c79 2072756e 206f6e63 is only run onc\n- 0x0114c330 652c2072 65676172 646c6573 73206f66 e, regardless of\n- 0x0114c340 20776865 74686572 20646576 656c6f70 whether develop\n- 0x0114c350 6d656e74 206f720a 2d2d2070 726f6475 ment or.-- produ\n- 0x0114c360 6374696f 6e206d6f 64652069 7320696e ction mode is in\n- 0x0114c370 20757365 2e0a6765 74436f6e 66203a3a use..getConf ::\n- 0x0114c380 20494f20 28436f6e 66696720 536e6170 IO (Config Snap\n- 0x0114c390 20417070 436f6e66 6967290a 67657443 AppConfig).getC\n- 0x0114c3a0 6f6e6620 3d20636f 6d6d616e 644c696e onf = commandLin\n- 0x0114c3b0 65417070 436f6e66 69672064 65666175 eAppConfig defau\n- 0x0114c3c0 6c74436f 6e666967 0a0a0a2d 2d2d2d2d ltConfig...-----\n- 0x0114c3d0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114c3e0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114c3f0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114c400 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114c410 2d2d2d2d 2d2d2d2d 2d0a2d2d 207c2054 ---------.-- | T\n- 0x0114c420 68697320 66756e63 74696f6e 2067656e his function gen\n- 0x0114c430 65726174 65732074 68652074 68652073 erates the the s\n- 0x0114c440 69746520 68616e64 6c657220 616e6420 ite handler and \n- 0x0114c450 636c6561 6e757020 61637469 6f6e2066 cleanup action f\n- 0x0114c460 726f6d20 7468650a 2d2d2063 6f6e6669 rom the.-- confi\n- 0x0114c470 67757261 74696f6e 2e20496e 2070726f guration. In pro\n- 0x0114c480 64756374 696f6e20 6d6f6465 2c207468 duction mode, th\n- 0x0114c490 69732061 6374696f 6e206973 206f6e6c is action is onl\n- 0x0114c4a0 79207275 6e206f6e 63652e20 496e0a2d y run once. In.-\n- 0x0114c4b0 2d206465 76656c6f 706d656e 74206d6f - development mo\n- 0x0114c4c0 64652c20 74686973 20616374 696f6e20 de, this action \n- 0x0114c4d0 69732072 756e2077 68656e65 76657220 is run whenever \n- 0x0114c4e0 74686520 6170706c 69636174 696f6e20 the application \n- 0x0114c4f0 69732072 656c6f61 6465642e 0a2d2d0a is reloaded..--.\n- 0x0114c500 2d2d2044 6576656c 6f706d65 6e74206d -- Development m\n- 0x0114c510 6f646520 616c736f 206d616b 65732073 ode also makes s\n- 0x0114c520 75726520 74686174 20746865 20636c65 ure that the cle\n- 0x0114c530 616e7570 20616374 696f6e73 20617265 anup actions are\n- 0x0114c540 2072756e 0a2d2d20 61707072 6f707269 run.-- appropri\n- 0x0114c550 6174656c 79206265 666f7265 20736875 ately before shu\n- 0x0114c560 74646f77 6e2e2054 68652063 6c65616e tdown. The clean\n- 0x0114c570 75702061 6374696f 6e207265 7475726e up action return\n- 0x0114c580 65642066 726f6d20 6c6f6164 536e6170 ed from loadSnap\n- 0x0114c590 54480a2d 2d207368 6f756c64 20737469 TH.-- should sti\n- 0x0114c5a0 6c6c2062 65207573 65642061 66746572 ll be used after\n- 0x0114c5b0 20746865 20736572 76657220 68617320 the server has \n- 0x0114c5c0 73746f70 70656420 68616e64 6c696e67 stopped handling\n- 0x0114c5d0 20726571 75657374 732c2061 73207468 requests, as th\n- 0x0114c5e0 650a2d2d 20636c65 616e7570 20616374 e.-- cleanup act\n- 0x0114c5f0 696f6e73 20617265 206f6e6c 79206175 ions are only au\n- 0x0114c600 746f6d61 74696361 6c6c7920 72756e20 tomatically run \n- 0x0114c610 7768656e 20612072 656c6f61 64206973 when a reload is\n- 0x0114c620 20747269 67676572 65642e0a 2d2d0a2d triggered..--.-\n- 0x0114c630 2d205468 69732073 616d706c 6520646f - This sample do\n- 0x0114c640 65736e27 74206163 7475616c 6c792075 esn't actually u\n- 0x0114c650 73652074 68652063 6f6e6669 67207061 se the config pa\n- 0x0114c660 73736564 20696e2c 20627574 206d6f72 ssed in, but mor\n- 0x0114c670 650a2d2d 20736f70 68697374 69636174 e.-- sophisticat\n- 0x0114c680 65642063 6f646520 6d696768 742e0a67 ed code might..g\n- 0x0114c690 65744163 74696f6e 73203a3a 20436f6e etActions :: Con\n- 0x0114c6a0 66696720 536e6170 20417070 436f6e66 fig Snap AppConf\n- 0x0114c6b0 6967202d 3e20494f 2028536e 61702028 ig -> IO (Snap (\n- 0x0114c6c0 292c2049 4f202829 290a6765 74416374 ), IO ()).getAct\n- 0x0114c6d0 696f6e73 20636f6e 66203d20 646f0a20 ions conf = do. \n- 0x0114c6e0 20202028 6d736773 2c207369 74652c20 (msgs, site, \n- 0x0114c6f0 636c6561 6e757029 203c2d20 72756e53 cleanup) <- runS\n- 0x0114c700 6e61706c 65740a20 20202020 20202028 naplet. (\n- 0x0114c710 61707045 6e766972 6f6e6d65 6e74203d appEnvironment =\n- 0x0114c720 3c3c2067 65744f74 68657220 636f6e66 << getOther conf\n- 0x0114c730 29206170 700a2020 20206850 75745374 ) app. hPutSt\n- 0x0114c740 724c6e20 73746465 72722024 20542e75 rLn stderr $ T.u\n- 0x0114c750 6e706163 6b206d73 67730a20 20202072 npack msgs. r\n- 0x0114c760 65747572 6e202873 6974652c 20636c65 eturn (site, cle\n- 0x0114c770 616e7570 290a007b 2d23204c 414e4755 anup)..{-# LANGU\n- 0x0114c780 41474520 4f766572 6c6f6164 65645374 AGE OverloadedSt\n- 0x0114c790 72696e67 7320232d 7d0a0a2d 2d2d2d2d rings #-}..-----\n- 0x0114c7a0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114c7b0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114c7c0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114c7d0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114c7e0 2d2d2d2d 2d2d2d2d 2d0a2d2d 207c2054 ---------.-- | T\n- 0x0114c7f0 68697320 6d6f6475 6c652069 73207768 his module is wh\n- 0x0114c800 65726520 616c6c20 74686520 726f7574 ere all the rout\n- 0x0114c810 65732061 6e642068 616e646c 65727320 es and handlers \n- 0x0114c820 61726520 64656669 6e656420 666f7220 are defined for \n- 0x0114c830 796f7572 0a2d2d20 73697465 2e205468 your.-- site. Th\n- 0x0114c840 65202761 70702720 66756e63 74696f6e e 'app' function\n- 0x0114c850 20697320 74686520 696e6974 69616c69 is the initiali\n- 0x0114c860 7a657220 74686174 20636f6d 62696e65 zer that combine\n- 0x0114c870 73206576 65727974 68696e67 0a2d2d20 s everything.-- \n- 0x0114c880 746f6765 74686572 20616e64 20697320 together and is \n- 0x0114c890 6578706f 72746564 20627920 74686973 exported by this\n- 0x0114c8a0 206d6f64 756c652e 0a6d6f64 756c6520 module..module \n- 0x0114c8b0 53697465 0a202028 20617070 0a202029 Site. ( app. )\n- 0x0114c8c0 20776865 72650a0a 2d2d2d2d 2d2d2d2d where..--------\n- 0x0114c8d0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114c8e0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114c8f0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114c900 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114c910 2d2d2d2d 2d2d0a69 6d706f72 74202020 ------.import \n- 0x0114c920 20202020 20202020 436f6e74 726f6c2e Control.\n- 0x0114c930 4170706c 69636174 6976650a 696d706f Applicative.impo\n- 0x0114c940 72742020 20202020 20202020 20446174 rt Dat\n- 0x0114c950 612e4279 74655374 72696e67 20284279 a.ByteString (By\n- 0x0114c960 74655374 72696e67 290a696d 706f7274 teString).import\n- 0x0114c970 20202020 20202020 20202044 6174612e Data.\n- 0x0114c980 4d61702e 53796e74 61782028 28232329 Map.Syntax ((##)\n- 0x0114c990 290a696d 706f7274 20717561 6c696669 ).import qualifi\n- 0x0114c9a0 65642044 6174612e 54657874 20617320 ed Data.Text as \n- 0x0114c9b0 540a696d 706f7274 20202020 20202020 T.import \n- 0x0114c9c0 20202053 6e61702e 436f7265 0a696d70 Snap.Core.imp\n- 0x0114c9d0 6f727420 20202020 20202020 2020536e ort Sn\n- 0x0114c9e0 61702e53 6e61706c 65740a69 6d706f72 ap.Snaplet.impor\n- 0x0114c9f0 74202020 20202020 20202020 536e6170 t Snap\n- 0x0114ca00 2e536e61 706c6574 2e417574 680a696d .Snaplet.Auth.im\n- 0x0114ca10 706f7274 20202020 20202020 20202053 port S\n- 0x0114ca20 6e61702e 536e6170 6c65742e 41757468 nap.Snaplet.Auth\n- 0x0114ca30 2e426163 6b656e64 732e4a73 6f6e4669 .Backends.JsonFi\n- 0x0114ca40 6c650a69 6d706f72 74202020 20202020 le.import \n- 0x0114ca50 20202020 536e6170 2e536e61 706c6574 Snap.Snaplet\n- 0x0114ca60 2e486569 73740a69 6d706f72 74202020 .Heist.import \n- 0x0114ca70 20202020 20202020 536e6170 2e536e61 Snap.Sna\n- 0x0114ca80 706c6574 2e536573 73696f6e 2e426163 plet.Session.Bac\n- 0x0114ca90 6b656e64 732e436f 6f6b6965 53657373 kends.CookieSess\n- 0x0114caa0 696f6e0a 696d706f 72742020 20202020 ion.import \n- 0x0114cab0 20202020 20536e61 702e5574 696c2e46 Snap.Util.F\n- 0x0114cac0 696c6553 65727665 0a696d70 6f727420 ileServe.import \n- 0x0114cad0 7175616c 69666965 64204865 6973742e qualified Heist.\n- 0x0114cae0 496e7465 72707265 74656420 61732049 Interpreted as I\n- 0x0114caf0 0a2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d .---------------\n+ 0x0114b810 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b820 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b830 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d0a ---------------.\n+ 0x0114b840 2d2d207c 2048616e 646c6520 6e657720 -- | Handle new \n+ 0x0114b850 75736572 20666f72 6d207375 626d6974 user form submit\n+ 0x0114b860 0a68616e 646c654e 65775573 6572203a .handleNewUser :\n+ 0x0114b870 3a204861 6e646c65 72204170 70202841 : Handler App (A\n+ 0x0114b880 7574684d 616e6167 65722041 70702920 uthManager App) \n+ 0x0114b890 28290a68 616e646c 654e6577 55736572 ().handleNewUser\n+ 0x0114b8a0 203d206d 6574686f 64204745 54206861 = method GET ha\n+ 0x0114b8b0 6e646c65 466f726d 203c7c3e 206d6574 ndleForm <|> met\n+ 0x0114b8c0 686f6420 504f5354 2068616e 646c6546 hod POST handleF\n+ 0x0114b8d0 6f726d53 75626d69 740a2020 77686572 ormSubmit. wher\n+ 0x0114b8e0 650a2020 20206861 6e646c65 466f726d e. handleForm\n+ 0x0114b8f0 203d2072 656e6465 7220226e 65775f75 = render \"new_u\n+ 0x0114b900 73657222 0a202020 2068616e 646c6546 ser\". handleF\n+ 0x0114b910 6f726d53 75626d69 74203d20 72656769 ormSubmit = regi\n+ 0x0114b920 73746572 55736572 20226c6f 67696e22 sterUser \"login\"\n+ 0x0114b930 20227061 7373776f 72642220 3e3e2072 \"password\" >> r\n+ 0x0114b940 65646972 65637420 222f220a 0a0a2d2d edirect \"/\"...--\n+ 0x0114b950 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b960 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b970 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b980 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114b990 2d2d2d2d 2d2d2d2d 2d2d2d2d 0a2d2d20 ------------.-- \n+ 0x0114b9a0 7c205468 65206170 706c6963 6174696f | The applicatio\n+ 0x0114b9b0 6e277320 726f7574 65732e0a 726f7574 n's routes..rout\n+ 0x0114b9c0 6573203a 3a205b28 42797465 53747269 es :: [(ByteStri\n+ 0x0114b9d0 6e672c20 48616e64 6c657220 41707020 ng, Handler App \n+ 0x0114b9e0 41707020 2829295d 0a726f75 74657320 App ())].routes \n+ 0x0114b9f0 3d205b20 28226c6f 67696e22 2c202020 = [ (\"login\", \n+ 0x0114ba00 20776974 68206175 74682068 616e646c with auth handl\n+ 0x0114ba10 654c6f67 696e5375 626d6974 290a2020 eLoginSubmit). \n+ 0x0114ba20 20202020 2020202c 2028226c 6f676f75 , (\"logou\n+ 0x0114ba30 74222c20 20207769 74682061 75746820 t\", with auth \n+ 0x0114ba40 68616e64 6c654c6f 676f7574 290a2020 handleLogout). \n+ 0x0114ba50 20202020 2020202c 2028226e 65775f75 , (\"new_u\n+ 0x0114ba60 73657222 2c207769 74682061 75746820 ser\", with auth \n+ 0x0114ba70 68616e64 6c654e65 77557365 72290a20 handleNewUser). \n+ 0x0114ba80 20202020 20202020 2c202822 222c2020 , (\"\", \n+ 0x0114ba90 20202020 20202073 65727665 44697265 serveDire\n+ 0x0114baa0 63746f72 79202273 74617469 6322290a ctory \"static\").\n+ 0x0114bab0 20202020 20202020 205d0a0a 0a2d2d2d ]...---\n+ 0x0114bac0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114bad0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114bae0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114baf0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114bb00 2d2d2d2d 2d2d2d2d 2d2d2d0a 2d2d207c -----------.-- |\n+ 0x0114bb10 20546865 20617070 6c696361 74696f6e The application\n+ 0x0114bb20 20696e69 7469616c 697a6572 2e0a6170 initializer..ap\n+ 0x0114bb30 70203a3a 20536e61 706c6574 496e6974 p :: SnapletInit\n+ 0x0114bb40 20417070 20417070 0a617070 203d206d App App.app = m\n+ 0x0114bb50 616b6553 6e61706c 65742022 61707022 akeSnaplet \"app\"\n+ 0x0114bb60 2022416e 20736e61 706c6574 20657861 \"An snaplet exa\n+ 0x0114bb70 6d706c65 20617070 6c696361 74696f6e mple application\n+ 0x0114bb80 2e22204e 6f746869 6e672024 20646f0a .\" Nothing $ do.\n+ 0x0114bb90 20202020 68203c2d 206e6573 74536e61 h <- nestSna\n+ 0x0114bba0 706c6574 20222220 68656973 74202420 plet \"\" heist $ \n+ 0x0114bbb0 68656973 74496e69 74202274 656d706c heistInit \"templ\n+ 0x0114bbc0 61746573 220a2020 20207320 3c2d206e ates\". s <- n\n+ 0x0114bbd0 65737453 6e61706c 65742022 73657373 estSnaplet \"sess\n+ 0x0114bbe0 22207365 73732024 0a202020 20202020 \" sess $. \n+ 0x0114bbf0 20202020 696e6974 436f6f6b 69655365 initCookieSe\n+ 0x0114bc00 7373696f 6e4d616e 61676572 20227369 ssionManager \"si\n+ 0x0114bc10 74655f6b 65792e74 78742220 22736573 te_key.txt\" \"ses\n+ 0x0114bc20 7322204e 6f746869 6e672028 4a757374 s\" Nothing (Just\n+ 0x0114bc30 20333630 30290a0a 20202020 2d2d204e 3600).. -- N\n+ 0x0114bc40 4f54453a 20576527 72652075 73696e67 OTE: We're using\n+ 0x0114bc50 20696e69 744a736f 6e46696c 65417574 initJsonFileAut\n+ 0x0114bc60 684d616e 61676572 20686572 65206265 hManager here be\n+ 0x0114bc70 63617573 65206974 27732065 61737920 cause it's easy \n+ 0x0114bc80 616e640a 20202020 2d2d2064 6f65736e and. -- doesn\n+ 0x0114bc90 27742072 65717569 72652061 6e79206b 't require any k\n+ 0x0114bca0 696e6420 6f662064 61746162 61736520 ind of database \n+ 0x0114bcb0 73657276 65722074 6f207275 6e2e2020 server to run. \n+ 0x0114bcc0 496e2070 72616374 6963652c 0a202020 In practice,. \n+ 0x0114bcd0 202d2d20 796f7527 6c6c2070 726f6261 -- you'll proba\n+ 0x0114bce0 626c7920 77616e74 20746f20 6368616e bly want to chan\n+ 0x0114bcf0 67652074 68697320 746f2061 206d6f72 ge this to a mor\n+ 0x0114bd00 6520726f 62757374 20617574 68206261 e robust auth ba\n+ 0x0114bd10 636b656e 642e0a20 20202061 203c2d20 ckend.. a <- \n+ 0x0114bd20 6e657374 536e6170 6c657420 22617574 nestSnaplet \"aut\n+ 0x0114bd30 68222061 75746820 240a2020 20202020 h\" auth $. \n+ 0x0114bd40 20202020 20696e69 744a736f 6e46696c initJsonFil\n+ 0x0114bd50 65417574 684d616e 61676572 20646566 eAuthManager def\n+ 0x0114bd60 41757468 53657474 696e6773 20736573 AuthSettings ses\n+ 0x0114bd70 73202275 73657273 2e6a736f 6e220a20 s \"users.json\". \n+ 0x0114bd80 20202061 6464526f 75746573 20726f75 addRoutes rou\n+ 0x0114bd90 7465730a 20202020 61646441 75746853 tes. addAuthS\n+ 0x0114bda0 706c6963 65732068 20617574 680a2020 plices h auth. \n+ 0x0114bdb0 20207265 7475726e 20242041 70702068 return $ App h\n+ 0x0114bdc0 20732061 0a0a002e 2f737263 2f536974 s a..../src/Sit\n+ 0x0114bdd0 652e6873 007b2d23 204c414e 47554147 e.hs.{-# LANGUAG\n+ 0x0114bde0 45204350 50202020 20202020 20202020 E CPP \n+ 0x0114bdf0 2020232d 7d0a7b2d 23204c41 4e475541 #-}.{-# LANGUA\n+ 0x0114be00 47452054 656d706c 61746548 61736b65 GE TemplateHaske\n+ 0x0114be10 6c6c2023 2d7d0a0a 7b2d0a0a 4e4f5445 ll #-}..{-..NOTE\n+ 0x0114be20 3a20446f 6e277420 6d6f6469 66792074 : Don't modify t\n+ 0x0114be30 68697320 66696c65 20756e6c 65737320 his file unless \n+ 0x0114be40 796f7520 6b6e6f77 20776861 7420796f you know what yo\n+ 0x0114be50 75206172 6520646f 696e672e 20204966 u are doing. If\n+ 0x0114be60 20796f75 20617265 0a6e6577 20746f20 you are.new to \n+ 0x0114be70 736e6170 2c207374 61727420 77697468 snap, start with\n+ 0x0114be80 20536974 652e6873 20616e64 20417070 Site.hs and App\n+ 0x0114be90 6c696361 74696f6e 2e68732e 20205468 lication.hs. Th\n+ 0x0114bea0 69732066 696c6520 636f6e74 61696e73 is file contains\n+ 0x0114beb0 0a626f69 6c657270 6c617465 206e6565 .boilerplate nee\n+ 0x0114bec0 64656420 666f7220 64796e61 6d696320 ded for dynamic \n+ 0x0114bed0 72656c6f 6164696e 6720616e 64206973 reloading and is\n+ 0x0114bee0 206e6f74 206d6561 6e742066 6f722067 not meant for g\n+ 0x0114bef0 656e6572 616c0a63 6f6e7375 6d707469 eneral.consumpti\n+ 0x0114bf00 6f6e2e0a 0a4f6363 6173696f 6e616c6c on...Occasionall\n+ 0x0114bf10 79206966 20776520 6d6f6469 66792074 y if we modify t\n+ 0x0114bf20 68652077 61792074 68652064 796e616d he way the dynam\n+ 0x0114bf30 69632072 656c6f61 64657220 776f726b ic reloader work\n+ 0x0114bf40 7320616e 6420796f 75207761 6e742074 s and you want t\n+ 0x0114bf50 6f0a7570 67726164 652c2079 6f75206d o.upgrade, you m\n+ 0x0114bf60 69676874 20686176 6520746f 20737761 ight have to swa\n+ 0x0114bf70 70206f75 74207468 69732066 696c6520 p out this file \n+ 0x0114bf80 666f7220 61206e65 77657220 76657273 for a newer vers\n+ 0x0114bf90 696f6e2e 20204275 7420696e 0a6d6f73 ion. But in.mos\n+ 0x0114bfa0 74206361 73657320 796f7527 6c6c206e t cases you'll n\n+ 0x0114bfb0 65766572 206e6565 6420746f 206d6f64 ever need to mod\n+ 0x0114bfc0 69667920 74686973 20636f64 652e0a0a ify this code...\n+ 0x0114bfd0 2d7d0a6d 6f64756c 65204d61 696e2077 -}.module Main w\n+ 0x0114bfe0 68657265 0a0a2d2d 2d2d2d2d 2d2d2d2d here..----------\n+ 0x0114bff0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114c000 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114c010 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114c020 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114c030 2d2d2d2d 0a696d70 6f727420 20202020 ----.import \n+ 0x0114c040 20202020 2020436f 6e74726f 6c2e4578 Control.Ex\n+ 0x0114c050 63657074 696f6e20 28536f6d 65457863 ception (SomeExc\n+ 0x0114c060 65707469 6f6e2c20 74727929 0a696d70 eption, try).imp\n+ 0x0114c070 6f727420 7175616c 69666965 64204461 ort qualified Da\n+ 0x0114c080 74612e54 65787420 61732054 0a696d70 ta.Text as T.imp\n+ 0x0114c090 6f727420 20202020 20202020 2020536e ort Sn\n+ 0x0114c0a0 61702e48 7474702e 53657276 65720a69 ap.Http.Server.i\n+ 0x0114c0b0 6d706f72 74202020 20202020 20202020 mport \n+ 0x0114c0c0 536e6170 2e536e61 706c6574 0a696d70 Snap.Snaplet.imp\n+ 0x0114c0d0 6f727420 20202020 20202020 2020536e ort Sn\n+ 0x0114c0e0 61702e53 6e61706c 65742e43 6f6e6669 ap.Snaplet.Confi\n+ 0x0114c0f0 670a696d 706f7274 20202020 20202020 g.import \n+ 0x0114c100 20202053 6e61702e 436f7265 0a696d70 Snap.Core.imp\n+ 0x0114c110 6f727420 20202020 20202020 20205379 ort Sy\n+ 0x0114c120 7374656d 2e494f0a 696d706f 72742020 stem.IO.import \n+ 0x0114c130 20202020 20202020 20536974 650a0a23 Site..#\n+ 0x0114c140 69666465 66204445 56454c4f 504d454e ifdef DEVELOPMEN\n+ 0x0114c150 540a696d 706f7274 20202020 20202020 T.import \n+ 0x0114c160 20202053 6e61702e 4c6f6164 65722e44 Snap.Loader.D\n+ 0x0114c170 796e616d 69630a23 656c7365 0a696d70 ynamic.#else.imp\n+ 0x0114c180 6f727420 20202020 20202020 2020536e ort Sn\n+ 0x0114c190 61702e4c 6f616465 722e5374 61746963 ap.Loader.Static\n+ 0x0114c1a0 0a23656e 6469660a 0a0a2d2d 2d2d2d2d .#endif...------\n+ 0x0114c1b0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114c1c0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114c1d0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114c1e0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114c1f0 2d2d2d2d 2d2d2d2d 0a2d2d20 7c205468 --------.-- | Th\n+ 0x0114c200 69732069 73207468 6520656e 74727920 is is the entry \n+ 0x0114c210 706f696e 7420666f 72207468 69732077 point for this w\n+ 0x0114c220 65622073 65727665 72206170 706c6963 eb server applic\n+ 0x0114c230 6174696f 6e2e2049 74207375 70706f72 ation. It suppor\n+ 0x0114c240 74730a2d 2d206561 73696c79 20737769 ts.-- easily swi\n+ 0x0114c250 74636869 6e672062 65747765 656e2069 tching between i\n+ 0x0114c260 6e746572 70726574 696e6720 736f7572 nterpreting sour\n+ 0x0114c270 63652061 6e642072 756e6e69 6e672073 ce and running s\n+ 0x0114c280 74617469 63616c6c 7920636f 6d70696c tatically compil\n+ 0x0114c290 65640a2d 2d20636f 64652e0a 2d2d0a2d ed.-- code..--.-\n+ 0x0114c2a0 2d20496e 20656974 68657220 6d6f6465 - In either mode\n+ 0x0114c2b0 2c207468 65206765 6e657261 74656420 , the generated \n+ 0x0114c2c0 70726f67 72616d20 73686f75 6c642062 program should b\n+ 0x0114c2d0 65207275 6e206672 6f6d2074 68652072 e run from the r\n+ 0x0114c2e0 6f6f7420 6f662074 68650a2d 2d207072 oot of the.-- pr\n+ 0x0114c2f0 6f6a6563 74207472 65652e20 5768656e oject tree. When\n+ 0x0114c300 20697420 69732072 756e2c20 6974206c it is run, it l\n+ 0x0114c310 6f636174 65732069 74732074 656d706c ocates its templ\n+ 0x0114c320 61746573 2c207374 61746963 20636f6e ates, static con\n+ 0x0114c330 74656e74 2c20616e 640a2d2d 20736f75 tent, and.-- sou\n+ 0x0114c340 72636520 66696c65 7320696e 20646576 rce files in dev\n+ 0x0114c350 656c6f70 6d656e74 206d6f64 652c2072 elopment mode, r\n+ 0x0114c360 656c6174 69766520 746f2074 68652063 elative to the c\n+ 0x0114c370 75727265 6e742077 6f726b69 6e672064 urrent working d\n+ 0x0114c380 69726563 746f7279 2e0a2d2d 0a2d2d20 irectory..--.-- \n+ 0x0114c390 5768656e 20636f6d 70696c65 64207769 When compiled wi\n+ 0x0114c3a0 74682074 68652064 6576656c 6f706d65 th the developme\n+ 0x0114c3b0 6e742066 6c61672c 206f6e6c 79206368 nt flag, only ch\n+ 0x0114c3c0 616e6765 7320746f 20746865 206c6962 anges to the lib\n+ 0x0114c3d0 72617269 65732c20 796f7572 0a2d2d20 raries, your.-- \n+ 0x0114c3e0 63616261 6c206669 6c652c20 6f722074 cabal file, or t\n+ 0x0114c3f0 68697320 66696c65 2073686f 756c6420 his file should \n+ 0x0114c400 72657175 69726520 61207265 636f6d70 require a recomp\n+ 0x0114c410 696c6520 746f2062 65207069 636b6564 ile to be picked\n+ 0x0114c420 2075702e 0a2d2d20 45766572 79746869 up..-- Everythi\n+ 0x0114c430 6e672065 6c736520 69732069 6e746572 ng else is inter\n+ 0x0114c440 70726574 65642061 74207275 6e74696d preted at runtim\n+ 0x0114c450 652e2054 68657265 20617265 20612066 e. There are a f\n+ 0x0114c460 65772063 6f6e7365 7175656e 63657320 ew consequences \n+ 0x0114c470 6f660a2d 2d207468 69732e0a 2d2d0a2d of.-- this..--.-\n+ 0x0114c480 2d204669 7273742c 20746869 73206973 - First, this is\n+ 0x0114c490 206d7563 6820736c 6f776572 2e205275 much slower. Ru\n+ 0x0114c4a0 6e6e696e 67207468 6520696e 74657270 nning the interp\n+ 0x0114c4b0 72657465 72207461 6b657320 61207369 reter takes a si\n+ 0x0114c4c0 676e6966 6963616e 740a2d2d 20636875 gnificant.-- chu\n+ 0x0114c4d0 6e6b206f 66207469 6d652028 6120636f nk of time (a co\n+ 0x0114c4e0 75706c65 2074656e 74687320 6f662061 uple tenths of a\n+ 0x0114c4f0 20736563 6f6e6420 6f6e2074 68652061 second on the a\n+ 0x0114c500 7574686f 72277320 6d616368 696e652c uthor's machine,\n+ 0x0114c510 20617420 74686973 0a2d2d20 74696d65 at this.-- time\n+ 0x0114c520 292c2072 65676172 646c6573 73206f66 ), regardless of\n+ 0x0114c530 20746865 2073696d 706c6963 69747920 the simplicity \n+ 0x0114c540 6f662074 6865206c 6f616465 6420636f of the loaded co\n+ 0x0114c550 64652e20 496e206f 72646572 20746f0a de. In order to.\n+ 0x0114c560 2d2d2072 65636f6d 70696c65 20616e64 -- recompile and\n+ 0x0114c570 2072652d 6c6f6164 20736572 76657220 re-load server \n+ 0x0114c580 73746174 65206173 20696e66 72657175 state as infrequ\n+ 0x0114c590 656e746c 79206173 20706f73 7369626c ently as possibl\n+ 0x0114c5a0 652c2074 68652073 6f757263 650a2d2d e, the source.--\n+ 0x0114c5b0 20646972 6563746f 72696573 20617265 directories are\n+ 0x0114c5c0 20776174 63686564 20666f72 20757064 watched for upd\n+ 0x0114c5d0 61746573 2c206173 20617265 20616e79 ates, as are any\n+ 0x0114c5e0 20657874 72612064 69726563 746f7269 extra directori\n+ 0x0114c5f0 65732073 70656369 66696564 0a2d2d20 es specified.-- \n+ 0x0114c600 62656c6f 772e0a2d 2d0a2d2d 20536563 below..--.-- Sec\n+ 0x0114c610 6f6e642c 20746865 2067656e 65726174 ond, the generat\n+ 0x0114c620 65642073 65727665 72206269 6e617279 ed server binary\n+ 0x0114c630 20697320 4d554348 206c6172 6765722c is MUCH larger,\n+ 0x0114c640 2073696e 63652069 74206c69 6e6b7320 since it links \n+ 0x0114c650 696e2074 68650a2d 2d204748 43204150 in the.-- GHC AP\n+ 0x0114c660 49202876 69612074 68652068 696e7420 I (via the hint \n+ 0x0114c670 6c696272 61727929 2e0a2d2d 0a2d2d20 library)..--.-- \n+ 0x0114c680 54686972 642c2061 6e642074 68652072 Third, and the r\n+ 0x0114c690 6561736f 6e20796f 7520776f 756c6420 eason you would \n+ 0x0114c6a0 65766572 2077616e 7420746f 20616374 ever want to act\n+ 0x0114c6b0 75616c6c 7920636f 6d70696c 65207769 ually compile wi\n+ 0x0114c6c0 74680a2d 2d206465 76656c6f 706d656e th.-- developmen\n+ 0x0114c6d0 74206d6f 64652c20 69732074 68617420 t mode, is that \n+ 0x0114c6e0 69742065 6e61626c 65732061 20666173 it enables a fas\n+ 0x0114c6f0 74657220 64657665 6c6f706d 656e7420 ter development \n+ 0x0114c700 6379636c 652e2059 6f752063 616e0a2d cycle. You can.-\n+ 0x0114c710 2d207369 6d706c79 20656469 74206120 - simply edit a \n+ 0x0114c720 66696c65 2c207361 76652079 6f757220 file, save your \n+ 0x0114c730 6368616e 6765732c 20616e64 20686974 changes, and hit\n+ 0x0114c740 2072656c 6f616420 746f2073 65652079 reload to see y\n+ 0x0114c750 6f757220 6368616e 6765730a 2d2d2072 our changes.-- r\n+ 0x0114c760 65666c65 63746564 20696d6d 65646961 eflected immedia\n+ 0x0114c770 74656c79 2e0a2d2d 0a2d2d20 5768656e tely..--.-- When\n+ 0x0114c780 20746869 73206973 20636f6d 70696c65 this is compile\n+ 0x0114c790 64207769 74686f75 74207468 65206465 d without the de\n+ 0x0114c7a0 76656c6f 706d656e 7420666c 61672c20 velopment flag, \n+ 0x0114c7b0 616c6c20 74686520 61637469 6f6e7320 all the actions \n+ 0x0114c7c0 6172650a 2d2d2073 74617469 63616c6c are.-- staticall\n+ 0x0114c7d0 7920636f 6d70696c 65642069 6e2e2054 y compiled in. T\n+ 0x0114c7e0 68697320 72657375 6c747320 696e2066 his results in f\n+ 0x0114c7f0 61737465 72206578 65637574 696f6e2c aster execution,\n+ 0x0114c800 20612073 6d616c6c 65722062 696e6172 a smaller binar\n+ 0x0114c810 790a2d2d 2073697a 652c2061 6e642068 y.-- size, and h\n+ 0x0114c820 6176696e 6720746f 20726563 6f6d7069 aving to recompi\n+ 0x0114c830 6c652074 68652073 65727665 7220666f le the server fo\n+ 0x0114c840 7220616e 7920636f 64652063 68616e67 r any code chang\n+ 0x0114c850 652e0a2d 2d0a6d61 696e203a 3a20494f e..--.main :: IO\n+ 0x0114c860 2028290a 6d61696e 203d2064 6f0a2020 ().main = do. \n+ 0x0114c870 20202d2d 20446570 656e6469 6e67206f -- Depending o\n+ 0x0114c880 6e207468 65207665 7273696f 6e206f66 n the version of\n+ 0x0114c890 206c6f61 64536e61 70544820 696e2073 loadSnapTH in s\n+ 0x0114c8a0 636f7065 2c207468 69732065 69746865 cope, this eithe\n+ 0x0114c8b0 7220656e 61626c65 730a2020 20202d2d r enables. --\n+ 0x0114c8c0 2064796e 616d6963 2072656c 6f616469 dynamic reloadi\n+ 0x0114c8d0 6e672c20 6f722063 6f6d7069 6c657320 ng, or compiles \n+ 0x0114c8e0 69742077 6974686f 75742e20 54686520 it without. The \n+ 0x0114c8f0 6c617374 20617267 756d656e 7420746f last argument to\n+ 0x0114c900 0a202020 202d2d20 6c6f6164 536e6170 . -- loadSnap\n+ 0x0114c910 54482069 73206120 6c697374 206f6620 TH is a list of \n+ 0x0114c920 61646469 74696f6e 616c2064 69726563 additional direc\n+ 0x0114c930 746f7269 65732074 6f207761 74636820 tories to watch \n+ 0x0114c940 666f7220 6368616e 67657320 746f0a20 for changes to. \n+ 0x0114c950 2020202d 2d207472 69676765 72207265 -- trigger re\n+ 0x0114c960 6c6f6164 7320696e 20646576 656c6f70 loads in develop\n+ 0x0114c970 6d656e74 206d6f64 652e2049 7420646f ment mode. It do\n+ 0x0114c980 65736e27 74206e65 65642074 6f20696e esn't need to in\n+ 0x0114c990 636c7564 6520736f 75726365 0a202020 clude source. \n+ 0x0114c9a0 202d2d20 64697265 63746f72 6965732c -- directories,\n+ 0x0114c9b0 2074686f 73652061 72652070 69636b65 those are picke\n+ 0x0114c9c0 64207570 20617574 6f6d6174 6963616c d up automatical\n+ 0x0114c9d0 6c792062 79207468 65207370 6c696365 ly by the splice\n+ 0x0114c9e0 2e0a2020 20202863 6f6e662c 20736974 .. (conf, sit\n+ 0x0114c9f0 652c2063 6c65616e 75702920 3c2d2024 e, cleanup) <- $\n+ 0x0114ca00 286c6f61 64536e61 70544820 5b7c2067 (loadSnapTH [| g\n+ 0x0114ca10 6574436f 6e66207c 5d0a2020 20202020 etConf |]. \n+ 0x0114ca20 20202020 20202020 20202020 20202020 \n+ 0x0114ca30 20202020 20202020 20202020 20202020 \n+ 0x0114ca40 20202020 27676574 41637469 6f6e730a 'getActions.\n+ 0x0114ca50 20202020 20202020 20202020 20202020 \n+ 0x0114ca60 20202020 20202020 20202020 20202020 \n+ 0x0114ca70 20202020 20202020 20205b22 736e6170 [\"snap\n+ 0x0114ca80 6c657473 2f686569 73742f74 656d706c lets/heist/templ\n+ 0x0114ca90 61746573 225d290a 0a202020 205f203c ates\"]).. _ <\n+ 0x0114caa0 2d207472 79202420 68747470 53657276 - try $ httpServ\n+ 0x0114cab0 6520636f 6e662073 69746520 3a3a2049 e conf site :: I\n+ 0x0114cac0 4f202845 69746865 7220536f 6d654578 O (Either SomeEx\n+ 0x0114cad0 63657074 696f6e20 2829290a 20202020 ception ()). \n+ 0x0114cae0 636c6561 6e75700a 0a0a2d2d 2d2d2d2d cleanup...------\n+ 0x0114caf0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n 0x0114cb00 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n 0x0114cb10 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n 0x0114cb20 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114cb30 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d0a ---------------.\n- 0x0114cb40 696d706f 72742020 20202020 20202020 import \n- 0x0114cb50 20417070 6c696361 74696f6e 0a0a0a2d Application...-\n- 0x0114cb60 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114cb70 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114cb80 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114cb90 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114cba0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d0a2d2d -------------.--\n- 0x0114cbb0 207c2052 656e6465 72206c6f 67696e20 | Render login \n- 0x0114cbc0 666f726d 0a68616e 646c654c 6f67696e form.handleLogin\n- 0x0114cbd0 203a3a20 4d617962 6520542e 54657874 :: Maybe T.Text\n- 0x0114cbe0 202d3e20 48616e64 6c657220 41707020 -> Handler App \n- 0x0114cbf0 28417574 684d616e 61676572 20417070 (AuthManager App\n- 0x0114cc00 29202829 0a68616e 646c654c 6f67696e ) ().handleLogin\n- 0x0114cc10 20617574 68457272 6f72203d 20686569 authError = hei\n- 0x0114cc20 73744c6f 63616c20 28492e62 696e6453 stLocal (I.bindS\n- 0x0114cc30 706c6963 65732065 72727329 20242072 plices errs) $ r\n- 0x0114cc40 656e6465 7220226c 6f67696e 220a2020 ender \"login\". \n- 0x0114cc50 77686572 650a2020 20206572 7273203d where. errs =\n- 0x0114cc60 206d6179 6265206d 656d7074 79207370 maybe mempty sp\n- 0x0114cc70 6c696365 20617574 68457272 6f720a20 lice authError. \n- 0x0114cc80 20202073 706c6963 65206572 72203d20 splice err = \n- 0x0114cc90 226c6f67 696e4572 726f7222 20232320 \"loginError\" ## \n- 0x0114cca0 492e7465 78745370 6c696365 20657272 I.textSplice err\n- 0x0114ccb0 0a0a0a2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ...-------------\n- 0x0114ccc0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114ccd0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114cce0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114ccf0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114cd00 2d0a2d2d 207c2048 616e646c 65206c6f -.-- | Handle lo\n- 0x0114cd10 67696e20 7375626d 69740a68 616e646c gin submit.handl\n- 0x0114cd20 654c6f67 696e5375 626d6974 203a3a20 eLoginSubmit :: \n- 0x0114cd30 48616e64 6c657220 41707020 28417574 Handler App (Aut\n- 0x0114cd40 684d616e 61676572 20417070 29202829 hManager App) ()\n- 0x0114cd50 0a68616e 646c654c 6f67696e 5375626d .handleLoginSubm\n- 0x0114cd60 6974203d 0a202020 206c6f67 696e5573 it =. loginUs\n- 0x0114cd70 65722022 6c6f6769 6e222022 70617373 er \"login\" \"pass\n- 0x0114cd80 776f7264 22204e6f 7468696e 670a2020 word\" Nothing. \n- 0x0114cd90 20202020 20202020 20202020 285c5f20 (\\_ \n- 0x0114cda0 2d3e2068 616e646c 654c6f67 696e2065 -> handleLogin e\n- 0x0114cdb0 72722920 28726564 69726563 7420222f rr) (redirect \"/\n- 0x0114cdc0 22290a20 20776865 72650a20 20202065 \"). where. e\n- 0x0114cdd0 7272203d 204a7573 74202255 6e6b6e6f rr = Just \"Unkno\n- 0x0114cde0 776e2075 73657220 6f722070 61737377 wn user or passw\n- 0x0114cdf0 6f726422 0a0a0a2d 2d2d2d2d 2d2d2d2d ord\"...---------\n- 0x0114ce00 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114ce10 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114ce20 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114ce30 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114ce40 2d2d2d2d 2d0a2d2d 207c204c 6f677320 -----.-- | Logs \n- 0x0114ce50 6f757420 616e6420 72656469 72656374 out and redirect\n- 0x0114ce60 73207468 65207573 65722074 6f207468 s the user to th\n- 0x0114ce70 65207369 74652069 6e646578 2e0a6861 e site index..ha\n- 0x0114ce80 6e646c65 4c6f676f 7574203a 3a204861 ndleLogout :: Ha\n- 0x0114ce90 6e646c65 72204170 70202841 7574684d ndler App (AuthM\n- 0x0114cea0 616e6167 65722041 70702920 28290a68 anager App) ().h\n- 0x0114ceb0 616e646c 654c6f67 6f757420 3d206c6f andleLogout = lo\n- 0x0114cec0 676f7574 203e3e20 72656469 72656374 gout >> redirect\n- 0x0114ced0 20222f22 0a0a0a2d 2d2d2d2d 2d2d2d2d \"/\"...---------\n- 0x0114cee0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114cef0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114cf00 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114cf10 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114cf20 2d2d2d2d 2d0a2d2d 207c2048 616e646c -----.-- | Handl\n- 0x0114cf30 65206e65 77207573 65722066 6f726d20 e new user form \n- 0x0114cf40 7375626d 69740a68 616e646c 654e6577 submit.handleNew\n- 0x0114cf50 55736572 203a3a20 48616e64 6c657220 User :: Handler \n- 0x0114cf60 41707020 28417574 684d616e 61676572 App (AuthManager\n- 0x0114cf70 20417070 29202829 0a68616e 646c654e App) ().handleN\n- 0x0114cf80 65775573 6572203d 206d6574 686f6420 ewUser = method \n- 0x0114cf90 47455420 68616e64 6c65466f 726d203c GET handleForm <\n- 0x0114cfa0 7c3e206d 6574686f 6420504f 53542068 |> method POST h\n- 0x0114cfb0 616e646c 65466f72 6d537562 6d69740a andleFormSubmit.\n- 0x0114cfc0 20207768 6572650a 20202020 68616e64 where. hand\n- 0x0114cfd0 6c65466f 726d203d 2072656e 64657220 leForm = render \n- 0x0114cfe0 226e6577 5f757365 72220a20 20202068 \"new_user\". h\n- 0x0114cff0 616e646c 65466f72 6d537562 6d697420 andleFormSubmit \n- 0x0114d000 3d207265 67697374 65725573 65722022 = registerUser \"\n- 0x0114d010 6c6f6769 6e222022 70617373 776f7264 login\" \"password\n- 0x0114d020 22203e3e 20726564 69726563 7420222f \" >> redirect \"/\n- 0x0114d030 220a0a0a 2d2d2d2d 2d2d2d2d 2d2d2d2d \"...------------\n- 0x0114d040 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114d050 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114d060 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114d070 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114d080 2d2d0a2d 2d207c20 54686520 6170706c --.-- | The appl\n- 0x0114d090 69636174 696f6e27 7320726f 75746573 ication's routes\n- 0x0114d0a0 2e0a726f 75746573 203a3a20 5b284279 ..routes :: [(By\n- 0x0114d0b0 74655374 72696e67 2c204861 6e646c65 teString, Handle\n- 0x0114d0c0 72204170 70204170 70202829 295d0a72 r App App ())].r\n- 0x0114d0d0 6f757465 73203d20 5b202822 6c6f6769 outes = [ (\"logi\n- 0x0114d0e0 6e222c20 20202077 69746820 61757468 n\", with auth\n- 0x0114d0f0 2068616e 646c654c 6f67696e 5375626d handleLoginSubm\n- 0x0114d100 6974290a 20202020 20202020 202c2028 it). , (\n- 0x0114d110 226c6f67 6f757422 2c202020 77697468 \"logout\", with\n- 0x0114d120 20617574 68206861 6e646c65 4c6f676f auth handleLogo\n- 0x0114d130 7574290a 20202020 20202020 202c2028 ut). , (\n- 0x0114d140 226e6577 5f757365 72222c20 77697468 \"new_user\", with\n- 0x0114d150 20617574 68206861 6e646c65 4e657755 auth handleNewU\n- 0x0114d160 73657229 0a202020 20202020 20202c20 ser). , \n- 0x0114d170 2822222c 20202020 20202020 20736572 (\"\", ser\n- 0x0114d180 76654469 72656374 6f727920 22737461 veDirectory \"sta\n- 0x0114d190 74696322 290a2020 20202020 2020205d tic\"). ]\n- 0x0114d1a0 0a0a0a2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ...-------------\n+ 0x0114cb30 2d2d2d2d 2d2d2d2d 0a2d2d20 7c205468 --------.-- | Th\n+ 0x0114cb40 69732061 6374696f 6e206c6f 61647320 is action loads \n+ 0x0114cb50 74686520 636f6e66 69672075 73656420 the config used \n+ 0x0114cb60 62792074 68697320 6170706c 69636174 by this applicat\n+ 0x0114cb70 696f6e2e 20546865 206c6f61 64656420 ion. The loaded \n+ 0x0114cb80 636f6e66 69670a2d 2d206973 20726574 config.-- is ret\n+ 0x0114cb90 75726e65 64206173 20746865 20666972 urned as the fir\n+ 0x0114cba0 73742065 6c656d65 6e74206f 66207468 st element of th\n+ 0x0114cbb0 65207475 706c6520 70726f64 75636564 e tuple produced\n+ 0x0114cbc0 20627920 74686520 6c6f6164 536e6170 by the loadSnap\n+ 0x0114cbd0 54480a2d 2d205370 6c696365 2e205468 TH.-- Splice. Th\n+ 0x0114cbe0 65207479 70652069 73206e6f 7420736f e type is not so\n+ 0x0114cbf0 6c69646c 79206669 7865642c 2074686f lidly fixed, tho\n+ 0x0114cc00 75676820 6974206d 75737420 62652061 ugh it must be a\n+ 0x0114cc10 6e20494f 20616374 696f6e20 74686174 n IO action that\n+ 0x0114cc20 0a2d2d20 70726f64 75636573 20746865 .-- produces the\n+ 0x0114cc30 2073616d 65207479 70652061 73202767 same type as 'g\n+ 0x0114cc40 65744163 74696f6e 73272074 616b6573 etActions' takes\n+ 0x0114cc50 2e204974 20616c73 6f206d75 73742062 . It also must b\n+ 0x0114cc60 6520616e 20696e73 74616e63 65206f66 e an instance of\n+ 0x0114cc70 0a2d2d20 54797065 61626c65 2e204966 .-- Typeable. If\n+ 0x0114cc80 20746865 20747970 65206f66 20746869 the type of thi\n+ 0x0114cc90 73206973 20636861 6e676564 2c206120 s is changed, a \n+ 0x0114cca0 66756c6c 20726563 6f6d7069 6c652077 full recompile w\n+ 0x0114ccb0 696c6c20 6265206e 65656465 6420746f ill be needed to\n+ 0x0114ccc0 0a2d2d20 7069636b 20757020 74686520 .-- pick up the \n+ 0x0114ccd0 6368616e 67652c20 6576656e 20696e20 change, even in \n+ 0x0114cce0 64657665 6c6f706d 656e7420 6d6f6465 development mode\n+ 0x0114ccf0 2e0a2d2d 0a2d2d20 54686973 20616374 ..--.-- This act\n+ 0x0114cd00 696f6e20 6973206f 6e6c7920 72756e20 ion is only run \n+ 0x0114cd10 6f6e6365 2c207265 67617264 6c657373 once, regardless\n+ 0x0114cd20 206f6620 77686574 68657220 64657665 of whether deve\n+ 0x0114cd30 6c6f706d 656e7420 6f720a2d 2d207072 lopment or.-- pr\n+ 0x0114cd40 6f647563 74696f6e 206d6f64 65206973 oduction mode is\n+ 0x0114cd50 20696e20 7573652e 0a676574 436f6e66 in use..getConf\n+ 0x0114cd60 203a3a20 494f2028 436f6e66 69672053 :: IO (Config S\n+ 0x0114cd70 6e617020 41707043 6f6e6669 67290a67 nap AppConfig).g\n+ 0x0114cd80 6574436f 6e66203d 20636f6d 6d616e64 etConf = command\n+ 0x0114cd90 4c696e65 41707043 6f6e6669 67206465 LineAppConfig de\n+ 0x0114cda0 6661756c 74436f6e 6669670a 0a0a2d2d faultConfig...--\n+ 0x0114cdb0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114cdc0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114cdd0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114cde0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114cdf0 2d2d2d2d 2d2d2d2d 2d2d2d2d 0a2d2d20 ------------.-- \n+ 0x0114ce00 7c205468 69732066 756e6374 696f6e20 | This function \n+ 0x0114ce10 67656e65 72617465 73207468 65207468 generates the th\n+ 0x0114ce20 65207369 74652068 616e646c 65722061 e site handler a\n+ 0x0114ce30 6e642063 6c65616e 75702061 6374696f nd cleanup actio\n+ 0x0114ce40 6e206672 6f6d2074 68650a2d 2d20636f n from the.-- co\n+ 0x0114ce50 6e666967 75726174 696f6e2e 20496e20 nfiguration. In \n+ 0x0114ce60 70726f64 75637469 6f6e206d 6f64652c production mode,\n+ 0x0114ce70 20746869 73206163 74696f6e 20697320 this action is \n+ 0x0114ce80 6f6e6c79 2072756e 206f6e63 652e2049 only run once. I\n+ 0x0114ce90 6e0a2d2d 20646576 656c6f70 6d656e74 n.-- development\n+ 0x0114cea0 206d6f64 652c2074 68697320 61637469 mode, this acti\n+ 0x0114ceb0 6f6e2069 73207275 6e207768 656e6576 on is run whenev\n+ 0x0114cec0 65722074 68652061 70706c69 63617469 er the applicati\n+ 0x0114ced0 6f6e2069 73207265 6c6f6164 65642e0a on is reloaded..\n+ 0x0114cee0 2d2d0a2d 2d204465 76656c6f 706d656e --.-- Developmen\n+ 0x0114cef0 74206d6f 64652061 6c736f20 6d616b65 t mode also make\n+ 0x0114cf00 73207375 72652074 68617420 74686520 s sure that the \n+ 0x0114cf10 636c6561 6e757020 61637469 6f6e7320 cleanup actions \n+ 0x0114cf20 61726520 72756e0a 2d2d2061 7070726f are run.-- appro\n+ 0x0114cf30 70726961 74656c79 20626566 6f726520 priately before \n+ 0x0114cf40 73687574 646f776e 2e205468 6520636c shutdown. The cl\n+ 0x0114cf50 65616e75 70206163 74696f6e 20726574 eanup action ret\n+ 0x0114cf60 75726e65 64206672 6f6d206c 6f616453 urned from loadS\n+ 0x0114cf70 6e617054 480a2d2d 2073686f 756c6420 napTH.-- should \n+ 0x0114cf80 7374696c 6c206265 20757365 64206166 still be used af\n+ 0x0114cf90 74657220 74686520 73657276 65722068 ter the server h\n+ 0x0114cfa0 61732073 746f7070 65642068 616e646c as stopped handl\n+ 0x0114cfb0 696e6720 72657175 65737473 2c206173 ing requests, as\n+ 0x0114cfc0 20746865 0a2d2d20 636c6561 6e757020 the.-- cleanup \n+ 0x0114cfd0 61637469 6f6e7320 61726520 6f6e6c79 actions are only\n+ 0x0114cfe0 20617574 6f6d6174 6963616c 6c792072 automatically r\n+ 0x0114cff0 756e2077 68656e20 61207265 6c6f6164 un when a reload\n+ 0x0114d000 20697320 74726967 67657265 642e0a2d is triggered..-\n+ 0x0114d010 2d0a2d2d 20546869 73207361 6d706c65 -.-- This sample\n+ 0x0114d020 20646f65 736e2774 20616374 75616c6c doesn't actuall\n+ 0x0114d030 79207573 65207468 6520636f 6e666967 y use the config\n+ 0x0114d040 20706173 73656420 696e2c20 62757420 passed in, but \n+ 0x0114d050 6d6f7265 0a2d2d20 736f7068 69737469 more.-- sophisti\n+ 0x0114d060 63617465 6420636f 6465206d 69676874 cated code might\n+ 0x0114d070 2e0a6765 74416374 696f6e73 203a3a20 ..getActions :: \n+ 0x0114d080 436f6e66 69672053 6e617020 41707043 Config Snap AppC\n+ 0x0114d090 6f6e6669 67202d3e 20494f20 28536e61 onfig -> IO (Sna\n+ 0x0114d0a0 70202829 2c20494f 20282929 0a676574 p (), IO ()).get\n+ 0x0114d0b0 41637469 6f6e7320 636f6e66 203d2064 Actions conf = d\n+ 0x0114d0c0 6f0a2020 2020286d 7367732c 20736974 o. (msgs, sit\n+ 0x0114d0d0 652c2063 6c65616e 75702920 3c2d2072 e, cleanup) <- r\n+ 0x0114d0e0 756e536e 61706c65 740a2020 20202020 unSnaplet. \n+ 0x0114d0f0 20202861 7070456e 7669726f 6e6d656e (appEnvironmen\n+ 0x0114d100 74203d3c 3c206765 744f7468 65722063 t =<< getOther c\n+ 0x0114d110 6f6e6629 20617070 0a202020 20685075 onf) app. hPu\n+ 0x0114d120 74537472 4c6e2073 74646572 72202420 tStrLn stderr $ \n+ 0x0114d130 542e756e 7061636b 206d7367 730a2020 T.unpack msgs. \n+ 0x0114d140 20207265 7475726e 20287369 74652c20 return (site, \n+ 0x0114d150 636c6561 6e757029 0a007b2d 23204c41 cleanup)..{-# LA\n+ 0x0114d160 4e475541 47452054 656d706c 61746548 NGUAGE TemplateH\n+ 0x0114d170 61736b65 6c6c2023 2d7d0a0a 2d2d2d2d askell #-}..----\n+ 0x0114d180 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114d190 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114d1a0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n 0x0114d1b0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114d1c0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114d1d0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114d1e0 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n- 0x0114d1f0 2d0a2d2d 207c2054 68652061 70706c69 -.-- | The appli\n- 0x0114d200 63617469 6f6e2069 6e697469 616c697a cation initializ\n- 0x0114d210 65722e0a 61707020 3a3a2053 6e61706c er..app :: Snapl\n- 0x0114d220 6574496e 69742041 70702041 70700a61 etInit App App.a\n- 0x0114d230 7070203d 206d616b 65536e61 706c6574 pp = makeSnaplet\n- 0x0114d240 20226170 70222022 416e2073 6e61706c \"app\" \"An snapl\n- 0x0114d250 65742065 78616d70 6c652061 70706c69 et example appli\n- 0x0114d260 63617469 6f6e2e22 204e6f74 68696e67 cation.\" Nothing\n- 0x0114d270 20242064 6f0a2020 20206820 3c2d206e $ do. h <- n\n- 0x0114d280 65737453 6e61706c 65742022 22206865 estSnaplet \"\" he\n- 0x0114d290 69737420 24206865 69737449 6e697420 ist $ heistInit \n- 0x0114d2a0 2274656d 706c6174 6573220a 20202020 \"templates\". \n- 0x0114d2b0 73203c2d 206e6573 74536e61 706c6574 s <- nestSnaplet\n- 0x0114d2c0 20227365 73732220 73657373 20240a20 \"sess\" sess $. \n- 0x0114d2d0 20202020 20202020 2020696e 6974436f initCo\n- 0x0114d2e0 6f6b6965 53657373 696f6e4d 616e6167 okieSessionManag\n- 0x0114d2f0 65722022 73697465 5f6b6579 2e747874 er \"site_key.txt\n- 0x0114d300 22202273 65737322 204e6f74 68696e67 \" \"sess\" Nothing\n- 0x0114d310 20284a75 73742033 36303029 0a0a2020 (Just 3600).. \n- 0x0114d320 20202d2d 204e4f54 453a2057 65277265 -- NOTE: We're\n- 0x0114d330 20757369 6e672069 6e69744a 736f6e46 using initJsonF\n- 0x0114d340 696c6541 7574684d 616e6167 65722068 ileAuthManager h\n- 0x0114d350 65726520 62656361 75736520 69742773 ere because it's\n- 0x0114d360 20656173 7920616e 640a2020 20202d2d easy and. --\n- 0x0114d370 20646f65 736e2774 20726571 75697265 doesn't require\n- 0x0114d380 20616e79 206b696e 64206f66 20646174 any kind of dat\n- 0x0114d390 61626173 65207365 72766572 20746f20 abase server to \n- 0x0114d3a0 72756e2e 2020496e 20707261 63746963 run. In practic\n- 0x0114d3b0 652c0a20 2020202d 2d20796f 75276c6c e,. -- you'll\n- 0x0114d3c0 2070726f 6261626c 79207761 6e742074 probably want t\n- 0x0114d3d0 6f206368 616e6765 20746869 7320746f o change this to\n- 0x0114d3e0 2061206d 6f726520 726f6275 73742061 a more robust a\n- 0x0114d3f0 75746820 6261636b 656e642e 0a202020 uth backend.. \n- 0x0114d400 2061203c 2d206e65 7374536e 61706c65 a <- nestSnaple\n- 0x0114d410 74202261 75746822 20617574 6820240a t \"auth\" auth $.\n- 0x0114d420 20202020 20202020 20202069 6e69744a initJ\n- 0x0114d430 736f6e46 696c6541 7574684d 616e6167 sonFileAuthManag\n- 0x0114d440 65722064 65664175 74685365 7474696e er defAuthSettin\n- 0x0114d450 67732073 65737320 22757365 72732e6a gs sess \"users.j\n- 0x0114d460 736f6e22 0a202020 20616464 526f7574 son\". addRout\n- 0x0114d470 65732072 6f757465 730a2020 20206164 es routes. ad\n- 0x0114d480 64417574 6853706c 69636573 20682061 dAuthSplices h a\n- 0x0114d490 7574680a 20202020 72657475 726e2024 uth. return $\n- 0x0114d4a0 20417070 20682073 20610a0a 002e2f73 App h s a..../s\n- 0x0114d4b0 72632f53 6974652e 6873003c 68746d6c rc/Site.hs.. . <\n- 0x0114d4d0 7469746c 653e536e 61702077 65622073 title>Snap web s\n- 0x0114d4e0 65727665 723c2f74 69746c65 3e0a2020 erver. \n- 0x0114d4f0 20203c6c 696e6b20 72656c3d 22737479 . \n- 0x0114d530 3c2f6865 61643e0a 20203c62 6f64793e . \n- 0x0114d540 0a202020 203c6469 76206964 3d22636f .
.. <\n- 0x0114d560 6170706c 792d636f 6e74656e 742f3e0a apply-content/>.\n- 0x0114d570 0a202020 203c2f64 69763e0a 20203c2f .
. ....\n- 0x0114d590 2f736e61 706c6574 732f6865 6973742f /snaplets/heist/\n- 0x0114d5a0 74656d70 6c617465 732f6261 73652e74 templates/base.t\n- 0x0114d5b0 706c003c 68313e53 6e617020 4578616d pl.

Snap Exam\n- 0x0114d5c0 706c6520 41707020 4c6f6769 6e3c2f68 ple App Login..

../login.<\n- 0x0114d610 62696e64 20746167 3d227375 626d6974 bind tag=\"submit\n- 0x0114d620 54657874 223e4c6f 67696e3c 2f62696e Text\">Login..\n- 0x0114d650 0a3c703e 446f6e27 74206861 76652061 .

Don't have a\n- 0x0114d660 206c6f67 696e2079 65743f20 3c612068 login yet? \n- 0x0114d680 43726561 74652061 206e6577 20757365 Create a new use\n- 0x0114d690 723c2f61 3e3c2f70 3e0a002e 2f736e61 r

.../sna\n- 0x0114d6a0 706c6574 732f6865 6973742f 74656d70 plets/heist/temp\n- 0x0114d6b0 6c617465 732f5f6c 6f67696e 2e74706c lates/_login.tpl\n- 0x0114d6c0 003c6831 3e526567 69737465 72206120 .

Register a \n- 0x0114d6d0 6e657720 75736572 3c2f6831 3e0a0a3c new user

..<\n- 0x0114d6e0 62696e64 20746167 3d22706f 73744163 bind tag=\"postAc\n- 0x0114d6f0 74696f6e 223e2f6e 65775f75 7365723c tion\">/new_user<\n- 0x0114d700 2f62696e 643e0a3c 62696e64 20746167 /bind>.Ad\n- 0x0114d720 64205573 65723c2f 62696e64 3e0a3c61 d User..../sn\n- 0x0114d750 61706c65 74732f68 65697374 2f74656d aplets/heist/tem\n- 0x0114d760 706c6174 65732f5f 6e65775f 75736572 plates/_new_user\n- 0x0114d770 2e74706c 003c6170 706c7920 74656d70 .tpl.. <\n- 0x0114d790 6170706c 79207465 6d706c61 74653d22 apply template=\"\n- 0x0114d7a0 5f6c6f67 696e222f 3e0a3c2f 6170706c _login\"/>..../snaplets/h\n- 0x0114d7c0 65697374 2f74656d 706c6174 65732f6c eist/templates/l\n- 0x0114d7d0 6f67696e 2e74706c 003c6170 706c7920 ogin.tpl.\n- 0x0114d7f0 0a0a2020 3c69664c 6f676765 64496e3e .. \n- 0x0114d800 0a202020 203c703e 0a202020 20202054 .

. T\n- 0x0114d810 68697320 69732061 2073696d 706c6520 his is a simple \n- 0x0114d820 64656d6f 20706167 65207365 72766564 demo page served\n- 0x0114d830 20757369 6e670a20 20202020 203c6120 using. Heist. \n- 0x0114d880 20202020 20616e64 20746865 203c6120 and the Snap web fr\n- 0x0114d8c0 616d6577 6f726b2e 0a202020 203c2f70 amework.. ..

Congra\n- 0x0114d8e0 74732120 20596f75 27726520 6c6f6767 ts! You're logg\n- 0x0114d8f0 65642069 6e206173 20273c6c 6f676765 ed in as ''

..\n- 0x0114d910 20202020 3c703e3c 61206872 65663d22

Logout<\n- 0x0114d930 2f613e3c 2f703e0a 20203c2f 69664c6f /a>

. .. . . ...../snaplets/h\n- 0x0114d9a0 65697374 2f74656d 706c6174 65732f69 eist/templates/i\n- 0x0114d9b0 6e646578 2e74706c 003c666f 726d206d ndex.tpl.. . . . \n- 0x0114da50 203c2f74 723e0a20 2020203c 74723e0a . .\n- 0x0114da60 20202020 20203c74 643e5061 7373776f . \n- 0x0114dac0 2020203c 74723e0a 20202020 20203c74 . . <\n- 0x0114db10 2f74643e 0a202020 203c2f74 723e0a20 /td>. . \n- 0x0114db20 203c2f74 61626c65 3e0a3c2f 666f726d
Logi\n- 0x0114da10 6e3a3c2f 74643e3c 74643e3c 696e7075 n:
Passwo\n- 0x0114da70 72643a3c 2f74643e 3c74643e 3c696e70 rd:<\n- 0x0114dab0 2f74643e 0a202020 203c2f74 723e0a20 /td>.
..../snaplets/he\n- 0x0114db40 6973742f 74656d70 6c617465 732f7573 ist/templates/us\n- 0x0114db50 6572666f 726d2e74 706c003c 6170706c erform.tpl.. ..../\n- 0x0114dba0 736e6170 6c657473 2f686569 73742f74 snaplets/heist/t\n- 0x0114dbb0 656d706c 61746573 2f6e6577 5f757365 emplates/new_use\n- 0x0114dbc0 722e7470 6c004e61 6d653a20 20202020 r.tpl.Name: \n- 0x0114dbd0 20202020 20202020 20202070 726f6a6e projn\n- 0x0114dbe0 616d650a 56657273 696f6e3a 20202020 ame.Version: \n- 0x0114dbf0 20202020 20202020 20302e31 0a53796e 0.1.Syn\n- 0x0114dc00 6f707369 733a2020 20202020 20202020 opsis: \n- 0x0114dc10 20205072 6f6a6563 74205379 6e6f7073 Project Synops\n- 0x0114dc20 69732048 6572650a 44657363 72697074 is Here.Descript\n- 0x0114dc30 696f6e3a 20202020 20202020 2050726f ion: Pro\n- 0x0114dc40 6a656374 20446573 63726970 74696f6e ject Description\n- 0x0114dc50 20486572 650a4c69 63656e73 653a2020 Here.License: \n- 0x0114dc60 20202020 20202020 20202041 6c6c5269 AllRi\n- 0x0114dc70 67687473 52657365 72766564 0a417574 ghtsReserved.Aut\n- 0x0114dc80 686f723a 20202020 20202020 20202020 hor: \n- 0x0114dc90 20204175 74686f72 0a4d6169 6e746169 Author.Maintai\n- 0x0114dca0 6e65723a 20202020 20202020 20206d61 ner: ma\n- 0x0114dcb0 696e7461 696e6572 40657861 6d706c65 intainer@example\n- 0x0114dcc0 2e636f6d 0a537461 62696c69 74793a20 .com.Stability: \n- 0x0114dcd0 20202020 20202020 20204578 70657269 Experi\n- 0x0114dce0 6d656e74 616c0a43 61746567 6f72793a mental.Category:\n- 0x0114dcf0 20202020 20202020 20202020 5765620a Web.\n- 0x0114dd00 4275696c 642d7479 70653a20 20202020 Build-type: \n- 0x0114dd10 20202020 2053696d 706c650a 43616261 Simple.Caba\n- 0x0114dd20 6c2d7665 7273696f 6e3a2020 20202020 l-version: \n- 0x0114dd30 203e3d31 2e320a0a 466c6167 20646576 >=1.2..Flag dev\n- 0x0114dd40 656c6f70 6d656e74 0a202044 65736372 elopment. Descr\n- 0x0114dd50 69707469 6f6e3a20 57686574 68657220 iption: Whether \n- 0x0114dd60 746f2062 75696c64 20746865 20736572 to build the ser\n- 0x0114dd70 76657220 696e2064 6576656c 6f706d65 ver in developme\n- 0x0114dd80 6e742028 696e7465 72707265 74656429 nt (interpreted)\n- 0x0114dd90 206d6f64 650a2020 44656661 756c743a mode. Default:\n- 0x0114dda0 2046616c 73650a0a 466c6167 206f6c64 False..Flag old\n- 0x0114ddb0 2d626173 650a2020 64656661 756c743a -base. default:\n- 0x0114ddc0 2046616c 73650a20 206d616e 75616c3a False. manual:\n- 0x0114ddd0 2046616c 73650a0a 45786563 75746162 False..Executab\n- 0x0114dde0 6c652070 726f6a6e 616d650a 20206873 le projname. hs\n- 0x0114ddf0 2d736f75 7263652d 64697273 3a207372 -source-dirs: sr\n- 0x0114de00 630a2020 6d61696e 2d69733a 204d6169 c. main-is: Mai\n- 0x0114de10 6e2e6873 0a0a2020 4275696c 642d6465 n.hs.. Build-de\n- 0x0114de20 70656e64 733a0a20 20202062 61736520 pends:. base \n- 0x0114de30 20202020 20202020 20202020 20202020 \n- 0x0114de40 20202020 203e3d20 342e3420 20202020 >= 4.4 \n- 0x0114de50 2626203c 20352c0a 20202020 62797465 && < 5,. byte\n- 0x0114de60 73747269 6e672020 20202020 20202020 string \n- 0x0114de70 20202020 20203e3d 20302e39 2e312020 >= 0.9.1 \n- 0x0114de80 20262620 3c20302e 31312c0a 20202020 && < 0.11,. \n- 0x0114de90 68656973 74202020 20202020 20202020 heist \n- 0x0114dea0 20202020 20202020 20203e3d 20312e30 >= 1.0\n- 0x0114deb0 20202020 20262620 3c20312e 322c0a20 && < 1.2,. \n- 0x0114dec0 2020206c 656e7320 20202020 20202020 lens \n- 0x0114ded0 20202020 20202020 20202020 203e3d20 >= \n- 0x0114dee0 332e372e 36202020 2626203c 20342e31 3.7.6 && < 4.1\n- 0x0114def0 382c0a20 2020206d 61702d73 796e7461 8,. map-synta\n- 0x0114df00 78202020 20202020 20202020 20202020 x \n- 0x0114df10 203e3d20 302e3220 20202020 2626203c >= 0.2 && <\n- 0x0114df20 20302e34 2c0a2020 20206d6f 6e61642d 0.4,. monad-\n- 0x0114df30 636f6e74 726f6c20 20202020 20202020 control \n- 0x0114df40 20202020 3e3d2031 2e302020 20202026 >= 1.0 &\n- 0x0114df50 26203c20 312e312c 0a202020 206d746c & < 1.1,. mtl\n- 0x0114df60 20202020 20202020 20202020 20202020 \n- 0x0114df70 20202020 2020203e 3d203220 20202020 >= 2 \n- 0x0114df80 20202626 203c2032 2e332c0a 20202020 && < 2.3,. \n- 0x0114df90 736e6170 20202020 20202020 20202020 snap \n- 0x0114dfa0 20202020 20202020 20203e3d 20312e30 >= 1.0\n- 0x0114dfb0 20202020 20262620 3c20312e 322c0a20 && < 1.2,. \n- 0x0114dfc0 20202073 6e61702d 636f7265 20202020 snap-core \n- 0x0114dfd0 20202020 20202020 20202020 203e3d20 >= \n- 0x0114dfe0 312e3020 20202020 2626203c 20312e31 1.0 && < 1.1\n- 0x0114dff0 2c0a2020 2020736e 61702d73 65727665 ,. snap-serve\n- 0x0114e000 72202020 20202020 20202020 20202020 r \n- 0x0114e010 3e3d2031 2e302020 20202026 26203c20 >= 1.0 && < \n- 0x0114e020 312e322c 0a202020 20736e61 702d6c6f 1.2,. snap-lo\n- 0x0114e030 61646572 2d737461 74696320 20202020 ader-static \n- 0x0114e040 2020203e 3d20312e 30202020 20202626 >= 1.0 &&\n- 0x0114e050 203c2031 2e312c0a 20202020 74657874 < 1.1,. text\n- 0x0114e060 20202020 20202020 20202020 20202020 \n- 0x0114e070 20202020 20203e3d 20302e31 31202020 >= 0.11 \n- 0x0114e080 20262620 3c20312e 332c0a20 20202074 && < 1.3,. t\n- 0x0114e090 696d6520 20202020 20202020 20202020 ime \n- 0x0114e0a0 20202020 20202020 203e3d20 312e3120 >= 1.1 \n- 0x0114e0b0 20202020 2626203c 20312e39 2c0a2020 && < 1.9,. \n- 0x0114e0c0 2020786d 6c68746d 6c202020 20202020 xmlhtml \n- 0x0114e0d0 20202020 20202020 20202020 3e3d2030 >= 0\n- 0x0114e0e0 2e312020 20202026 26203c20 302e330a .1 && < 0.3.\n- 0x0114e0f0 0a202069 6620666c 61672864 6576656c . if flag(devel\n- 0x0114e100 6f706d65 6e74290a 20202020 6275696c opment). buil\n- 0x0114e110 642d6465 70656e64 733a0a20 20202020 d-depends:. \n- 0x0114e120 20736e61 702d6c6f 61646572 2d64796e snap-loader-dyn\n- 0x0114e130 616d6963 203e3d20 312e3020 2626203c amic >= 1.0 && <\n- 0x0114e140 20312e31 0a202020 20637070 2d6f7074 1.1. cpp-opt\n- 0x0114e150 696f6e73 3a202d44 44455645 4c4f504d ions: -DDEVELOPM\n- 0x0114e160 454e540a 20202020 2d2d2049 6e206465 ENT. -- In de\n- 0x0114e170 76656c6f 706d656e 74206d6f 64652c20 velopment mode, \n- 0x0114e180 73706565 64206973 20616c72 65616479 speed is already\n- 0x0114e190 20676f69 6e672074 6f207375 66666572 going to suffer\n- 0x0114e1a0 2c20736f 20736b69 700a2020 20202d2d , so skip. --\n- 0x0114e1b0 20746865 2066616e 6379206f 7074696d the fancy optim\n- 0x0114e1c0 697a6174 696f6e20 666c6167 732e2020 ization flags. \n- 0x0114e1d0 41646469 74696f6e 616c6c79 2c206469 Additionally, di\n- 0x0114e1e0 7361626c 6520616c 6c0a2020 20202d2d sable all. --\n- 0x0114e1f0 20776172 6e696e67 732e2020 54686520 warnings. The \n- 0x0114e200 68696e74 206c6962 72617279 20646f65 hint library doe\n- 0x0114e210 736e2774 20676976 6520616e 206f7074 sn't give an opt\n- 0x0114e220 696f6e20 746f2065 78656375 74650a20 ion to execute. \n- 0x0114e230 2020202d 2d20636f 6d70696c 65642063 -- compiled c\n- 0x0114e240 6f646520 7768656e 20746865 72652077 ode when there w\n- 0x0114e250 65726520 616c736f 20776172 6e696e67 ere also warning\n- 0x0114e260 732c2073 6f206469 7361626c 696e670a s, so disabling.\n- 0x0114e270 20202020 2d2d2077 61726e69 6e677320 -- warnings \n- 0x0114e280 616c6c6f 77732071 7569636b 65722077 allows quicker w\n- 0x0114e290 6f726b66 6c6f772e 0a202020 20676863 orkflow.. ghc\n- 0x0114e2a0 2d6f7074 696f6e73 3a202d74 68726561 -options: -threa\n- 0x0114e2b0 64656420 2d770a20 20656c73 650a2020 ded -w. else. \n- 0x0114e2c0 20206966 20696d70 6c286768 63203e3d if impl(ghc >=\n- 0x0114e2d0 20362e31 322e3029 0a202020 20202067 6.12.0). g\n- 0x0114e2e0 68632d6f 7074696f 6e733a20 2d746872 hc-options: -thr\n- 0x0114e2f0 65616465 64202d57 616c6c20 2d667761 eaded -Wall -fwa\n- 0x0114e300 726e2d74 61627320 2d66756e 626f782d rn-tabs -funbox-\n- 0x0114e310 73747269 63742d66 69656c64 73202d4f strict-fields -O\n- 0x0114e320 320a2020 20202020 20202020 20202020 2. \n- 0x0114e330 20202020 202d666e 6f2d7761 726e2d6f -fno-warn-o\n- 0x0114e340 72706861 6e73202d 666e6f2d 7761726e rphans -fno-warn\n- 0x0114e350 2d756e75 7365642d 646f2d62 696e640a -unused-do-bind.\n- 0x0114e360 20202020 656c7365 0a202020 20202067 else. g\n- 0x0114e370 68632d6f 7074696f 6e733a20 2d746872 hc-options: -thr\n- 0x0114e380 65616465 64202d57 616c6c20 2d667761 eaded -Wall -fwa\n- 0x0114e390 726e2d74 61627320 2d66756e 626f782d rn-tabs -funbox-\n- 0x0114e3a0 73747269 63742d66 69656c64 73202d4f strict-fields -O\n- 0x0114e3b0 320a2020 20202020 20202020 20202020 2. \n- 0x0114e3c0 20202020 202d666e 6f2d7761 726e2d6f -fno-warn-o\n- 0x0114e3d0 72706861 6e730a00 68746d6c 207b0a20 rphans..html {. \n+ 0x0114d1c0 2d2d2d2d 2d2d2d2d 2d2d0a2d 2d207c20 ----------.-- | \n+ 0x0114d1d0 54686973 206d6f64 756c6520 64656669 This module defi\n+ 0x0114d1e0 6e657320 6f757220 6170706c 69636174 nes our applicat\n+ 0x0114d1f0 696f6e27 73207374 61746520 74797065 ion's state type\n+ 0x0114d200 20616e64 20616e20 616c6961 7320666f and an alias fo\n+ 0x0114d210 72206974 730a2d2d 2068616e 646c6572 r its.-- handler\n+ 0x0114d220 206d6f6e 61642e0a 6d6f6475 6c652041 monad..module A\n+ 0x0114d230 70706c69 63617469 6f6e2077 68657265 pplication where\n+ 0x0114d240 0a0a2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ..--------------\n+ 0x0114d250 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114d260 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114d270 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114d280 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114d290 0a696d70 6f727420 436f6e74 726f6c2e .import Control.\n+ 0x0114d2a0 4c656e73 0a696d70 6f727420 536e6170 Lens.import Snap\n+ 0x0114d2b0 2e536e61 706c6574 0a696d70 6f727420 .Snaplet.import \n+ 0x0114d2c0 536e6170 2e536e61 706c6574 2e486569 Snap.Snaplet.Hei\n+ 0x0114d2d0 73740a69 6d706f72 7420536e 61702e53 st.import Snap.S\n+ 0x0114d2e0 6e61706c 65742e41 7574680a 696d706f naplet.Auth.impo\n+ 0x0114d2f0 72742053 6e61702e 536e6170 6c65742e rt Snap.Snaplet.\n+ 0x0114d300 53657373 696f6e0a 0a2d2d2d 2d2d2d2d Session..-------\n+ 0x0114d310 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114d320 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114d330 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114d340 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114d350 2d2d2d2d 2d2d2d0a 64617461 20417070 -------.data App\n+ 0x0114d360 203d2041 70700a20 2020207b 205f6865 = App. { _he\n+ 0x0114d370 69737420 3a3a2053 6e61706c 65742028 ist :: Snaplet (\n+ 0x0114d380 48656973 74204170 70290a20 2020202c Heist App). ,\n+ 0x0114d390 205f7365 7373203a 3a20536e 61706c65 _sess :: Snaple\n+ 0x0114d3a0 74205365 7373696f 6e4d616e 61676572 t SessionManager\n+ 0x0114d3b0 0a202020 202c205f 61757468 203a3a20 . , _auth :: \n+ 0x0114d3c0 536e6170 6c657420 28417574 684d616e Snaplet (AuthMan\n+ 0x0114d3d0 61676572 20417070 290a2020 20207d0a ager App). }.\n+ 0x0114d3e0 0a6d616b 654c656e 73657320 27274170 .makeLenses ''Ap\n+ 0x0114d3f0 700a0a69 6e737461 6e636520 48617348 p..instance HasH\n+ 0x0114d400 65697374 20417070 20776865 72650a20 eist App where. \n+ 0x0114d410 20202068 65697374 4c656e73 203d2073 heistLens = s\n+ 0x0114d420 7562536e 61706c65 74206865 6973740a ubSnaplet heist.\n+ 0x0114d430 0a0a2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ..--------------\n+ 0x0114d440 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114d450 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114d460 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114d470 2d2d2d2d 2d2d2d2d 2d2d2d2d 2d2d2d2d ----------------\n+ 0x0114d480 0a747970 65204170 7048616e 646c6572 .type AppHandler\n+ 0x0114d490 203d2048 616e646c 65722041 70702041 = Handler App A\n+ 0x0114d4a0 70700a0a 0a002e2f 7372632f 4170706c pp...../src/Appl\n+ 0x0114d4b0 69636174 696f6e2e 6873004e 616d653a ication.hs.Name:\n+ 0x0114d4c0 20202020 20202020 20202020 20202020 \n+ 0x0114d4d0 70726f6a 6e616d65 0a566572 73696f6e projname.Version\n+ 0x0114d4e0 3a202020 20202020 20202020 2020302e : 0.\n+ 0x0114d4f0 310a5379 6e6f7073 69733a20 20202020 1.Synopsis: \n+ 0x0114d500 20202020 20202050 726f6a65 63742053 Project S\n+ 0x0114d510 796e6f70 73697320 48657265 0a446573 ynopsis Here.Des\n+ 0x0114d520 63726970 74696f6e 3a202020 20202020 cription: \n+ 0x0114d530 20205072 6f6a6563 74204465 73637269 Project Descri\n+ 0x0114d540 7074696f 6e204865 72650a4c 6963656e ption Here.Licen\n+ 0x0114d550 73653a20 20202020 20202020 20202020 se: \n+ 0x0114d560 416c6c52 69676874 73526573 65727665 AllRightsReserve\n+ 0x0114d570 640a4175 74686f72 3a202020 20202020 d.Author: \n+ 0x0114d580 20202020 20202041 7574686f 720a4d61 Author.Ma\n+ 0x0114d590 696e7461 696e6572 3a202020 20202020 intainer: \n+ 0x0114d5a0 2020206d 61696e74 61696e65 72406578 maintainer@ex\n+ 0x0114d5b0 616d706c 652e636f 6d0a5374 6162696c ample.com.Stabil\n+ 0x0114d5c0 6974793a 20202020 20202020 20202045 ity: E\n+ 0x0114d5d0 78706572 696d656e 74616c0a 43617465 xperimental.Cate\n+ 0x0114d5e0 676f7279 3a202020 20202020 20202020 gory: \n+ 0x0114d5f0 20576562 0a427569 6c642d74 7970653a Web.Build-type:\n+ 0x0114d600 20202020 20202020 20205369 6d706c65 Simple\n+ 0x0114d610 0a436162 616c2d76 65727369 6f6e3a20 .Cabal-version: \n+ 0x0114d620 20202020 20203e3d 312e320a 0a466c61 >=1.2..Fla\n+ 0x0114d630 67206465 76656c6f 706d656e 740a2020 g development. \n+ 0x0114d640 44657363 72697074 696f6e3a 20576865 Description: Whe\n+ 0x0114d650 74686572 20746f20 6275696c 64207468 ther to build th\n+ 0x0114d660 65207365 72766572 20696e20 64657665 e server in deve\n+ 0x0114d670 6c6f706d 656e7420 28696e74 65727072 lopment (interpr\n+ 0x0114d680 65746564 29206d6f 64650a20 20446566 eted) mode. Def\n+ 0x0114d690 61756c74 3a204661 6c73650a 0a466c61 ault: False..Fla\n+ 0x0114d6a0 67206f6c 642d6261 73650a20 20646566 g old-base. def\n+ 0x0114d6b0 61756c74 3a204661 6c73650a 20206d61 ault: False. ma\n+ 0x0114d6c0 6e75616c 3a204661 6c73650a 0a457865 nual: False..Exe\n+ 0x0114d6d0 63757461 626c6520 70726f6a 6e616d65 cutable projname\n+ 0x0114d6e0 0a202068 732d736f 75726365 2d646972 . hs-source-dir\n+ 0x0114d6f0 733a2073 72630a20 206d6169 6e2d6973 s: src. main-is\n+ 0x0114d700 3a204d61 696e2e68 730a0a20 20427569 : Main.hs.. Bui\n+ 0x0114d710 6c642d64 6570656e 64733a0a 20202020 ld-depends:. \n+ 0x0114d720 62617365 20202020 20202020 20202020 base \n+ 0x0114d730 20202020 20202020 20203e3d 20342e34 >= 4.4\n+ 0x0114d740 20202020 20262620 3c20352c 0a202020 && < 5,. \n+ 0x0114d750 20627974 65737472 696e6720 20202020 bytestring \n+ 0x0114d760 20202020 20202020 2020203e 3d20302e >= 0.\n+ 0x0114d770 392e3120 20202626 203c2030 2e31312c 9.1 && < 0.11,\n+ 0x0114d780 0a202020 20686569 73742020 20202020 . heist \n+ 0x0114d790 20202020 20202020 20202020 2020203e >\n+ 0x0114d7a0 3d20312e 30202020 20202626 203c2031 = 1.0 && < 1\n+ 0x0114d7b0 2e322c0a 20202020 6c656e73 20202020 .2,. lens \n+ 0x0114d7c0 20202020 20202020 20202020 20202020 \n+ 0x0114d7d0 20203e3d 20332e37 2e362020 20262620 >= 3.7.6 && \n+ 0x0114d7e0 3c20342e 31382c0a 20202020 6d61702d < 4.18,. map-\n+ 0x0114d7f0 73796e74 61782020 20202020 20202020 syntax \n+ 0x0114d800 20202020 20203e3d 20302e32 20202020 >= 0.2 \n+ 0x0114d810 20262620 3c20302e 342c0a20 2020206d && < 0.4,. m\n+ 0x0114d820 6f6e6164 2d636f6e 74726f6c 20202020 onad-control \n+ 0x0114d830 20202020 20202020 203e3d20 312e3020 >= 1.0 \n+ 0x0114d840 20202020 2626203c 20312e31 2c0a2020 && < 1.1,. \n+ 0x0114d850 20206d74 6c202020 20202020 20202020 mtl \n+ 0x0114d860 20202020 20202020 20202020 3e3d2032 >= 2\n+ 0x0114d870 20202020 20202026 26203c20 322e332c && < 2.3,\n+ 0x0114d880 0a202020 20736e61 70202020 20202020 . snap \n+ 0x0114d890 20202020 20202020 20202020 2020203e >\n+ 0x0114d8a0 3d20312e 30202020 20202626 203c2031 = 1.0 && < 1\n+ 0x0114d8b0 2e322c0a 20202020 736e6170 2d636f72 .2,. snap-cor\n+ 0x0114d8c0 65202020 20202020 20202020 20202020 e \n+ 0x0114d8d0 20203e3d 20312e30 20202020 20262620 >= 1.0 && \n+ 0x0114d8e0 3c20312e 312c0a20 20202073 6e61702d < 1.1,. snap-\n+ 0x0114d8f0 73657276 65722020 20202020 20202020 server \n+ 0x0114d900 20202020 203e3d20 312e3020 20202020 >= 1.0 \n+ 0x0114d910 2626203c 20312e32 2c0a2020 2020736e && < 1.2,. sn\n+ 0x0114d920 61702d6c 6f616465 722d7374 61746963 ap-loader-static\n+ 0x0114d930 20202020 20202020 3e3d2031 2e302020 >= 1.0 \n+ 0x0114d940 20202026 26203c20 312e312c 0a202020 && < 1.1,. \n+ 0x0114d950 20746578 74202020 20202020 20202020 text \n+ 0x0114d960 20202020 20202020 2020203e 3d20302e >= 0.\n+ 0x0114d970 31312020 20202626 203c2031 2e332c0a 11 && < 1.3,.\n+ 0x0114d980 20202020 74696d65 20202020 20202020 time \n+ 0x0114d990 20202020 20202020 20202020 20203e3d >=\n+ 0x0114d9a0 20312e31 20202020 20262620 3c20312e 1.1 && < 1.\n+ 0x0114d9b0 392c0a20 20202078 6d6c6874 6d6c2020 9,. xmlhtml \n+ 0x0114d9c0 20202020 20202020 20202020 20202020 \n+ 0x0114d9d0 203e3d20 302e3120 20202020 2626203c >= 0.1 && <\n+ 0x0114d9e0 20302e33 0a0a2020 69662066 6c616728 0.3.. if flag(\n+ 0x0114d9f0 64657665 6c6f706d 656e7429 0a202020 development). \n+ 0x0114da00 20627569 6c642d64 6570656e 64733a0a build-depends:.\n+ 0x0114da10 20202020 2020736e 61702d6c 6f616465 snap-loade\n+ 0x0114da20 722d6479 6e616d69 63203e3d 20312e30 r-dynamic >= 1.0\n+ 0x0114da30 20262620 3c20312e 310a2020 20206370 && < 1.1. cp\n+ 0x0114da40 702d6f70 74696f6e 733a202d 44444556 p-options: -DDEV\n+ 0x0114da50 454c4f50 4d454e54 0a202020 202d2d20 ELOPMENT. -- \n+ 0x0114da60 496e2064 6576656c 6f706d65 6e74206d In development m\n+ 0x0114da70 6f64652c 20737065 65642069 7320616c ode, speed is al\n+ 0x0114da80 72656164 7920676f 696e6720 746f2073 ready going to s\n+ 0x0114da90 75666665 722c2073 6f20736b 69700a20 uffer, so skip. \n+ 0x0114daa0 2020202d 2d207468 65206661 6e637920 -- the fancy \n+ 0x0114dab0 6f707469 6d697a61 74696f6e 20666c61 optimization fla\n+ 0x0114dac0 67732e20 20416464 6974696f 6e616c6c gs. Additionall\n+ 0x0114dad0 792c2064 69736162 6c652061 6c6c0a20 y, disable all. \n+ 0x0114dae0 2020202d 2d207761 726e696e 67732e20 -- warnings. \n+ 0x0114daf0 20546865 2068696e 74206c69 62726172 The hint librar\n+ 0x0114db00 7920646f 65736e27 74206769 76652061 y doesn't give a\n+ 0x0114db10 6e206f70 74696f6e 20746f20 65786563 n option to exec\n+ 0x0114db20 7574650a 20202020 2d2d2063 6f6d7069 ute. -- compi\n+ 0x0114db30 6c656420 636f6465 20776865 6e207468 led code when th\n+ 0x0114db40 65726520 77657265 20616c73 6f207761 ere were also wa\n+ 0x0114db50 726e696e 67732c20 736f2064 69736162 rnings, so disab\n+ 0x0114db60 6c696e67 0a202020 202d2d20 7761726e ling. -- warn\n+ 0x0114db70 696e6773 20616c6c 6f777320 71756963 ings allows quic\n+ 0x0114db80 6b657220 776f726b 666c6f77 2e0a2020 ker workflow.. \n+ 0x0114db90 20206768 632d6f70 74696f6e 733a202d ghc-options: -\n+ 0x0114dba0 74687265 61646564 202d770a 2020656c threaded -w. el\n+ 0x0114dbb0 73650a20 20202069 6620696d 706c2867 se. if impl(g\n+ 0x0114dbc0 6863203e 3d20362e 31322e30 290a2020 hc >= 6.12.0). \n+ 0x0114dbd0 20202020 6768632d 6f707469 6f6e733a ghc-options:\n+ 0x0114dbe0 202d7468 72656164 6564202d 57616c6c -threaded -Wall\n+ 0x0114dbf0 202d6677 61726e2d 74616273 202d6675 -fwarn-tabs -fu\n+ 0x0114dc00 6e626f78 2d737472 6963742d 6669656c nbox-strict-fiel\n+ 0x0114dc10 6473202d 4f320a20 20202020 20202020 ds -O2. \n+ 0x0114dc20 20202020 20202020 20202d66 6e6f2d77 -fno-w\n+ 0x0114dc30 61726e2d 6f727068 616e7320 2d666e6f arn-orphans -fno\n+ 0x0114dc40 2d776172 6e2d756e 75736564 2d646f2d -warn-unused-do-\n+ 0x0114dc50 62696e64 0a202020 20656c73 650a2020 bind. else. \n+ 0x0114dc60 20202020 6768632d 6f707469 6f6e733a ghc-options:\n+ 0x0114dc70 202d7468 72656164 6564202d 57616c6c -threaded -Wall\n+ 0x0114dc80 202d6677 61726e2d 74616273 202d6675 -fwarn-tabs -fu\n+ 0x0114dc90 6e626f78 2d737472 6963742d 6669656c nbox-strict-fiel\n+ 0x0114dca0 6473202d 4f320a20 20202020 20202020 ds -O2. \n+ 0x0114dcb0 20202020 20202020 20202d66 6e6f2d77 -fno-w\n+ 0x0114dcc0 61726e2d 6f727068 616e730a 003c6831 arn-orphans..Register a new \n+ 0x0114dce0 75736572 3c2f6831 3e0a0a3c 62696e64 user

../new_user.Add Us\n+ 0x0114dd30 65723c2f 62696e64 3e0a3c61 70706c79 er..../snaple\n+ 0x0114dd60 74732f68 65697374 2f74656d 706c6174 ts/heist/templat\n+ 0x0114dd70 65732f5f 6e65775f 75736572 2e74706c es/_new_user.tpl\n+ 0x0114dd80 003c666f 726d206d 6574686f 643d2270 .. <\n+ 0x0114ddb0 7461626c 65206964 3d22696e 666f223e table id=\"info\">\n+ 0x0114ddc0 0a202020 203c7472 3e0a2020 20202020 . . \n+ 0x0114ddd0 3c74643e 4c6f6769 6e3a3c2f 74643e3c Login:<\n+ 0x0114dde0 74643e3c 696e7075 74207479 70653d22 td><\n+ 0x0114de10 2f74643e 0a202020 203c2f74 723e0a20 /td>. . \n+ 0x0114de20 2020203c 74723e0a 20202020 20203c74 . Password:\n+ 0x0114de40 3c74643e 3c696e70 75742074 7970653d . \n+ 0x0114de80 203c2f74 723e0a20 2020203c 74723e0a . .\n+ 0x0114de90 20202020 20203c74 643e3c2f 74643e0a .\n+ 0x0114dea0 20202020 20203c74 643e3c69 6e707574 . \n+ 0x0114dee0 203c2f74 723e0a20 203c2f74 61626c65 . ..../sna\n+ 0x0114df00 706c6574 732f6865 6973742f 74656d70 plets/heist/temp\n+ 0x0114df10 6c617465 732f7573 6572666f 726d2e74 lates/userform.t\n+ 0x0114df20 706c003c 6170706c 79207465 6d706c61 pl.. ..../snaplets\n+ 0x0114df70 2f686569 73742f74 656d706c 61746573 /heist/templates\n+ 0x0114df80 2f6e6577 5f757365 722e7470 6c003c61 /new_user.tpl.. ..../s\n+ 0x0114dfd0 6e61706c 6574732f 68656973 742f7465 naplets/heist/te\n+ 0x0114dfe0 6d706c61 7465732f 6c6f6769 6e2e7470 mplates/login.tp\n+ 0x0114dff0 6c003c68 313e536e 61702045 78616d70 l.

Snap Examp\n+ 0x0114e000 6c652041 7070204c 6f67696e 3c2f6831 le App Login..

..\n+ 0x0114e040 2f6c6f67 696e3c2f 62696e64 3e0a3c62 /login.Login...\n+ 0x0114e090 3c703e44 6f6e2774 20686176 65206120

Don't have a \n+ 0x0114e0a0 6c6f6769 6e207965 743f203c 61206872 login yet? C\n+ 0x0114e0c0 72656174 65206120 6e657720 75736572 reate a new user\n+ 0x0114e0d0 3c2f613e 3c2f703e 0a002e2f 736e6170

.../snap\n+ 0x0114e0e0 6c657473 2f686569 73742f74 656d706c lets/heist/templ\n+ 0x0114e0f0 61746573 2f5f6c6f 67696e2e 74706c00 ates/_login.tpl.\n+ 0x0114e100 3c68746d 6c3e0a20 203c6865 61643e0a . .\n+ 0x0114e110 20202020 3c746974 6c653e53 6e617020 Snap \n+ 0x0114e120 77656220 73657276 65723c2f 7469746c web server</titl\n+ 0x0114e130 653e0a20 2020203c 6c696e6b 2072656c e>. <link rel\n+ 0x0114e140 3d227374 796c6573 68656574 22207479 =\"stylesheet\" ty\n+ 0x0114e150 70653d22 74657874 2f637373 22206872 pe=\"text/css\" hr\n+ 0x0114e160 65663d22 2f736372 65656e2e 63737322 ef=\"/screen.css\"\n+ 0x0114e170 2f3e0a20 203c2f68 6561643e 0a20203c />. </head>. <\n+ 0x0114e180 626f6479 3e0a2020 20203c64 69762069 body>. <div i\n+ 0x0114e190 643d2263 6f6e7465 6e74223e 0a0a2020 d=\"content\">.. \n+ 0x0114e1a0 20202020 3c617070 6c792d63 6f6e7465 <apply-conte\n+ 0x0114e1b0 6e742f3e 0a0a2020 20203c2f 6469763e nt/>.. </div>\n+ 0x0114e1c0 0a20203c 2f626f64 793e0a3c 2f68746d . </body>.</htm\n+ 0x0114e1d0 6c3e0a00 2e2f736e 61706c65 74732f68 l>.../snaplets/h\n+ 0x0114e1e0 65697374 2f74656d 706c6174 65732f62 eist/templates/b\n+ 0x0114e1f0 6173652e 74706c00 3c617070 6c792074 ase.tpl.<apply t\n+ 0x0114e200 656d706c 6174653d 22626173 65223e0a emplate=\"base\">.\n+ 0x0114e210 0a20203c 69664c6f 67676564 496e3e0a . <ifLoggedIn>.\n+ 0x0114e220 20202020 3c703e0a 20202020 20205468 <p>. Th\n+ 0x0114e230 69732069 73206120 73696d70 6c652064 is is a simple d\n+ 0x0114e240 656d6f20 70616765 20736572 76656420 emo page served \n+ 0x0114e250 7573696e 670a2020 20202020 3c612068 using. <a h\n+ 0x0114e260 7265663d 22687474 703a2f2f 736e6170 ref=\"http://snap\n+ 0x0114e270 6672616d 65776f72 6b2e636f 6d2f646f framework.com/do\n+ 0x0114e280 63732f74 75746f72 69616c73 2f686569 cs/tutorials/hei\n+ 0x0114e290 7374223e 48656973 743c2f61 3e0a2020 st\">Heist</a>. \n+ 0x0114e2a0 20202020 616e6420 74686520 3c612068 and the <a h\n+ 0x0114e2b0 7265663d 22687474 703a2f2f 736e6170 ref=\"http://snap\n+ 0x0114e2c0 6672616d 65776f72 6b2e636f 6d2f223e framework.com/\">\n+ 0x0114e2d0 536e6170 3c2f613e 20776562 20667261 Snap</a> web fra\n+ 0x0114e2e0 6d65776f 726b2e0a 20202020 3c2f703e mework.. </p>\n+ 0x0114e2f0 0a0a2020 20203c70 3e436f6e 67726174 .. <p>Congrat\n+ 0x0114e300 73212020 596f7527 7265206c 6f676765 s! You're logge\n+ 0x0114e310 6420696e 20617320 273c6c6f 67676564 d in as '<logged\n+ 0x0114e320 496e5573 65722f3e 273c2f70 3e0a0a20 InUser/>'</p>.. \n+ 0x0114e330 2020203c 703e3c61 20687265 663d222f <p><a href=\"/\n+ 0x0114e340 6c6f676f 7574223e 4c6f676f 75743c2f logout\">Logout</\n+ 0x0114e350 613e3c2f 703e0a20 203c2f69 664c6f67 a></p>. </ifLog\n+ 0x0114e360 67656449 6e3e0a0a 20203c69 664c6f67 gedIn>.. <ifLog\n+ 0x0114e370 6765644f 75743e0a 20202020 3c617070 gedOut>. <app\n+ 0x0114e380 6c792074 656d706c 6174653d 225f6c6f ly template=\"_lo\n+ 0x0114e390 67696e22 2f3e0a20 203c2f69 664c6f67 gin\"/>. </ifLog\n+ 0x0114e3a0 6765644f 75743e0a 0a3c2f61 70706c79 gedOut>..</apply\n+ 0x0114e3b0 3e0a002e 2f736e61 706c6574 732f6865 >.../snaplets/he\n+ 0x0114e3c0 6973742f 74656d70 6c617465 732f696e ist/templates/in\n+ 0x0114e3d0 6465782e 74706c00 68746d6c 207b0a20 dex.tpl.html {. \n 0x0114e3e0 20207061 6464696e 673a2030 3b0a2020 padding: 0;. \n 0x0114e3f0 206d6172 67696e3a 20303b0a 20202062 margin: 0;. b\n 0x0114e400 61636b67 726f756e 642d636f 6c6f723a ackground-color:\n 0x0114e410 20236666 66666666 3b0a2020 20666f6e #ffffff;. fon\n 0x0114e420 742d6661 6d696c79 3a205665 7264616e t-family: Verdan\n 0x0114e430 612c2048 656c7665 74696361 2c207361 a, Helvetica, sa\n 0x0114e440 6e732d73 65726966 3b0a7d0a 626f6479 ns-serif;.}.body\n@@ -2101,74 +2101,74 @@\n 0x0114e760 616d203c 2d206765 74506172 616d2022 am <- getParam \"\n 0x0114e770 6563686f 70617261 6d220a20 2020206d echoparam\". m\n 0x0114e780 61796265 20287772 69746542 5320226d aybe (writeBS \"m\n 0x0114e790 75737420 73706563 69667920 6563686f ust specify echo\n 0x0114e7a0 2f706172 616d2069 6e205552 4c22290a /param in URL\").\n 0x0114e7b0 20202020 20202020 20207772 69746542 writeB\n 0x0114e7c0 53207061 72616d0a 002e2f73 72632f4d S param.../src/M\n- 0x0114e7d0 61696e2e 68730070 6c616365 686f6c64 ain.hs.placehold\n- 0x0114e7e0 65720a00 2e2f6c6f 672f706c 61636568 er.../log/placeh\n- 0x0114e7f0 6f6c6465 72004e61 6d653a20 20202020 older.Name: \n- 0x0114e800 20202020 20202020 20202070 726f6a6e projn\n- 0x0114e810 616d650a 56657273 696f6e3a 20202020 ame.Version: \n- 0x0114e820 20202020 20202020 20302e31 0a53796e 0.1.Syn\n- 0x0114e830 6f707369 733a2020 20202020 20202020 opsis: \n- 0x0114e840 20205072 6f6a6563 74205379 6e6f7073 Project Synops\n- 0x0114e850 69732048 6572650a 44657363 72697074 is Here.Descript\n- 0x0114e860 696f6e3a 20202020 20202020 2050726f ion: Pro\n- 0x0114e870 6a656374 20446573 63726970 74696f6e ject Description\n- 0x0114e880 20486572 650a4c69 63656e73 653a2020 Here.License: \n- 0x0114e890 20202020 20202020 20202041 6c6c5269 AllRi\n- 0x0114e8a0 67687473 52657365 72766564 0a417574 ghtsReserved.Aut\n- 0x0114e8b0 686f723a 20202020 20202020 20202020 hor: \n- 0x0114e8c0 20204175 74686f72 0a4d6169 6e746169 Author.Maintai\n- 0x0114e8d0 6e65723a 20202020 20202020 20206d61 ner: ma\n- 0x0114e8e0 696e7461 696e6572 40657861 6d706c65 intainer@example\n- 0x0114e8f0 2e636f6d 0a537461 62696c69 74793a20 .com.Stability: \n- 0x0114e900 20202020 20202020 20204578 70657269 Experi\n- 0x0114e910 6d656e74 616c0a43 61746567 6f72793a mental.Category:\n- 0x0114e920 20202020 20202020 20202020 5765620a Web.\n- 0x0114e930 4275696c 642d7479 70653a20 20202020 Build-type: \n- 0x0114e940 20202020 2053696d 706c650a 43616261 Simple.Caba\n- 0x0114e950 6c2d7665 7273696f 6e3a2020 20202020 l-version: \n- 0x0114e960 203e3d31 2e320a0a 45786563 75746162 >=1.2..Executab\n- 0x0114e970 6c652070 726f6a6e 616d650a 20206873 le projname. hs\n- 0x0114e980 2d736f75 7263652d 64697273 3a207372 -source-dirs: sr\n- 0x0114e990 630a2020 6d61696e 2d69733a 204d6169 c. main-is: Mai\n- 0x0114e9a0 6e2e6873 0a0a2020 4275696c 642d6465 n.hs.. Build-de\n- 0x0114e9b0 70656e64 733a0a20 20202062 61736520 pends:. base \n- 0x0114e9c0 20202020 20202020 20202020 20202020 \n- 0x0114e9d0 20202020 203e3d20 34202020 20202626 >= 4 &&\n- 0x0114e9e0 203c2035 2c0a2020 20206279 74657374 < 5,. bytest\n- 0x0114e9f0 72696e67 20202020 20202020 20202020 ring \n- 0x0114ea00 20202020 3e3d2030 2e392e31 20262620 >= 0.9.1 && \n- 0x0114ea10 3c20302e 31312c0a 20202020 6d746c20 < 0.11,. mtl \n- 0x0114ea20 20202020 20202020 20202020 20202020 \n- 0x0114ea30 20202020 20203e3d 20322020 20202026 >= 2 &\n- 0x0114ea40 26203c20 332c0a20 20202073 6e61702d & < 3,. snap-\n- 0x0114ea50 636f7265 20202020 20202020 20202020 core \n- 0x0114ea60 20202020 203e3d20 312e3020 20202626 >= 1.0 &&\n- 0x0114ea70 203c2031 2e312c0a 20202020 736e6170 < 1.1,. snap\n- 0x0114ea80 2d736572 76657220 20202020 20202020 -server \n- 0x0114ea90 20202020 20203e3d 20312e30 20202026 >= 1.0 &\n- 0x0114eaa0 26203c20 312e320a 0a202069 6620696d & < 1.2.. if im\n- 0x0114eab0 706c2867 6863203e 3d20362e 31322e30 pl(ghc >= 6.12.0\n- 0x0114eac0 290a2020 20206768 632d6f70 74696f6e ). ghc-option\n- 0x0114ead0 733a202d 74687265 61646564 202d5761 s: -threaded -Wa\n- 0x0114eae0 6c6c202d 66776172 6e2d7461 6273202d ll -fwarn-tabs -\n- 0x0114eaf0 66756e62 6f782d73 74726963 742d6669 funbox-strict-fi\n- 0x0114eb00 656c6473 202d4f32 0a202020 20202020 elds -O2. \n- 0x0114eb10 20202020 20202020 20202d66 6e6f2d77 -fno-w\n- 0x0114eb20 61726e2d 756e7573 65642d64 6f2d6269 arn-unused-do-bi\n- 0x0114eb30 6e640a20 20656c73 650a2020 20206768 nd. else. gh\n- 0x0114eb40 632d6f70 74696f6e 733a202d 74687265 c-options: -thre\n- 0x0114eb50 61646564 202d5761 6c6c202d 66776172 aded -Wall -fwar\n- 0x0114eb60 6e2d7461 6273202d 66756e62 6f782d73 n-tabs -funbox-s\n- 0x0114eb70 74726963 742d6669 656c6473 202d4f32 trict-fields -O2\n- 0x0114eb80 0a002e2f 666f6f2e 63616261 6c003a73 .../foo.cabal.:s\n+ 0x0114e7d0 61696e2e 6873004e 616d653a 20202020 ain.hs.Name: \n+ 0x0114e7e0 20202020 20202020 20202020 70726f6a proj\n+ 0x0114e7f0 6e616d65 0a566572 73696f6e 3a202020 name.Version: \n+ 0x0114e800 20202020 20202020 2020302e 310a5379 0.1.Sy\n+ 0x0114e810 6e6f7073 69733a20 20202020 20202020 nopsis: \n+ 0x0114e820 20202050 726f6a65 63742053 796e6f70 Project Synop\n+ 0x0114e830 73697320 48657265 0a446573 63726970 sis Here.Descrip\n+ 0x0114e840 74696f6e 3a202020 20202020 20205072 tion: Pr\n+ 0x0114e850 6f6a6563 74204465 73637269 7074696f oject Descriptio\n+ 0x0114e860 6e204865 72650a4c 6963656e 73653a20 n Here.License: \n+ 0x0114e870 20202020 20202020 20202020 416c6c52 AllR\n+ 0x0114e880 69676874 73526573 65727665 640a4175 ightsReserved.Au\n+ 0x0114e890 74686f72 3a202020 20202020 20202020 thor: \n+ 0x0114e8a0 20202041 7574686f 720a4d61 696e7461 Author.Mainta\n+ 0x0114e8b0 696e6572 3a202020 20202020 2020206d iner: m\n+ 0x0114e8c0 61696e74 61696e65 72406578 616d706c aintainer@exampl\n+ 0x0114e8d0 652e636f 6d0a5374 6162696c 6974793a e.com.Stability:\n+ 0x0114e8e0 20202020 20202020 20202045 78706572 Exper\n+ 0x0114e8f0 696d656e 74616c0a 43617465 676f7279 imental.Category\n+ 0x0114e900 3a202020 20202020 20202020 20576562 : Web\n+ 0x0114e910 0a427569 6c642d74 7970653a 20202020 .Build-type: \n+ 0x0114e920 20202020 20205369 6d706c65 0a436162 Simple.Cab\n+ 0x0114e930 616c2d76 65727369 6f6e3a20 20202020 al-version: \n+ 0x0114e940 20203e3d 312e320a 0a457865 63757461 >=1.2..Executa\n+ 0x0114e950 626c6520 70726f6a 6e616d65 0a202068 ble projname. h\n+ 0x0114e960 732d736f 75726365 2d646972 733a2073 s-source-dirs: s\n+ 0x0114e970 72630a20 206d6169 6e2d6973 3a204d61 rc. main-is: Ma\n+ 0x0114e980 696e2e68 730a0a20 20427569 6c642d64 in.hs.. Build-d\n+ 0x0114e990 6570656e 64733a0a 20202020 62617365 epends:. base\n+ 0x0114e9a0 20202020 20202020 20202020 20202020 \n+ 0x0114e9b0 20202020 20203e3d 20342020 20202026 >= 4 &\n+ 0x0114e9c0 26203c20 352c0a20 20202062 79746573 & < 5,. bytes\n+ 0x0114e9d0 7472696e 67202020 20202020 20202020 tring \n+ 0x0114e9e0 20202020 203e3d20 302e392e 31202626 >= 0.9.1 &&\n+ 0x0114e9f0 203c2030 2e31312c 0a202020 206d746c < 0.11,. mtl\n+ 0x0114ea00 20202020 20202020 20202020 20202020 \n+ 0x0114ea10 20202020 2020203e 3d203220 20202020 >= 2 \n+ 0x0114ea20 2626203c 20332c0a 20202020 736e6170 && < 3,. snap\n+ 0x0114ea30 2d636f72 65202020 20202020 20202020 -core \n+ 0x0114ea40 20202020 20203e3d 20312e30 20202026 >= 1.0 &\n+ 0x0114ea50 26203c20 312e312c 0a202020 20736e61 & < 1.1,. sna\n+ 0x0114ea60 702d7365 72766572 20202020 20202020 p-server \n+ 0x0114ea70 20202020 2020203e 3d20312e 30202020 >= 1.0 \n+ 0x0114ea80 2626203c 20312e32 0a0a2020 69662069 && < 1.2.. if i\n+ 0x0114ea90 6d706c28 67686320 3e3d2036 2e31322e mpl(ghc >= 6.12.\n+ 0x0114eaa0 30290a20 20202067 68632d6f 7074696f 0). ghc-optio\n+ 0x0114eab0 6e733a20 2d746872 65616465 64202d57 ns: -threaded -W\n+ 0x0114eac0 616c6c20 2d667761 726e2d74 61627320 all -fwarn-tabs \n+ 0x0114ead0 2d66756e 626f782d 73747269 63742d66 -funbox-strict-f\n+ 0x0114eae0 69656c64 73202d4f 320a2020 20202020 ields -O2. \n+ 0x0114eaf0 20202020 20202020 2020202d 666e6f2d -fno-\n+ 0x0114eb00 7761726e 2d756e75 7365642d 646f2d62 warn-unused-do-b\n+ 0x0114eb10 696e640a 2020656c 73650a20 20202067 ind. else. g\n+ 0x0114eb20 68632d6f 7074696f 6e733a20 2d746872 hc-options: -thr\n+ 0x0114eb30 65616465 64202d57 616c6c20 2d667761 eaded -Wall -fwa\n+ 0x0114eb40 726e2d74 61627320 2d66756e 626f782d rn-tabs -funbox-\n+ 0x0114eb50 73747269 63742d66 69656c64 73202d4f strict-fields -O\n+ 0x0114eb60 320a002e 2f666f6f 2e636162 616c0070 2.../foo.cabal.p\n+ 0x0114eb70 6c616365 686f6c64 65720a00 2e2f6c6f laceholder.../lo\n+ 0x0114eb80 672f706c 61636568 6f6c6465 72003a73 g/placeholder.:s\n 0x0114eb90 6574202d 69737263 0a3a7365 74202d68 et -isrc.:set -h\n 0x0114eba0 6964652d 7061636b 61676520 4d6f6e61 ide-package Mona\n 0x0114ebb0 64436174 6368494f 2d6d746c 0a3a7365 dCatchIO-mtl.:se\n 0x0114ebc0 74202d68 6964652d 7061636b 61676520 t -hide-package \n 0x0114ebd0 6d6f6e61 64732d66 640a3a73 6574202d monads-fd.:set -\n 0x0114ebe0 584f7665 726c6f61 64656453 7472696e XOverloadedStrin\n 0x0114ebf0 67730a00 2e2f2e67 68636900 2e2f7372 gs.../.ghci../sr\n"}, {"source1": "readelf --wide --decompress --hex-dump=.data {}", "source2": "readelf --wide --decompress --hex-dump=.data {}", "unified_diff": "@@ -37,18 +37,18 @@\n 0x01297220 00000000 00000000 fceb1401 54a10e01 ............T...\n 0x01297230 18722901 39173501 00000000 54a10e01 .r).9.5.....T...\n 0x01297240 04722901 2e722901 00000000 64811201 .r)..r).....d...\n 0x01297250 00000000 00000000 00000000 f4eb1401 ................\n 0x01297260 64811201 00000000 00000000 00000000 d...............\n 0x01297270 8eeb1401 ec870e01 4c722901 60722901 ........Lr).`r).\n 0x01297280 00000000 64811201 00000000 00000000 ....d...........\n- 0x01297290 00000000 82eb1401 64811201 00000000 ........d.......\n- 0x012972a0 00000000 00000000 f6e71401 ec870e01 ................\n+ 0x01297290 00000000 7ceb1401 64811201 00000000 ....|...d.......\n+ 0x012972a0 00000000 00000000 6feb1401 ec870e01 ........o.......\n 0x012972b0 84722901 98722901 00000000 64811201 .r)..r).....d...\n- 0x012972c0 00000000 00000000 00000000 e4e71401 ................\n+ 0x012972c0 00000000 00000000 00000000 63eb1401 ............c...\n 0x012972d0 64811201 00000000 00000000 00000000 d...............\n 0x012972e0 d7e71401 ec870e01 bc722901 d0722901 .........r)..r).\n 0x012972f0 00000000 64811201 00000000 00000000 ....d...........\n 0x01297300 00000000 c9e71401 64811201 00000000 ........d.......\n 0x01297310 00000000 00000000 85e51401 ec870e01 ................\n 0x01297320 f4722901 08732901 00000000 54a10e01 .r)..s).....T...\n 0x01297330 1d732901 39173501 00000000 54a10e01 .s).9.5.....T...\n@@ -60,83 +60,83 @@\n 0x01297390 64811201 00000000 00000000 00000000 d...............\n 0x012973a0 71e51401 64811201 00000000 00000000 q...d...........\n 0x012973b0 00000000 60e51401 64811201 00000000 ....`...d.......\n 0x012973c0 00000000 00000000 45e51401 54a10e01 ........E...T...\n 0x012973d0 b8732901 2e722901 00000000 54a10e01 .s)..r).....T...\n 0x012973e0 a4732901 ce732901 00000000 54a10e01 .s)..s).....T...\n 0x012973f0 90732901 de732901 00000000 54a10e01 .s)..s).....T...\n- 0x01297400 04722901 ee732901 00000000 54a10e01 .r)..s).....T...\n- 0x01297410 7c732901 fe732901 00000000 64811201 |s)..s).....d...\n+ 0x01297400 7c732901 ee732901 00000000 54a10e01 |s)..s).....T...\n+ 0x01297410 04722901 fe732901 00000000 64811201 .r)..s).....d...\n 0x01297420 00000000 00000000 00000000 31e51401 ............1...\n 0x01297430 64811201 00000000 00000000 00000000 d...............\n 0x01297440 d8e31401 ec870e01 1c742901 30742901 .........t).0t).\n 0x01297450 00000000 64811201 00000000 00000000 ....d...........\n- 0x01297460 00000000 c6db1401 ec870e01 84722901 .............r).\n- 0x01297470 54742901 00000000 64811201 00000000 Tt).....d.......\n- 0x01297480 00000000 00000000 9edb1401 64811201 ............d...\n- 0x01297490 00000000 00000000 00000000 5bdb1401 ............[...\n- 0x012974a0 ec870e01 78742901 8c742901 00000000 ....xt)..t).....\n- 0x012974b0 64811201 00000000 00000000 00000000 d...............\n- 0x012974c0 33db1401 64811201 00000000 00000000 3...d...........\n- 0x012974d0 00000000 b9d91401 ec870e01 b0742901 .............t).\n- 0x012974e0 c4742901 00000000 64811201 00000000 .t).....d.......\n- 0x012974f0 00000000 00000000 94d91401 64811201 ............d...\n- 0x01297500 00000000 00000000 00000000 d9d71401 ................\n- 0x01297510 ec870e01 e8742901 fc742901 00000000 .....t)..t).....\n- 0x01297520 64811201 00000000 00000000 00000000 d...............\n- 0x01297530 b4d71401 64811201 00000000 00000000 ....d...........\n- 0x01297540 00000000 75d71401 ec870e01 20752901 ....u....... u).\n- 0x01297550 34752901 00000000 64811201 00000000 4u).....d.......\n- 0x01297560 00000000 00000000 4cd71401 64811201 ........L...d...\n- 0x01297570 00000000 00000000 00000000 c1d61401 ................\n- 0x01297580 ec870e01 58752901 6c752901 00000000 ....Xu).lu).....\n- 0x01297590 64811201 00000000 00000000 00000000 d...............\n- 0x012975a0 9bd61401 64811201 00000000 00000000 ....d...........\n- 0x012975b0 00000000 b3d51401 ec870e01 90752901 .............u).\n- 0x012975c0 a4752901 00000000 64811201 00000000 .u).....d.......\n- 0x012975d0 00000000 00000000 8fd51401 64811201 ............d...\n+ 0x01297460 00000000 b3e31401 64811201 00000000 ........d.......\n+ 0x01297470 00000000 00000000 f8e11401 ec870e01 ................\n+ 0x01297480 54742901 68742901 00000000 64811201 Tt).ht).....d...\n+ 0x01297490 00000000 00000000 00000000 d4e11401 ................\n+ 0x012974a0 64811201 00000000 00000000 00000000 d...............\n+ 0x012974b0 00e11401 ec870e01 8c742901 a0742901 .........t)..t).\n+ 0x012974c0 00000000 64811201 00000000 00000000 ....d...........\n+ 0x012974d0 00000000 dae01401 64811201 00000000 ........d.......\n+ 0x012974e0 00000000 00000000 f2df1401 ec870e01 ................\n+ 0x012974f0 c4742901 d8742901 00000000 64811201 .t)..t).....d...\n+ 0x01297500 00000000 00000000 00000000 cddf1401 ................\n+ 0x01297510 64811201 00000000 00000000 00000000 d...............\n+ 0x01297520 8edf1401 ec870e01 fc742901 10752901 .........t)..u).\n+ 0x01297530 00000000 64811201 00000000 00000000 ....d...........\n+ 0x01297540 00000000 66df1401 64811201 00000000 ....f...d.......\n+ 0x01297550 00000000 00000000 23df1401 ec870e01 ........#.......\n+ 0x01297560 34752901 48752901 00000000 64811201 4u).Hu).....d...\n+ 0x01297570 00000000 00000000 00000000 fbde1401 ................\n+ 0x01297580 64811201 00000000 00000000 00000000 d...............\n+ 0x01297590 81dd1401 ec870e01 6c752901 80752901 ........lu)..u).\n+ 0x012975a0 00000000 64811201 00000000 00000000 ....d...........\n+ 0x012975b0 00000000 58dd1401 64811201 00000000 ....X...d.......\n+ 0x012975c0 00000000 00000000 cddc1401 ec870e01 ................\n+ 0x012975d0 a4752901 b8752901 00000000 64811201 .u)..u).....d...\n 0x012975e0 00000000 00000000 00000000 bbd41401 ................\n- 0x012975f0 ec870e01 c8752901 dc752901 00000000 .....u)..u).....\n+ 0x012975f0 ec870e01 bc722901 dc752901 00000000 .....r)..u).....\n 0x01297600 64811201 00000000 00000000 00000000 d...............\n- 0x01297610 add41401 64811201 00000000 00000000 ....d...........\n- 0x01297620 00000000 77c71401 ec870e01 00762901 ....w........v).\n+ 0x01297610 a6d41401 64811201 00000000 00000000 ....d...........\n+ 0x01297620 00000000 5ad11401 ec870e01 00762901 ....Z........v).\n 0x01297630 14762901 00000000 64811201 00000000 .v).....d.......\n- 0x01297640 00000000 00000000 f2b31401 ec870e01 ................\n+ 0x01297640 00000000 00000000 d5bd1401 ec870e01 ................\n 0x01297650 f4722901 38762901 00000000 64811201 .r).8v).....d...\n- 0x01297660 00000000 00000000 00000000 ddb31401 ................\n+ 0x01297660 00000000 00000000 00000000 c7bd1401 ................\n 0x01297670 64811201 00000000 00000000 00000000 d...............\n 0x01297680 91b01401 ec870e01 5c762901 70762901 ........\\v).pv).\n 0x01297690 00000000 54a10e01 85762901 39173501 ....T....v).9.5.\n 0x012976a0 00000000 54a10e01 4d762901 96762901 ....T...Mv)..v).\n 0x012976b0 00000000 54a10e01 29762901 a6762901 ....T...)v)..v).\n 0x012976c0 00000000 54a10e01 f1752901 b6762901 ....T....u)..v).\n- 0x012976d0 00000000 54a10e01 b9752901 c6762901 ....T....u)..v).\n- 0x012976e0 00000000 54a10e01 81752901 d6762901 ....T....u)..v).\n- 0x012976f0 00000000 54a10e01 49752901 e6762901 ....T...Iu)..v).\n- 0x01297700 00000000 54a10e01 11752901 f6762901 ....T....u)..v).\n- 0x01297710 00000000 54a10e01 d9742901 06772901 ....T....t)..w).\n- 0x01297720 00000000 54a10e01 a1742901 16772901 ....T....t)..w).\n- 0x01297730 00000000 54a10e01 e5722901 26772901 ....T....r).&w).\n- 0x01297740 00000000 54a10e01 69742901 36772901 ....T...it).6w).\n- 0x01297750 00000000 54a10e01 75722901 46772901 ....T...ur).Fw).\n- 0x01297760 00000000 54a10e01 45742901 56772901 ....T...Et).Vw).\n+ 0x012976d0 00000000 54a10e01 cd752901 c6762901 ....T....u)..v).\n+ 0x012976e0 00000000 54a10e01 95752901 d6762901 ....T....u)..v).\n+ 0x012976f0 00000000 54a10e01 5d752901 e6762901 ....T...]u)..v).\n+ 0x01297700 00000000 54a10e01 25752901 f6762901 ....T...%u)..v).\n+ 0x01297710 00000000 54a10e01 ed742901 06772901 ....T....t)..w).\n+ 0x01297720 00000000 54a10e01 b5742901 16772901 ....T....t)..w).\n+ 0x01297730 00000000 54a10e01 7d742901 26772901 ....T...}t).&w).\n+ 0x01297740 00000000 54a10e01 45742901 36772901 ....T...Et).6w).\n+ 0x01297750 00000000 54a10e01 ad722901 46772901 ....T....r).Fw).\n+ 0x01297760 00000000 54a10e01 75722901 56772901 ....T...ur).Vw).\n 0x01297770 00000000 ec870e01 0e742901 66772901 .........t).fw).\n 0x01297780 00000000 64811201 00000000 00000000 ....d...........\n- 0x01297790 00000000 2aac1401 ec870e01 84722901 ....*........r).\n+ 0x01297790 00000000 2aac1401 ec870e01 bc722901 ....*........r).\n 0x012977a0 84772901 00000000 64811201 00000000 .w).....d.......\n- 0x012977b0 00000000 00000000 17ac1401 64811201 ............d...\n- 0x012977c0 00000000 00000000 00000000 e8681401 .............h..\n+ 0x012977b0 00000000 00000000 1aac1401 64811201 ............d...\n+ 0x012977c0 00000000 00000000 00000000 abaa1401 ................\n 0x012977d0 ec870e01 a8772901 bc772901 00000000 .....w)..w).....\n 0x012977e0 64811201 00000000 00000000 00000000 d...............\n- 0x012977f0 d8681401 64811201 00000000 00000000 .h..d...........\n+ 0x012977f0 98aa1401 64811201 00000000 00000000 ....d...........\n 0x01297800 00000000 69671401 ec870e01 e0772901 ....ig.......w).\n 0x01297810 f4772901 00000000 54a10e01 09782901 .w).....T....x).\n 0x01297820 39173501 00000000 54a10e01 d1772901 9.5.....T....w).\n- 0x01297830 1a782901 00000000 54a10e01 e5722901 .x).....T....r).\n- 0x01297840 2a782901 00000000 54a10e01 99772901 *x).....T....w).\n+ 0x01297830 1a782901 00000000 54a10e01 99772901 .x).....T....w).\n+ 0x01297840 2a782901 00000000 54a10e01 ad722901 *x).....T....r).\n 0x01297850 3a782901 00000000 54a10e01 75722901 :x).....T...ur).\n 0x01297860 4a782901 00000000 ec870e01 3e722901 Jx).........>r).\n 0x01297870 5a782901 00000000 64811201 00000000 Zx).....d.......\n 0x01297880 00000000 00000000 48671401 64811201 ........Hg..d...\n 0x01297890 00000000 00000000 00000000 41671401 ............Ag..\n 0x012978a0 64811201 00000000 00000000 00000000 d...............\n 0x012978b0 31671401 64811201 00000000 00000000 1g..d...........\n"}]}]}]}]}]}