-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Simple modules for writing apps with Snap, abstracted from hpaste. -- -- Simple modules for writing apps with Snap, abstracted from hpaste. @package snap-app @version 0.2.2 -- | Useful operator (++) = mappend. module Data.Monoid.Operator (++) :: Monoid a => a -> a -> a module Network.URI.Params updateUrlParam :: String -> String -> URI -> URI clearUrlQueries :: URI -> URI deleteQueryKey :: String -> URI -> URI editQuery :: ([(String, String)] -> [(String, String)]) -> String -> String formEncodeUrl :: [(String, String)] -> [Char] updateUrlParams :: [(String, String)] -> URI -> URI uriParams :: URI -> [(String, String)] module Text.Blaze.Extra (!.) :: Attributable h => h -> AttributeValue -> h (!#) :: Attributable h => h -> AttributeValue -> h linesToHtml :: String -> Html htmlIntercalate :: Html -> [Html] -> Html htmlCommasAnd :: [Html] -> Html htmlCommas :: [Html] -> Html hrefSet :: URI -> String -> String -> Attribute hrefURI :: URI -> Attribute hrefURIWithHash :: URI -> String -> Attribute hrefAssoc :: String -> [(String, String)] -> Attribute instance ToValue URI -- | Data pagination. module Data.Pagination -- | A pagination object, holds information about the name, total, per -- page, current page, etc. data Pagination Pagination :: Integer -> Integer -> String -> Integer -> Bool -> Pagination pnTotal :: Pagination -> Integer pnPerPage :: Pagination -> Integer pnName :: Pagination -> String pnCurrentPage :: Pagination -> Integer pnShowDesc :: Pagination -> Bool -- | Get the page count of the pagination results. pnPageCount :: Pagination -> Integer -- | Add the current page of the pagination from the current URI. addCurrentPNData :: URI -> Pagination -> Pagination instance Show Pagination instance Default Pagination -- | Simple pagination support for blaze. module Text.Blaze.Pagination -- | Render pagination as html. pagination :: PN -> Html data PN PN :: URI -> Pagination -> Maybe [Integer] -> PN pnURI :: PN -> URI pnPn :: PN -> Pagination pnResultsPerPage :: PN -> Maybe [Integer] -- | Abstraction of environment functions (could be state, could be reader, -- whatever). Intended to ease migration from Reader/State. module Control.Monad.Env env :: MonadReader env m => (env -> val) -> m val -- | Model-view-controller app types. module Snap.App.Types -- | The controller monad. newtype Controller config state a Controller :: ReaderT (ControllerState config state) Snap a -> Controller config state a runController :: Controller config state a -> ReaderT (ControllerState config state) Snap a -- | The model monad (limited access to IO, only DB access). newtype Model config state a Model :: ReaderT (ModelState config state) IO a -> Model config state a runModel :: Model config state a -> ReaderT (ModelState config state) IO a -- | The state accessible to the controller (DB/session stuff). data ControllerState config state ControllerState :: config -> Connection -> state -> ControllerState config state controllerStateConfig :: ControllerState config state -> config controllerStateConn :: ControllerState config state -> Connection controllerState :: ControllerState config state -> state -- | The state accessible to the model (just DB connection). data ModelState config state ModelState :: Connection -> state -> config -> ModelState config state modelStateConn :: ModelState config state -> Connection modelStateAnns :: ModelState config state -> state modelStateConfig :: ModelState config state -> config class AppConfig config getConfigDomain :: AppConfig config => config -> String class AppLiftModel c s liftModel :: AppLiftModel c s => Model c s a -> Controller c s a instance Monad (Controller config state) instance Functor (Controller config state) instance Applicative (Controller config state) instance Alternative (Controller config state) instance MonadReader (ControllerState config state) (Controller config state) instance MonadSnap (Controller config state) instance MonadIO (Controller config state) instance MonadPlus (Controller config state) instance MonadCatchIO (Controller config state) instance Monad (Model config state) instance Functor (Model config state) instance Applicative (Model config state) instance MonadReader (ModelState config state) (Model config state) instance MonadIO (Model config state) -- | Controller routing/handling. module Snap.App.Controller -- | Run a controller handler. runHandler :: s -> c -> Pool -> Controller c s () -> Snap () -- | Strictly renders HTML to Text before outputting it via Snap. This -- ensures that any lazy exceptions are caught by the Snap handler. output :: Html -> Controller c s () -- | Strictly renders text before outputting it via Snap. This ensures that -- any lazy exceptions are caught by the Snap handler. outputText :: Text -> Controller c s () -- | Generic redirect to home page. goHome :: Controller c s () -- | Extract a Just value or go home. justOrGoHome :: Maybe a -> (a -> Controller c s ()) -> Controller c s () -- | Get integer parmater. getInteger :: ByteString -> Integer -> Controller c s Integer -- | Get string. getString :: ByteString -> String -> Controller c s String -- | Get string (maybe). getStringMaybe :: ByteString -> Controller c s (Maybe String) -- | Get pagination data. getPagination :: AppConfig c => String -> Controller c s PN getMyURI :: AppConfig c => Controller c s URI -- | Model running. module Snap.App.Model -- | Run a model action from within a controller. model :: AppLiftModel c s => Model c s a -> Controller c s a -- | Run a model action at the top-level. runDB :: s -> c -> Pool -> Model c s () -> IO () -- | Query with some parameters. query :: (QueryParams ps, QueryResults r) => [String] -> ps -> Model c s [r] -- | Query a single field from a single result. single :: (QueryParams ps, QueryResults (Only r)) => [String] -> ps -> Model c s (Maybe r) -- | Query a single field from a single result (no params). singleNoParams :: QueryResults (Only r) => [String] -> Model c s (Maybe r) -- | Query with no parameters. queryNoParams :: QueryResults r => [String] -> Model c s [r] -- | Process a query for later use. processQuery :: (QueryParams q, QueryResults r) => Query -> q -> Model c s (ProcessedQuery r) -- | A version of query that does not perform query substitution. queryProcessed :: QueryResults r => ProcessedQuery r -> Model c s [r] -- | Execute some SQL returning the rows affected. exec :: QueryParams ps => [String] -> ps -> Model c s Integer -- | A single-value "collection". -- -- This is useful if you need to supply a single parameter to a SQL -- query, or extract a single column from a SQL result. -- -- Parameter example: -- --
--   query c "select x from scores where x > ?" (Only (42::Int))
--   
-- -- Result example: -- --
--   xs <- query_ c "select id from users"
--   forM_ xs $ \(Only id) -> {- ... -}
--   
newtype Only a :: * -> * Only :: a -> Only a fromOnly :: Only a -> a -- | Migration library module Snap.App.Migrate -- | Migrate the DB to the latest version. migrate :: Bool -> [(Int, Model c s Integer)] -> Model c s () -- | Set the current database version. setVersion :: Int -> Model c s () -- | Ensure the version table exists. ensureExists :: Model c s () -- | Create the version number. createVersion :: Model c s () -- | Just print to stdout for now. echo :: String -> Model c s () module Snap.App