Hoogle Search

Within LTS Haskell 24.38 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. fromForm :: FromForm a => Form -> Either Text a

    http-api-data Web.Internal.FormUrlEncoded

    Parse Form into a value.

  2. gFromForm :: GFromForm t f => Proxy t -> FormOptions -> Form -> Either Text (f x)

    http-api-data Web.Internal.FormUrlEncoded

    No documentation available.

  3. gToForm :: GToForm t f => Proxy t -> FormOptions -> f x -> Form

    http-api-data Web.Internal.FormUrlEncoded

    No documentation available.

  4. genericFromForm :: (Generic a, GFromForm a (Rep a)) => FormOptions -> Form -> Either Text a

    http-api-data Web.Internal.FormUrlEncoded

    A Generic-based implementation of fromForm. This is used as a default implementation in FromForm. Note that this only works for records (i.e. product data types with named fields):

    data Person = Person
    { name :: String
    , age  :: Int
    } deriving (Generic)
    
    In this implementation each field's value gets decoded using parseQueryParam. Two field types are exceptions:
    • for values of type Maybe a an entry is parsed if present in the Form and the is decoded with parseQueryParam; if no entry is present result is Nothing;
    • for values of type [a] (except [Char]) all entries are parsed to produce a list of parsed values;
    Here's an example:
    data Post = Post
    { title    :: String
    , subtitle :: Maybe String
    , comments :: [String]
    } deriving (Generic, Show)
    
    instance FromForm Post
    
    >>> urlDecodeAsForm "comments=Nice%20post%21&comments=%2B1&title=Test" :: Either Text Post
    Right (Post {title = "Test", subtitle = Nothing, comments = ["Nice post!","+1"]})
    

  5. genericToForm :: (Generic a, GToForm a (Rep a)) => FormOptions -> a -> Form

    http-api-data Web.Internal.FormUrlEncoded

    A Generic-based implementation of toForm. This is used as a default implementation in ToForm. Note that this only works for records (i.e. product data types with named fields):

    data Person = Person
    { name :: String
    , age  :: Int
    } deriving (Generic)
    
    In this implementation each field's value gets encoded using toQueryParam. Two field types are exceptions:
    • for values of type Maybe a an entry is added to the Form only when it is Just x and the encoded value is toQueryParam x; Nothing values are omitted from the Form;
    • for values of type [a] (except [Char]) an entry is added for every item in the list; if the list is empty no entries are added to the Form;
    Here's an example:
    data Post = Post
    { title    :: String
    , subtitle :: Maybe String
    , comments :: [String]
    } deriving (Generic, Show)
    
    instance ToForm Post
    
    >>> urlEncodeAsFormStable Post { title = "Test", subtitle = Nothing, comments = ["Nice post!", "+1"] }
    "comments=Nice%20post%21&comments=%2B1&title=Test"
    

  6. parseFormKey :: FromFormKey k => Text -> Either Text k

    http-api-data Web.Internal.FormUrlEncoded

    Parse a key of a Form.

  7. toForm :: ToForm a => a -> Form

    http-api-data Web.Internal.FormUrlEncoded

    Convert a value into Form.

  8. toFormKey :: ToFormKey k => k -> Text

    http-api-data Web.Internal.FormUrlEncoded

    Render a key for a Form.

  9. unForm :: Form -> HashMap Text [Text]

    http-api-data Web.Internal.FormUrlEncoded

    No documentation available.

  10. urlDecodeAsForm :: FromForm a => ByteString -> Either Text a

    http-api-data Web.Internal.FormUrlEncoded

    This is a convenience function for decoding a application/x-www-form-urlencoded ByteString directly to a datatype that has an instance of FromForm. This is effectively fromForm <=< urlDecodeForm.

    >>> urlDecodeAsForm "name=Dennis&age=22" :: Either Text Person
    Right (Person {name = "Dennis", age = 22})
    

Page 502 of many | Previous | Next