Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- class ToResource api res a where
- toResource :: a -> res a
- toResource' :: Proxy api -> Proxy res -> a -> res a
- class ToCollection api res a where
- toCollection :: Foldable f => f a -> res a
- toCollection' :: Foldable f => Proxy api -> Proxy res -> f a -> res a
- class Resource res where
- class Resource res => EmbeddingResource res where
- class Resource res => CollectingResource res where
- collect :: a -> res a -> res a
- data HRel = HRel {}
- class Related a where
- class BuildRels api rs a where
- selfLink :: forall api a id. (Related a, HasField (IdSelName a) a id, IsElem (GetOneApi a) api, HasLink (GetOneApi a), MkLink (GetOneApi a) Link ~ (id -> Link)) => Proxy api -> a -> (String, Link)
- relatedLinks :: forall api a. (Related a, BuildRels api (Relations a) a) => Proxy api -> a -> [(String, Link)]
- defaultLinks :: forall api a id. (Related a, HasField (IdSelName a) a id, IsElem (GetOneApi a) api, HasLink (GetOneApi a), MkLink (GetOneApi a) Link ~ (id -> Link), BuildRels api (Relations a) a) => Proxy api -> a -> [(String, Link)]
Resource
Construction
class ToResource api res a where Source #
Class for converting values of a
to their respective Resource-Representation.
toResource :: a -> res a Source #
Converts a value into it's Resource-Representation.
toResource' :: Proxy api -> Proxy res -> a -> res a Source #
Like toResource
but takes proxies for ambiguity.
Instances
(Related a, HasField (IdSelName a) a id, IsElem (GetOneApi a) api, HasLink (GetOneApi a), MkLink (GetOneApi a) Link ~ (id -> Link), BuildRels api (Relations a) a, Resource HALResource) => ToResource (api :: Type) HALResource a Source # | |
Defined in Servant.Hateoas.ContentType.HAL toResource :: a -> HALResource a Source # toResource' :: Proxy api -> Proxy HALResource -> a -> HALResource a Source # |
class ToCollection api res a where Source #
Class for converting multiple values of a
to their respective collection-like representation.
toCollection :: Foldable f => f a -> res a Source #
Converts many values into their Collection-Representation.
toCollection' :: Foldable f => Proxy api -> Proxy res -> f a -> res a Source #
Like toCollection
but takes proxies for ambiguity.
Instances
(Related a, HasField (IdSelName a) a id, IsElem (GetOneApi a) api, HasLink (GetOneApi a), MkLink (GetOneApi a) Link ~ (id -> Link), BuildRels api (Relations a) a, Resource CollectionResource) => ToCollection (api :: Type) CollectionResource a Source # | |
Defined in Servant.Hateoas.ContentType.Collection toCollection :: Foldable f => f a -> CollectionResource a Source # toCollection' :: Foldable f => Proxy api -> Proxy CollectionResource -> f a -> CollectionResource a Source # |
Modification
class Resource res where Source #
Class for resources that carry Hypermedia-Relations.
Instances
Resource CollectionItem Source # | |
Defined in Servant.Hateoas.ContentType.Collection addLink :: forall (a :: k). (String, Link) -> CollectionItem a -> CollectionItem a Source # | |
Resource CollectionResource Source # | |
Defined in Servant.Hateoas.ContentType.Collection addLink :: forall (a :: k). (String, Link) -> CollectionResource a -> CollectionResource a Source # | |
Resource HALResource Source # | |
Defined in Servant.Hateoas.ContentType.HAL addLink :: forall (a :: k). (String, Link) -> HALResource a -> HALResource a Source # |
class Resource res => EmbeddingResource res where Source #
Class for Resource
s that can embed other resources.
embed :: ToJSON e => (String, e) -> res a -> res a Source #
Embed a resource b
with its relation rel
as tuple (rel, b)
.
Instances
EmbeddingResource HALResource Source # | |
Defined in Servant.Hateoas.ContentType.HAL embed :: forall e (a :: k). ToJSON e => (String, e) -> HALResource a -> HALResource a Source # |
class Resource res => CollectingResource res where Source #
Class for Resource
s that can collect multiple resources.
Instances
CollectingResource CollectionResource Source # | |
Defined in Servant.Hateoas.ContentType.Collection collect :: a -> CollectionResource a -> CollectionResource a Source # |
Hypermedia-Relations
Type
Data-Kind for Hypermedia-Relations.
Class
Types that have Hypermedia-Relations.
type IdSelName a :: Symbol Source #
Name of the record selector that holds the resources identifier
type GetOneApi a :: Type Source #
Servant-Endpoint for retrieving one a
by its identifier
type CollectionName a :: Symbol Source #
Name for collected values
type CollectionName a = "items"
type Relations a :: [HRel] Source #
List of all relations a
has
Construction
class BuildRels api rs a where Source #
Class for deriving Hypermedia-Relations for types.
selfLink :: forall api a id. (Related a, HasField (IdSelName a) a id, IsElem (GetOneApi a) api, HasLink (GetOneApi a), MkLink (GetOneApi a) Link ~ (id -> Link)) => Proxy api -> a -> (String, Link) Source #
Generates the pair ("self", link)
where link
is the Link
to a
itself.
relatedLinks :: forall api a. (Related a, BuildRels api (Relations a) a) => Proxy api -> a -> [(String, Link)] Source #
Generates pairs (rel, link)
for all related resources as defined with Relations
.
defaultLinks :: forall api a id. (Related a, HasField (IdSelName a) a id, IsElem (GetOneApi a) api, HasLink (GetOneApi a), MkLink (GetOneApi a) Link ~ (id -> Link), BuildRels api (Relations a) a) => Proxy api -> a -> [(String, Link)] Source #
Generate Hypermedia-Links by default.
defaultLinks api x = selfLink api x : relatedLinks api x