snap-app-0.1.5: Simple modules for writing apps with Snap, abstracted from hpaste.

Safe HaskellNone



Model running.



model :: AppLiftModel c s => Model c s a -> Controller c s aSource

Run a model action from within a controller.

runDB :: s -> c -> Pool -> Model c s () -> IO ()Source

Run a model action at the top-level.

query :: (QueryParams ps, QueryResults r) => [String] -> ps -> Model c s [r]Source

Query with some parameters.

single :: (QueryParams ps, QueryResults (Only r)) => [String] -> ps -> Model c s (Maybe r)Source

Query a single field from a single result.

singleNoParams :: QueryResults (Only r) => [String] -> Model c s (Maybe r)Source

Query a single field from a single result (no params).

queryNoParams :: QueryResults r => [String] -> Model c s [r]Source

Query with no parameters.

processQuery :: (QueryParams q, QueryResults r) => Query -> q -> Model c s (ProcessedQuery r)Source

Process a query for later use.

queryProcessed :: QueryResults r => ProcessedQuery r -> Model c s [r]Source

A version of query that does not perform query substitution.

exec :: QueryParams ps => [String] -> ps -> Model c s IntegerSource

Execute some SQL returning the rows affected.

newtype Only a

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) -> {- ... -}




fromOnly :: a


Functor Only 
Typeable1 Only 
Eq a => Eq (Only a) 
Ord a => Ord (Only a) 
Read a => Read (Only a) 
Show a => Show (Only a) 
Result a => QueryResults (Only a) 
Param a => QueryParams (Only a)