servant-0.19.1: A family of combinators for defining webservices APIs
Safe Haskell None
Language Haskell2010

Servant.API.Modifiers

Synopsis

Required / optional argument

data Required Source #

Required argument. Not wrapped.

data Optional Source #

Optional argument. Wrapped in Maybe .

Instances

Instances details
( KnownSymbol h, ToHttpApiData v) => AddHeader h v ( Headers (fst ': rest) a) ( Headers ( Header h v ': (fst ': rest)) a) Source #
Instance details

Defined in Servant.API.ResponseHeaders

Methods

addOptionalHeader :: ResponseHeader h v -> Headers (fst ': rest) a -> Headers ( Header h v ': (fst ': rest)) a

HasResponseHeader h a ( Header h a ': rest) Source #
Instance details

Defined in Servant.API.ResponseHeaders

( KnownSymbol h, GetHeadersFromHList rest, ToHttpApiData v) => GetHeaders' ( Header h v ': rest) Source #
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeaders' :: Headers ( Header h v ': rest) a -> [ Header0 ]

( FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h) => BuildHeadersTo ( Header h v ': xs) Source #
Instance details

Defined in Servant.API.ResponseHeaders

type FoldRequired mods = FoldRequired' ' False mods Source #

Fold modifier list to decide whether argument is required.

>>> :kind! FoldRequired '[Required, Description "something"]
FoldRequired '[Required, Description "something"] :: Bool
= 'True
>>> :kind! FoldRequired '[Required, Optional]
FoldRequired '[Required, Optional] :: Bool
= 'False
>>> :kind! FoldRequired '[]
FoldRequired '[] :: Bool
= 'False

type family FoldRequired' (acc :: Bool ) (mods :: [*]) :: Bool where ... Source #

Implementation of FoldRequired .

Lenient / strict parsing

data Lenient Source #

Leniently parsed argument, i.e. parsing never fail. Wrapped in Either Text .

data Strict Source #

Strictly parsed argument. Not wrapped.

Instances

Instances details
( KnownSymbol h, ToHttpApiData v) => AddHeader h v ( Headers (fst ': rest) a) ( Headers ( Header h v ': (fst ': rest)) a) Source #
Instance details

Defined in Servant.API.ResponseHeaders

Methods

addOptionalHeader :: ResponseHeader h v -> Headers (fst ': rest) a -> Headers ( Header h v ': (fst ': rest)) a

HasResponseHeader h a ( Header h a ': rest) Source #
Instance details

Defined in Servant.API.ResponseHeaders

( KnownSymbol h, GetHeadersFromHList rest, ToHttpApiData v) => GetHeaders' ( Header h v ': rest) Source #
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeaders' :: Headers ( Header h v ': rest) a -> [ Header0 ]

( FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h) => BuildHeadersTo ( Header h v ': xs) Source #
Instance details

Defined in Servant.API.ResponseHeaders

type FoldLenient mods = FoldLenient' ' False mods Source #

Fold modifier list to decide whether argument should be parsed strictly or leniently.

>>> :kind! FoldLenient '[]
FoldLenient '[] :: Bool
= 'False

type family FoldLenient' (acc :: Bool ) (mods :: [*]) :: Bool where ... Source #

Implementation of FoldLenient .

Equations

FoldLenient' acc '[] = acc
FoldLenient' acc ( Lenient ': mods) = FoldLenient' ' True mods
FoldLenient' acc ( Strict ': mods) = FoldLenient' ' False mods
FoldLenient' acc (mod ': mods) = FoldLenient' acc mods

Utilities

foldRequiredArgument Source #

Arguments

:: forall mods a r. SBoolI ( FoldRequired mods)
=> Proxy mods
-> (a -> r)

Required

-> ( Maybe a -> r)

Optional

-> RequiredArgument mods a
-> r

Fold a RequiredAgument into a value

unfoldRequiredArgument Source #

Arguments

:: forall mods m a. ( Monad m, SBoolI ( FoldRequired mods), SBoolI ( FoldLenient mods))
=> Proxy mods
-> m ( RequiredArgument mods a)

error when argument is required

-> ( Text -> m ( RequiredArgument mods a))

error when argument is strictly parsed

-> Maybe ( Either Text a)

value

-> m ( RequiredArgument mods a)

Unfold a value into a RequiredArgument .

unfoldRequestArgument Source #

Arguments

:: forall mods m a. ( Monad m, SBoolI ( FoldRequired mods), SBoolI ( FoldLenient mods))
=> Proxy mods
-> m ( RequestArgument mods a)

error when argument is required

-> ( Text -> m ( RequestArgument mods a))

error when argument is strictly parsed

-> Maybe ( Either Text a)

value

-> m ( RequestArgument mods a)

Unfold a value into a RequestArgument .