Hoogle Search

Within LTS Haskell 24.45 (ghc-9.10.3)

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

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

    http-api-data Web.Internal.FormUrlEncoded

    No documentation available.

  2. 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})
    

  3. urlDecodeForm :: ByteString -> Either Text Form

    http-api-data Web.Internal.FormUrlEncoded

    Decode an application/x-www-form-urlencoded ByteString to a Form. Key-value pairs get decoded normally:

    >>> urlDecodeForm "name=Greg&lastname=Weber"
    Right (fromList [("lastname","Weber"),("name","Greg")])
    
    Keys with no values get decoded to pairs with empty values.
    >>> urlDecodeForm "is_test"
    Right (fromList [("is_test","")])
    
    Empty keys are allowed:
    >>> urlDecodeForm "=foobar"
    Right (fromList [("","foobar")])
    
    The empty string gets decoded into an empty Form:
    >>> urlDecodeForm ""
    Right (fromList [])
    
    Everything is un-escaped with unEscapeString:
    >>> urlDecodeForm "fullname=Andres%20L%C3%B6h"
    Right (fromList [("fullname","Andres L\246h")])
    
    Improperly formed strings result in an error:
    >>> urlDecodeForm "this=has=too=many=equals"
    Left "not a valid pair: this=has=too=many=equals"
    

  4. urlEncodeAsForm :: ToForm a => a -> ByteString

    http-api-data Web.Internal.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 urlEncodeForm . toForm. _NOTE:_ this encoding is unstable and may result in different key order (but not values). For a stable encoding see urlEncodeAsFormStable.

  5. urlEncodeAsFormStable :: ToForm a => a -> ByteString

    http-api-data Web.Internal.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"
    

  6. urlEncodeForm :: Form -> ByteString

    http-api-data Web.Internal.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.

  7. urlEncodeFormStable :: Form -> ByteString

    http-api-data Web.Internal.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"
    

  8. class Uniform a

    mwc-random System.Random.MWC

    The class of types for which a uniformly distributed value can be drawn from all possible values of the type.

  9. class UniformRange a

    mwc-random System.Random.MWC

    The class of types for which a uniformly distributed value can be drawn from a range.

  10. uniform :: (Variate a, PrimMonad m) => Gen (PrimState m) -> m a

    mwc-random System.Random.MWC

    Generate a single uniformly distributed random variate. The range of values produced varies by type:

    • For fixed-width integral types, the type's entire range is used.
    • For floating point numbers, the range (0,1] is used. Zero is explicitly excluded, to allow variates to be used in statistical calculations that require non-zero values (e.g. uses of the log function).
    To generate a Float variate with a range of [0,1), subtract 2**(-33). To do the same with Double variates, subtract 2**(-53).

Page 504 of many | Previous | Next