| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Web.Hyperbole.Data.Param
Synopsis
- newtype Param = Param {}
- newtype ParamValue = ParamValue {}
- class ToParam a where
- toParam :: a -> ParamValue
- class FromParam a where
- parseParam :: ParamValue -> Either String a
- decodeFormValue :: Maybe Text -> Either String a
- parseQueryParam :: FromHttpApiData a => ParamValue -> Either String a
- toQueryParam :: ToHttpApiData a => a -> ParamValue
- showParam :: Show a => a -> ParamValue
- readParam :: Read a => ParamValue -> Either String a
- genericToParam :: (Generic a, GToJSON Zero (Rep a)) => a -> ParamValue
- genericParseParam :: (Generic a, GFromJSON Zero (Rep a)) => ParamValue -> Either String a
- jsonOptions :: Options
- jsonParam :: ToJSON a => a -> ParamValue
- jsonParse :: FromJSON a => ParamValue -> Either String a
Documentation
newtype ParamValue Source #
Encode arbitrarily complex data into url form encoded data
Constructors
| ParamValue | |
Instances
class ToParam a where Source #
sessions, forms, and querys all encode data as query strings. ToParam and FromParam control how a datatype is encoded to a parameter.
-
This is equivalent to Web.HttpApiData, which is missing some instances and has some strange defaults
data AppColor = White | Red | Green deriving (Show, Generic,ToParam,FromParam)
Minimal complete definition
Nothing
Methods
toParam :: a -> ParamValue Source #
Instances
class FromParam a where Source #
Decode data from a query, session, or form parameter value
data AppColor = White | Red | Green deriving (Show, Generic,ToParam,FromParam)
Minimal complete definition
Nothing
Methods
parseParam :: ParamValue -> Either String a Source #
default parseParam :: (Generic a, GFromJSON Zero (Rep a)) => ParamValue -> Either String a Source #
Instances
parseQueryParam :: FromHttpApiData a => ParamValue -> Either String a Source #
toQueryParam :: ToHttpApiData a => a -> ParamValue Source #
showParam :: Show a => a -> ParamValue Source #
Encode a Show as a query param
genericToParam :: (Generic a, GToJSON Zero (Rep a)) => a -> ParamValue Source #
genericParseParam :: (Generic a, GFromJSON Zero (Rep a)) => ParamValue -> Either String a Source #
jsonParam :: ToJSON a => a -> ParamValue Source #