Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- class HasResourceServer api m ct where
- getResourceServer :: MonadIO m => Proxy m -> Proxy ct -> Proxy api -> ServerT (Resourcify api ct) m
- type family Resourcify api ct where ...
- type family ResourcifyServer server ct m where ...
Type-Class
class HasResourceServer api m ct where Source #
A typeclass providing a function to turn an API into a resourceful API.
getResourceServer :: MonadIO m => Proxy m -> Proxy ct -> Proxy api -> ServerT (Resourcify api ct) m Source #
Instances
Type-Families
type family Resourcify api ct where ... Source #
Turns an API into a resourceful API by replacing the response type of each endpoint with a resource type.
Resourcify EmptyAPI ct = EmptyAPI | |
Resourcify (a :<|> b) ct = Resourcify a ct :<|> Resourcify b ct | |
Resourcify (a :> b) ct = a :> Resourcify b ct | |
Resourcify (Verb m s _ a) ct = Verb m s '[ct] (MkResource ct a) | |
Resourcify ('Layer api cs verb) ct = 'Layer (Resourcify api ct) (Resourcify cs ct) (Resourcify verb ct) | |
Resourcify (x : xs) ct = Resourcify x ct : Resourcify xs ct | |
Resourcify a _ = a |
type family ResourcifyServer server ct m where ... Source #
Turns a ServerT
into a resourceful ServerT
by replacing the result type m a
of the function server
with m (res a)
where
res :=
.MkResource
ct
Together with Resourcify
the following Constraint
holds:
forall api ct m. ServerT (Resourcify api) ct m ~ ResourcifyServer (ServerT api m) ct m
ResourcifyServer EmptyServer ct m = EmptyServer | |
ResourcifyServer (a :<|> b) ct m = ResourcifyServer a ct m :<|> ResourcifyServer b ct m | |
ResourcifyServer (a -> b) ct m = a -> ResourcifyServer b ct m | |
ResourcifyServer (m a) ct m = m (MkResource ct a) | |
ResourcifyServer (f a) ct m = f (ResourcifyServer a ct m) |