Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Char8 as B
import System.IO
main = do hSetEncoding stdout utf8
B.putStrLn "ħéłłø ẇøŕłð"
putStrLn "ħéłłø ẇøŕłð"

Snap Extentions

Snap Extensions is a library which makes it easy to extend your Snap application with modular chunks of functionality such as session management, user authentication, templating and database connection pooling.

Included Extensions

Snap.Extension.DBPool

Snaplets

Snaplet is a library containing a set of modular, reusable web-components for use with the Snap web framework. Each of these components is said to be a Snaplet. Snaplets can be used to easily add features like session management, user authentication, templating and database connection pooling to your application.

Every Snaplet has an interface and at least one implementation of that interface. For some Snaplets, like Heist, there is only ever going to

------------------------------------------------------------------------------
class MonadTrans t where
lift :: Monad m => m a -> t m a
lifted :: Monad m => ((t m a -> m a) -> m a) -> t m a
lift = lifted . const
-----------------------------------------------------------------------------
instance (MonadTrans t, Monad m) => Monad (t m) where
return = lift . return
src/Splices.hs:24:26:
No instance for (GenericXMLString Node)
arising from a use of `getAttribute'
at src/Splices.hs:24:26-50
Possible fix:
add an instance declaration for (GenericXMLString Node)
In the second argument of `($)', namely `getAttribute "href" input'
In the expression: fromJust $ getAttribute "href" input
In the definition of `href':
href = fromJust $ getAttribute "href" input
{-# LANGUAGE OverloadedStrings #-}
module Splices where
import Data.ByteString.Char8(ByteString)
import qualified Data.ByteString.Char8 as B
import Data.Maybe
import Snap.Types
import Text.Templating.Heist
import Text.XML.Expat.Tree hiding (Node)
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.Maybe
import Control.Applicative
import Snap.Types
import Snap.Util.FileServe
import Text.Templating.Heist
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE OverloadedStrings #-}
module Server(templateServer,server,AppConfig(..),emptyServerConfig) where
import Control.Applicative
import Control.Concurrent
import Control.Exception (SomeException)
import Control.Monad.CatchIO
import Data.ByteString.Char8 (ByteString)
path "div" (do n <- getParam "n"
writeBS $ B.pack $ show $ div (100::Int) (read $ B.unpack $ fromJust n))
import Data.Char
atLeastOneFollowedByAndThen f c g [] = False
atLeastOneFollowedByAndThen f c g (x:xs) = f x && yys /= [] && y == c && g ys
where yys = dropWhile f xs
~(y:ys) = yys
isEmail = atLeastOneFollowedByAndThen isAlphaNum '@' isDomain
isDomain = atLeastOneFollowedByAndThen isAlphaNum '.' (\t -> isTerminator t || isDomain t)
isTerminator = (`elem` ["com", "net", "org", "ie"])