servant-hateoas-0.3.1: HATEOAS extension for servant
Safe HaskellSafe-Inferred
LanguageGHC2021

Servant.Hateoas.ResourceServer

Synopsis

Type-Class

class HasResourceServer api m ct where Source #

A typeclass providing a function to turn an API into a resourceful API.

Methods

getResourceServer :: MonadIO m => Proxy m -> Proxy ct -> Proxy api -> ServerT (Resourcify api ct) m Source #

Instances

Instances details
(api ~ LayerApi l, rApi ~ Resourcify api ct, ServerT (Resourcify l ct) m ~ ResourcifyServer (ServerT l m) ct m, rServer ~ ResourcifyServer (ServerT l m) ct m, res ~ MkResource ct, buildFun ~ ReplaceHandler rServer [(String, ResourceLink)], Resource res, BuildLayerLinks (Resourcify l ct) m, PolyvariadicComp buildFun (IsFun buildFun), Return buildFun (IsFun buildFun) ~ [(String, ResourceLink)], Replace buildFun (m (res Intermediate)) (IsFun buildFun) ~ rServer) => HasResourceServer (l :: Layer) m ct Source # 
Instance details

Defined in Servant.Hateoas.ResourceServer

Methods

getResourceServer :: Proxy m -> Proxy ct -> Proxy l -> ServerT (Resourcify l ct) m Source #

(server ~ ServerT api m, ServerT (Resourcify api ct) m ~ ResourcifyServer server ct m, mkLink ~ MkLink api Link, res ~ MkResource ct, Resource res, ToResource res a, HasHandler api, HasLink api, IsElem api api, PolyvariadicComp2 server mkLink (IsFun server), Return2 server mkLink (IsFun server) ~ (m a, Link), Replace2 server mkLink (m (res a)) (IsFun mkLink) ~ ResourcifyServer server ct m) => HasResourceServer (api :: Type) m ct Source #

Adds a self-link to the resource.

Instance details

Defined in Servant.Hateoas.ResourceServer

Methods

getResourceServer :: Proxy m -> Proxy ct -> Proxy api -> ServerT (Resourcify api ct) m Source #

(HasResourceServer a m ct, HasResourceServer b m ct) => HasResourceServer (a :<|> b :: Type) m ct Source # 
Instance details

Defined in Servant.Hateoas.ResourceServer

Methods

getResourceServer :: Proxy m -> Proxy ct -> Proxy (a :<|> b) -> ServerT (Resourcify (a :<|> b) ct) m Source #

HasResourceServer ('[] :: [Layer]) m ct Source # 
Instance details

Defined in Servant.Hateoas.ResourceServer

Methods

getResourceServer :: Proxy m -> Proxy ct -> Proxy '[] -> ServerT (Resourcify '[] ct) m Source #

(MonadIO m, HasResourceServer ls m ct, HasResourceServer l m ct, BuildLayerLinks (Resourcify l ct) m) => HasResourceServer (l ': ls :: [Layer]) m ct Source # 
Instance details

Defined in Servant.Hateoas.ResourceServer

Methods

getResourceServer :: Proxy m -> Proxy ct -> Proxy (l ': ls) -> ServerT (Resourcify (l ': ls) ct) m Source #

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.

Equations

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

Equations

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)