Happstack.State.ComponentSystem
- data End = End
- data h :+: t = h :+: t
- class (Serialize ev, Serialize res) => UpdateEvent ev res | ev -> res
- class (Serialize ev, Serialize res) => QueryEvent ev res | ev -> res
- data Method st where
- Update :: UpdateEvent ev res => (ev -> Update st res) -> Method st
- Query :: QueryEvent ev res => (ev -> Query st res) -> Method st
- methodType :: Method t -> String
- class Methods a where
- data MethodMap where
- type ComponentTree = Map String MethodMap
- type ComponentVersions = Map String [ByteString]
- class (SubHandlers (Dependencies a), Serialize a) => Component a where
- type Dependencies a
- initialValue :: a
- onLoad :: Proxy a -> IO ()
- class SubHandlers a where
- subHandlers :: a -> Collect ()
- data Collection = Collection ComponentTree ComponentVersions [IO ()]
- addItem :: MonadState Collection m => String -> MethodMap -> [ByteString] -> IO () -> m ()
- type Collect = State Collection
- collectHandlers :: (Methods a, Component a) => Proxy a -> (ComponentTree, ComponentVersions, [IO ()])
- collectHandlers' :: (Methods a, Component a) => Proxy a -> Collect ()
- dup :: String -> b
Documentation
data End
Equivalent of [] for type level lists. Used for Components that have no dependencies
Constructors
End |
Instances
SubHandlers End | In correspondence with its role as [] in the type level list, the instance for End does not add any components to the set. |
data h :+: t
Type level Cons for enumerating type dependencies of a Component
Constructors
h :+: t |
Instances
(Methods a, Component a, SubHandlers b) => SubHandlers (:+: a b) | This is the instance that completes the definition of :+: and End as being the constructors of a type level list in SubHandlers. Note that since b needs to be an instance of SubHandlers, the list needs to be terminated with End. |
class (Serialize ev, Serialize res) => UpdateEvent ev res | ev -> res
Instances
UpdateEvent SetCheckpointState () | |
Typeable st => UpdateEvent (SetNewState st) () |
class (Serialize ev, Serialize res) => QueryEvent ev res | ev -> res
Instances
data Method st where
Method is the actual type that all Updates and Querys eventually
get lifted into via mkMethods
.
Constructors
Update :: UpdateEvent ev res => (ev -> Update st res) -> Method st | |
Query :: QueryEvent ev res => (ev -> Query st res) -> Method st |
methodType :: Method t -> String
Displays the type of a Method
class Methods a where
Class for enumerating the set of defined methods by the type of the state.
Instances should not be defined directly, but using mkMethods
data MethodMap where
type ComponentTree = Map String MethodMap
State type -> method map
type ComponentVersions = Map String [ByteString]
State type -> all versions
class (SubHandlers (Dependencies a), Serialize a) => Component a where
In order to be used as a part of Happstack's MACID state, a data type
needs to be an instance of Component. The minimal definition is
an initialValue and the type corresponding to the set of Dependencies.
Note that the SubHandlers condition will be automatically met if the
Dependencies is built from End
and :+:
with other instances of
Component and Methods
Associated Types
type Dependencies a
class SubHandlers a where
SubHandlers is used to build up the set of components corresponding to the instance type.
Methods
subHandlers :: a -> Collect ()
Instances
SubHandlers End | In correspondence with its role as [] in the type level list, the instance for End does not add any components to the set. |
(Methods a, Component a, SubHandlers b) => SubHandlers (:+: a b) | This is the instance that completes the definition of :+: and End as being the constructors of a type level list in SubHandlers. Note that since b needs to be an instance of SubHandlers, the list needs to be terminated with End. |
data Collection
Constructors
Collection ComponentTree ComponentVersions [IO ()] |
addItem :: MonadState Collection m => String -> MethodMap -> [ByteString] -> IO () -> m ()
type Collect = State Collection
collectHandlers :: (Methods a, Component a) => Proxy a -> (ComponentTree, ComponentVersions, [IO ()])