Copyright | Alej Cabrera 2015 |
---|---|
License | BSD-3 |
Maintainer | cpp.cabrera@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
- data Result a
- data P a
- parse :: (a -> P b) -> a -> Result b
- parseMaybe :: (a -> P b) -> a -> Maybe b
- parseEither :: (a -> P b) -> a -> Either Error b
- (<?>) :: P a -> Text -> P a
- freeform :: Text -> P a
- malformed :: Reason -> Text -> P a
- missing :: Loc -> P a
- data Loc
- type Reason = Text
- data Error
- toEnv :: Request -> Env
- toEnvWithForm :: Request -> [(Text, Text)] -> Env
- toEnvRaw :: Request -> ByteString -> Env
- data Env
- class FromEnv a where
- intQ :: (Read a, Integral a) => Text -> Env -> P a
- boolQ :: Text -> Env -> P Bool
- floatQ :: (Read a, Fractional a) => Text -> Env -> P a
- textQ :: Text -> Env -> P Text
- bytesQ :: (Text -> ByteString) -> Text -> Env -> P ByteString
- intQM :: (Read a, Integral a) => Text -> Env -> P (Maybe a)
- floatQM :: (Read a, Fractional a) => Text -> Env -> P (Maybe a)
- textQM :: Text -> Env -> P (Maybe Text)
- bytesQM :: (Text -> ByteString) -> Text -> Env -> P (Maybe ByteString)
- intF :: (Read a, Integral a) => Text -> Env -> P a
- boolF :: Text -> Env -> P Bool
- floatF :: (Read a, Fractional a) => Text -> Env -> P a
- textF :: Text -> Env -> P Text
- bytesF :: (Text -> ByteString) -> Text -> Env -> P ByteString
- intFM :: (Read a, Integral a) => Text -> Env -> P (Maybe a)
- floatFM :: (Read a, Fractional a) => Text -> Env -> P (Maybe a)
- textFM :: Text -> Env -> P (Maybe Text)
- bytesFM :: (Text -> ByteString) -> Text -> Env -> P (Maybe ByteString)
- intH :: (Integral a, Read a) => CI Text -> Env -> P a
- boolH :: CI Text -> Env -> P Bool
- floatH :: (Fractional a, Read a) => CI Text -> Env -> P a
- textH :: CI Text -> Env -> P Text
- bytesH :: (Text -> ByteString) -> CI Text -> Env -> P ByteString
- intHM :: (Integral a, Read a) => CI Text -> Env -> P (Maybe a)
- floatHM :: (Fractional a, Read a) => CI Text -> Env -> P (Maybe a)
- textHM :: CI Text -> Env -> P (Maybe Text)
- bytesHM :: (Text -> ByteString) -> CI Text -> Env -> P (Maybe ByteString)
- choice :: [P a] -> P a
Primitive parsing data types
Primitive parsing functions
parseMaybe :: (a -> P b) -> a -> Maybe b Source
parseEither :: (a -> P b) -> a -> Either Error b Source
Error generation and parser annotation
Error types
Generating parsing environment
toEnv :: Request -> Env Source
Construct an Env without parsing any form parameters This is ideal if you're not consuming any form data.
toEnvWithForm :: Request -> [(Text, Text)] -> Env Source
Construct an Env from a Request and an association list of form parameters
If a framework exposes parameters in this fashion (Spock, Scotty),
use this over toEnvRaw
. It's likely the framework consumes the
request body when data is sent along using content-type
'application/x-www-form-urlencoded'
toEnvRaw :: Request -> ByteString -> Env Source
Expects form data via request body ByteString This is appropriate if you're programming with raw Network.Wai NOTE: if you're expecting form data, and the form data is in an invalid format this will happily construct an Env with empty form data
Parser driving type class
Allows for the parsing of a data type a
from an Env
Derived combinators, query parameters
floatQ :: (Read a, Fractional a) => Text -> Env -> P a Source
Require a parameter as a fractional type
bytesQ :: (Text -> ByteString) -> Text -> Env -> P ByteString Source
Require a parameter as bytes, applying the encoding function f
floatQM :: (Read a, Fractional a) => Text -> Env -> P (Maybe a) Source
Optional parameter as fractional
bytesQM :: (Text -> ByteString) -> Text -> Env -> P (Maybe ByteString) Source
Optional header as bytes, applying the encoding function f
Derived combinators, form parameters
floatF :: (Read a, Fractional a) => Text -> Env -> P a Source
Require a parameter as a fractional type
bytesF :: (Text -> ByteString) -> Text -> Env -> P ByteString Source
Require a parameter as bytes, applying the encoding function f
floatFM :: (Read a, Fractional a) => Text -> Env -> P (Maybe a) Source
Optional parameter as fractional
bytesFM :: (Text -> ByteString) -> Text -> Env -> P (Maybe ByteString) Source
Optional header as bytes, applying the encoding function f
Derived combinators, headers
bytesH :: (Text -> ByteString) -> CI Text -> Env -> P ByteString Source
Require a header as bytes, applying the encoding function f
floatHM :: (Fractional a, Read a) => CI Text -> Env -> P (Maybe a) Source
Optional header as floating
bytesHM :: (Text -> ByteString) -> CI Text -> Env -> P (Maybe ByteString) Source
Optional header as bytes, applying the encoding function f