Safe Haskell | None |
---|
A Resource
type for representing a REST resource, as well as
smart constructors for empty resources which can them be filled in
using record updates.
- data Resource m s sid mid aid where
- Resource :: (Applicative m, Monad m, Applicative s, Monad s) => {
- name :: String
- description :: String
- schema :: Schema sid mid aid
- private :: Bool
- enter :: forall b. sid -> s b -> m b
- list :: mid -> ListHandler m
- statics :: aid -> Handler m
- get :: Maybe (Handler s)
- update :: Maybe (Handler s)
- remove :: Maybe (Handler s)
- create :: Maybe (Handler m)
- actions :: [(String, Handler s)]
- selects :: [(String, Handler s)]
- Resource :: (Applicative m, Monad m, Applicative s, Monad s) => {
- mkResource :: (Applicative m, Monad m, Applicative s, Monad s) => (forall b. sid -> s b -> m b) -> Resource m s sid Void Void
- mkResourceId :: (Applicative m, Monad m) => Resource m m sid Void Void
- mkResourceReader :: (Applicative m, Monad m) => Resource m (ReaderT sid m) sid Void Void
- mkResourceReaderWith :: (Applicative m, Monad m, Applicative s, Monad s) => (forall b. s b -> ReaderT sid m b) -> Resource m s sid Void Void
- newtype Void = Void {
- magic :: forall a. a
The Resource
type.
data Resource m s sid mid aid whereSource
The Resource
data type represents a single resource in a REST
API. Handlers run in a monad m
, while things below this resource
run in s
. The identifiers sid
, mid
and aid
identify a
single item, a listing and an action.
Resource :: (Applicative m, Monad m, Applicative s, Monad s) => String -> String -> Schema sid mid aid -> Bool -> (forall b. sid -> s b -> m b) -> (mid -> ListHandler m) -> (aid -> Handler m) -> Maybe (Handler s) -> Maybe (Handler s) -> Maybe (Handler s) -> Maybe (Handler m) -> [(String, Handler s)] -> [(String, Handler s)] -> Resource m s sid mid aid | |
|
Smart constructors for empty resources.
mkResource :: (Applicative m, Monad m, Applicative s, Monad s) => (forall b. sid -> s b -> m b) -> Resource m s sid Void VoidSource
Create an empty resource given an enter
function. It has no
name, so if you wish to route to this resource, you should set one.
mkResourceId :: (Applicative m, Monad m) => Resource m m sid Void VoidSource
mkResourceReader :: (Applicative m, Monad m) => Resource m (ReaderT sid m) sid Void VoidSource
Make a resource that provides the single resource identifier to its subresources.
mkResourceReaderWith :: (Applicative m, Monad m, Applicative s, Monad s) => (forall b. s b -> ReaderT sid m b) -> Resource m s sid Void VoidSource