Safe Haskell | None |
---|---|
Language | Haskell2010 |
Various useful functions.
Synopsis
- mergeVal :: Value -> Value -> Value
- writeForm :: (ConvertibleStrings α Text, ConvertibleStrings β Text, ConvertibleStrings ByteString γ) => [(α, β)] -> γ
- readForm :: (ConvertibleStrings Text α, ConvertibleStrings Text β, ConvertibleStrings γ ByteString) => γ -> Maybe [(α, β)]
- formList :: Form -> [(Text, Text)]
- formToObject :: [(Text, Text)] -> Value
- formKey :: Parser [Text]
- parseUri :: ConvertibleStrings α String => α -> URI
- slugify :: Text -> Text
- errText :: ServantErr -> ByteString -> ServantErr
- throwErrText :: MonadThrow μ => ServantErr -> ByteString -> μ α
Documentation
mergeVal :: Value -> Value -> Value Source #
Merges two JSON objects recursively. When the values are not objects, just returns the left one.
writeForm :: (ConvertibleStrings α Text, ConvertibleStrings β Text, ConvertibleStrings ByteString γ) => [(α, β)] -> γ Source #
Encodes key-value data as application/x-www-form-urlencoded.
readForm :: (ConvertibleStrings Text α, ConvertibleStrings Text β, ConvertibleStrings γ ByteString) => γ -> Maybe [(α, β)] Source #
Decodes key-value data from application/x-www-form-urlencoded.
formList :: Form -> [(Text, Text)] Source #
Reads a Servant incoming form as a list of key-value pairs (for use in FromForm instances).
formToObject :: [(Text, Text)] -> Value Source #
Converts a flat key-value form with keys in typical nesting syntax (e.g. "one[two][three]") to an Aeson Value with nesting (for use in FromForm instances).
slugify :: Text -> Text Source #
Prepares text for inclusion in a URL.
>>>
:set -XOverloadedStrings
>>>
slugify "Hello & World!"
"hello-and-world"
errText :: ServantErr -> ByteString -> ServantErr Source #
Creates a simple text/plain ServantErr.
throwErrText :: MonadThrow μ => ServantErr -> ByteString -> μ α Source #
Creates and throws a simple text/plain ServantErr.