rest-core-0.39: Rest API library.

Safe HaskellNone
LanguageHaskell98

Rest.Resource

Description

A Resource type for representing a REST resource, as well as smart constructors for empty resources which can then be filled in using record updates.

Synopsis

Documentation

data Resource m s sid mid aid where Source #

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.

Constructors

Resource :: (Applicative m, Monad m, Applicative s, Monad s) => {..} -> Resource m s sid mid aid 

Fields

mkResource :: (Applicative m, Monad m, Applicative s, Monad s) => (forall b. sid -> s b -> m b) -> Resource m s sid Void Void Source #

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 Void Source #

Make a resource that doesn't add any information for subresources (i.e. enter is set to id).

mkResourceReader :: (Applicative m, Monad m) => Resource m (ReaderT sid m) sid Void Void Source #

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 Void Source #

Make a resource that provides the single resource identifier to its subresources, by giving a conversion function to a ReaderT. If s is a newtype around ReaderT, for example, the function should unwrap the newtype.