{-| Description: Web types for TsWeb These are the base wrappers around Spock's contexts and state monad. The main thing that TsWeb does is force in a 'Context' type that is a wrapper around a 'SuperRecord.Rec' and a 'Data.HVect.HVect'. The Rec is used to store tagged URL paths, while the HVect stores contextual data for views, such as a database connection or authentication information. -} module TsWeb.Types where import Data.HVect (HVect) import SuperRecord (Rec) import Web.Spock (ActionCtxT, WebStateM) import Web.Spock.Core (SpockCtxT) -- | A container for a 'SuperRecord.Rec' of tagged Spock paths and a -- `Data.HVect.HVect' of view contextual data. -- -- The paths are built with 'TsWeb.Routing.path' and friends, and are queried -- using `TsWeb.Action.getPath' / 'TsWeb.Action.showPath'. -- -- Context extras are currently populated using 'TsWeb.Routing.dbwrite' and -- 'TsWeb.Routing.Auth.auth'; probably more will be added as needed. data Context lts vec = Context { ctxPaths :: Rec lts -- ^Tagged paths for web context , ctxExtras :: HVect vec -- ^Free-form extras for web context } -- | Wrapper around 'WebStateM' to suppress spock's database and web_state type TsWebStateM sessdata = WebStateM () sessdata () -- | Wrapper around 'ActionCtxT' to use 'Context' and 'TsWebStateM' type TsActionCtxT lts xs sessdata a = ActionCtxT (Context lts xs) (TsWebStateM sessdata) a -- | Wrapper around 'SpockCtxT' to use 'Context' and 'TsWebStateM' type TsSpockCtxT lts xs sessdata = SpockCtxT (Context lts xs) (TsWebStateM sessdata)