Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Required
- data Optional
- type FoldRequired mods = FoldRequired' False mods
- type family FoldRequired' (acc :: Bool) (mods :: [*]) :: Bool where ...
- data Lenient
- data Strict
- type FoldLenient mods = FoldLenient' False mods
- type family FoldLenient' (acc :: Bool) (mods :: [*]) :: Bool where ...
- type RequiredArgument mods a = If (FoldRequired mods) a (Maybe a)
- foldRequiredArgument :: forall mods a r. SBoolI (FoldRequired mods) => Proxy mods -> (a -> r) -> (Maybe a -> r) -> RequiredArgument mods a -> r
- unfoldRequiredArgument :: forall mods m a. (Monad m, SBoolI (FoldRequired mods), SBoolI (FoldLenient mods)) => Proxy mods -> m (RequiredArgument mods a) -> (Text -> m (RequiredArgument mods a)) -> Maybe (Either Text a) -> m (RequiredArgument mods a)
- type RequestArgument mods a = If (FoldRequired mods) (If (FoldLenient mods) (Either Text a) a) (Maybe (If (FoldLenient mods) (Either Text a) a))
- unfoldRequestArgument :: forall mods m a. (Monad m, SBoolI (FoldRequired mods), SBoolI (FoldLenient mods)) => Proxy mods -> m (RequestArgument mods a) -> (Text -> m (RequestArgument mods a)) -> Maybe (Either Text a) -> m (RequestArgument mods a)
Required / optional argument
Optional argument. Wrapped in Maybe
.
(KnownSymbol h, ToHttpApiData v) => AddHeader h v (Headers ((:) * fst rest) a) (Headers ((:) * (Header * h v) ((:) * fst rest)) a) Source # | |
(FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h) => BuildHeadersTo ((:) * (Header * h v) xs) Source # | |
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
.
FoldRequired' acc '[] = acc | |
FoldRequired' acc (Required ': mods) = FoldRequired' True mods | |
FoldRequired' acc (Optional ': mods) = FoldRequired' False mods | |
FoldRequired' acc (mod ': mods) = FoldRequired' acc mods |
Lenient / strict parsing
Strictly parsed argument. Not wrapped.
(KnownSymbol h, ToHttpApiData v) => AddHeader h v (Headers ((:) * fst rest) a) (Headers ((:) * (Header * h v) ((:) * fst rest)) a) Source # | |
(FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h) => BuildHeadersTo ((:) * (Header * h v) xs) Source # | |
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
.
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
type RequiredArgument mods a = If (FoldRequired mods) a (Maybe a) Source #
:: SBoolI (FoldRequired mods) | |
=> Proxy mods | |
-> (a -> r) | |
-> (Maybe a -> r) | |
-> RequiredArgument mods a | |
-> r |
Fold a RequiredAgument
into a value
unfoldRequiredArgument Source #
:: (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
.
type RequestArgument mods a = If (FoldRequired mods) (If (FoldLenient mods) (Either Text a) a) (Maybe (If (FoldLenient mods) (Either Text a) a)) Source #
unfoldRequestArgument Source #
:: (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
.