glue-common-0.4.1: Make better services.

Safe HaskellNone
LanguageHaskell2010

Glue.Types

Description

Module containing the root types and some support functionality.

Synopsis

Documentation

type BasicService m a b = a -> m b Source

Type alias for the most basic form of a service supported.

type MultiGetService m a b = BasicService m (MultiGetRequest a) (MultiGetResponse a b) Source

Type alias for a service that looks up multiple values and returns multiple results.

type MultiGetRequest a = HashSet a Source

Type alias for the request portion of a MultiGetService.

type MultiGetResponse a b = HashMap a b Source

Type alias for the response portion of a MultiGetService.

type ResultVar a = MVar (Either SomeException a) Source

Type alias for the common container of a result used in asynchronous calls.

type MToIO m = forall a. m a -> IO a Source

Run the m into an IO instance for a response.

type FailOrSuccess a b = Either SomeException (MultiGetResponse a b) Source

Type alias for either a failure or a successful response.

multiGetToBasic :: (Hashable a, Eq a, Monad m) => MultiGetService m a b -> BasicService m a (Maybe b) Source

Convert a MultiGetService into a BasicService that looks up a single key, returning a Maybe which determines if the value was present.

getResult :: MonadBaseControl IO m => ResultVar a -> m a Source

Obtain a result from a ResultVar in the Monad of your choice.

makeCall :: (Eq a, Hashable a, MonadBaseControl IO m) => MultiGetService m a b -> HashSet a -> m (FailOrSuccess a b) Source

Makes a multi-get call and handles the error bundling it up inside an Either.