Convert a value into Form.
An example type and instance:
{-# LANGUAGE OverloadedLists #-}
data Person = Person
{ name :: String
, age :: Int }
instance ToForm Person where
toForm person =
[ ("name", toQueryParam (name person))
, ("age", toQueryParam (age person)) ]
Instead of manually writing ToForm instances you can
use a default generic implementation of toForm.
To do that, simply add deriving Generic clause to your datatype
and declare a ToForm instance for your datatype without
giving definition for toForm.
For instance, the previous example can be simplified into this:
data Person = Person
{ name :: String
, age :: Int
} deriving (Generic)
instance ToForm Person
The default implementation of toForm is genericToForm.
Instances5ToForm
ToForm FormDefined in http-api-data-0.6.1 · Web.Internal.FormUrlEncodedToHttpApiData v => ToForm (IntMap [v])Defined in http-api-data-0.6.1 · Web.Internal.FormUrlEncoded(ToFormKey k, ToHttpApiData v) => ToForm [(k, v)]Defined in http-api-data-0.6.1 · Web.Internal.FormUrlEncoded(ToFormKey k, ToHttpApiData v) => ToForm (Map k [v])Defined in http-api-data-0.6.1 · Web.Internal.FormUrlEncoded(ToFormKey k, ToHttpApiData v) => ToForm (HashMap k [v])Defined in http-api-data-0.6.1 · Web.Internal.FormUrlEncoded