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. urlEncodeAsFormStable :: ToForm a => a -> ByteString

    http-api-data Web.FormUrlEncoded

    This is a convenience function for encoding a datatype that has instance of ToForm directly to a application/x-www-form-urlencoded ByteString. This is effectively urlEncodeFormStable . toForm.

    >>> urlEncodeAsFormStable Person {name = "Dennis", age = 22}
    "age=22&name=Dennis"
    

  2. urlEncodeForm :: Form -> ByteString

    http-api-data Web.FormUrlEncoded

    Encode a Form to an application/x-www-form-urlencoded ByteString. _NOTE:_ this encoding is unstable and may result in different key order (but not values). For a stable encoding see urlEncodeFormStable.

  3. urlEncodeFormStable :: Form -> ByteString

    http-api-data Web.FormUrlEncoded

    Encode a Form to an application/x-www-form-urlencoded ByteString. For an unstable (but faster) encoding see urlEncodeForm. Key-value pairs get encoded to key=value and separated by &:

    >>> urlEncodeFormStable [("name", "Julian"), ("lastname", "Arni")]
    "lastname=Arni&name=Julian"
    
    Keys with empty values get encoded to just key (without the = sign):
    >>> urlEncodeFormStable [("is_test", "")]
    "is_test"
    
    Empty keys are allowed too:
    >>> urlEncodeFormStable [("", "foobar")]
    "=foobar"
    
    However, if both key and value are empty, the key-value pair is ignored. (This prevents urlDecodeForm . urlEncodeFormStable from being a true isomorphism).
    >>> urlEncodeFormStable [("", "")]
    ""
    
    Everything is escaped with escapeURIString isUnreserved:
    >>> urlEncodeFormStable [("fullname", "Andres Löh")]
    "fullname=Andres%20L%C3%B6h"
    

  4. class FromForm a

    http-api-data Web.Internal.FormUrlEncoded

    Parse Form into a value. An example type and instance:

    data Person = Person
    { name :: String
    , age  :: Int }
    
    instance FromForm Person where
    fromForm f = Person
    <$> parseUnique "name" f
    <*> parseUnique "age"  f
    
    Instead of manually writing FromForm instances you can use a default generic implementation of fromForm. To do that, simply add deriving Generic clause to your datatype and declare a FromForm instance for your datatype without giving definition for fromForm. For instance, the previous example can be simplified into this:
    data Person = Person
    { name :: String
    , age  :: Int
    } deriving (Generic)
    
    instance FromForm Person
    
    The default implementation of fromForm is genericFromForm. It only works for records and it will use parseQueryParam for each field's value.

  5. class FromFormKey k

    http-api-data Web.Internal.FormUrlEncoded

    Typeclass for types that can be parsed from keys of a Form. This is the reverse of ToFormKey.

  6. class GFromForm (t :: k) (f :: Type -> Type)

    http-api-data Web.Internal.FormUrlEncoded

    No documentation available.

  7. class GToForm (t :: k) (f :: Type -> Type)

    http-api-data Web.Internal.FormUrlEncoded

    No documentation available.

  8. class ToForm a

    http-api-data Web.Internal.FormUrlEncoded

    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.

  9. class ToFormKey k

    http-api-data Web.Internal.FormUrlEncoded

    Typeclass for types that can be used as keys in a Form-like container (like Map).

  10. defaultFormOptions :: FormOptions

    http-api-data Web.Internal.FormUrlEncoded

    Default encoding FormOptions.

    FormOptions
    { fieldLabelModifier = id
    }
    

Page 501 of many | Previous | Next