snap-app-0.6.0: 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 :: (ToRow ps, FromRow r) => [String] -> ps -> Model c s [r]Source

Query with some parameters.

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

Query a single field from a single result.

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

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

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

Query with no parameters.

withPoolConnection :: (MonadCatchIO m, MonadIO m) => Pool -> (Connection -> m a) -> m ()Source

Use the connection pool.

exec :: ToRow ps => [String] -> ps -> Model c s Int64Source

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) 
FromField a => FromRow (Only a) 
ToField a => ToRow (Only a) 



:: MonadIO m 
=> ConnectInfo

Connect info.

-> m Pool 

Create a new connection pool.