scottish-0.1.0.1: scotty with batteries included

Safe HaskellNone

Web.Scottish

Contents

Description

Scotty apps with configuration and states

Synopsis

Types

data Scottish config globalState localState a Source

config is read-only in ActionT, but read-write in ScottyT for initialization.

localState is reinitialized to def for every execution of each ActionT.

globalState may be a TVar, or other monadic mutable data types. Normally, globalState should not be necessary for server apps, as there may be multiple instance of the server running, even across machines, and you sure cannot make them share the same state. However, you may be able to do some process-local caching or user interaction (say in games), with globalState.

Instances

Monad (Scottish config globalState localState) 
Functor (Scottish config globalState localState) 
Applicative (Scottish config globalState localState) 
MonadIO (Scottish config globalState localState) 

type Scottish' c s' = Scottish c () s'Source

Scottish monad without globalState

type ScottishM e c s s' = ScottyT e (Scottish c s s')Source

type ScottishActionM e c s s' = ActionT e (Scottish c s s')Source

App runners/converters

scottish :: (Default c, Default s, Default s') => Port -> ScottishM e c s s' () -> IO ()Source

Run a scottish app with warp.

scottishApp :: (Default c, Default s, Default s') => ScottishM e c s s' () -> IO ApplicationSource

Turn a scottish app into a WAI one, which can be run with any WAI handler.

scottishOpts :: (Default c, Default s, Default s') => Options -> ScottishM e c s s' () -> IO ()Source

Run a scottish app with extra options.

scottish' :: (Default c, Default s, Default s') => Port -> ScottishM Status c s s' () -> IO ()Source

Scottish app runner with Status handler installed.

scottishApp' :: (Default c, Default s, Default s') => ScottishM Status c s s' () -> IO ApplicationSource

Scottish app converter with Status handler installed.

scottishOpts' :: (Default c, Default s, Default s') => Options -> ScottishM Status c s s' () -> IO ()Source

Scottish app runner with Status handler installed.

handleRaisedStatus :: ScottishM Status c s s' () -> ScottishM Status c s s' ()Source

Status is a good candidate as an ScottyError instance by itself. Call this function to install a default handler to report the Status when one is raised.

Also, you may want to define instances of ScottyError with tuples/records containing Status, to provide more informative error pages.

Configuratio/State accessors

Shared by ScottyM & ScottyActionM

getConfig :: MonadTrans t => t (Scottish c s s') cSource

(>$<) :: MonadTrans t => (a -> Scottish c s s' b) -> IdentityT (Scottish c s s') a -> t (Scottish c s s') bSource

Lift a Scottish function to a MonadTrans wrapped Scottish one.

ScottyActionM only

modifyLocalState :: ScottyError e => (s' -> s') -> ScottishActionM e c s s' ()Source

ScottyM only

setConfig :: c -> ScottishM e c s s' ()Source

modifyConfig :: (c -> c) -> ScottishM e c s s' ()Source

setGlobalState :: s -> ScottishM e c s s' ()Source

modifyGlobalState :: (s -> s) -> ScottishM e c s s' ()Source

Re-exports from Web.Scotty.Trans