Skip to content

Instantly share code, notes, and snippets.

{-# 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 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)
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
------------------------------------------------------------------------------
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

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

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
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Char8 as B
import System.IO
main = do hSetEncoding stdout utf8
B.putStrLn "ħéłłø ẇøŕłð"
putStrLn "ħéłłø ẇøŕłð"
{-# LANGUAGE OverloadedStrings #-}
{-|
'Snap.Extension.Clever.Impl' is an implementation of the 'MonadClever'
interface defined in 'Snap.Extension.Clever'.
As always, to use, add 'CleverState' to your application's state, along with
an instance of 'HasCleverState' for your application's state, making sure to
use 'cleverInitializer' in your application's 'Initializer', and then you're
loadTemplates path = readDirectoryWith reader path
>>= (free
-- DirTree (Maybe (FilePath, Either String ByteString))
>>> F.toList
-- [Maybe (String, Either String ByteString)]
>>> catMaybes
-- [(String, Either String ByteString)]
>>> unzip
-- ([String], [Either String ByteString])
>>> second partitionEithers
@duairc
duairc / IDNA.hs
Created January 10, 2014 03:59
Fast IDNA implementation in Haskell using attoparsec.
{-# LANGUAGE BangPatterns #-}
module Text.IDNA
( toASCII
, toUnicode
)
where
-- attoparsec ----------------------------------------------------------------
import Data.Attoparsec.Text