Hoogle Search

Within LTS Haskell 24.64 (ghc-9.10.3)

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

  1. 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"
    

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

  3. 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"
    

  4. 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.

  5. 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"
    

  6. 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.

  7. class UniformRange a

    mwc-random System.Random.MWC

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

  8. 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).

  9. uniformM :: (Uniform a, StatefulGen g m) => g -> m a

    mwc-random System.Random.MWC

    Generates a value uniformly distributed over all possible values of that type. There is a default implementation via Generic:

    >>> :set -XDeriveGeneric -XDeriveAnyClass
    
    >>> import GHC.Generics (Generic)
    
    >>> import System.Random.Stateful
    
    >>> data MyBool = MyTrue | MyFalse deriving (Show, Generic, Finite, Uniform)
    
    >>> data Action = Code MyBool | Eat (Maybe Bool) | Sleep deriving (Show, Generic, Finite, Uniform)
    
    >>> gen <- newIOGenM (mkStdGen 42)
    
    >>> uniformListM 10 gen :: IO [Action]
    [Code MyTrue,Code MyTrue,Eat Nothing,Code MyFalse,Eat (Just False),Eat (Just True),Eat Nothing,Eat (Just False),Sleep,Code MyFalse]
    

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

    mwc-random System.Random.MWC

    Generate single uniformly distributed random variable in a given range.

    • For integral types inclusive range is used.
    • For floating point numbers range (a,b] is used if one ignores rounding errors.

Page 389 of many | Previous | Next