wai-request-spec-0.9.1.0: Declarative request parsing

CopyrightAlej Cabrera 2015
LicenseBSD-3
Maintainercpp.cabrera@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Network.Wai.RequestSpec

Description

 

Synopsis

Documentation

  • Primitive parsing data types

data Result a Source

Constructors

Failure Error 
Success a 
  • Primitive parsing functions

parse :: (a -> P b) -> a -> Result b Source

parseMaybe :: (a -> P b) -> a -> Maybe b Source

parseEither :: (a -> P b) -> a -> Either Error b Source

  • Error generation and parser annotation

(<?>) :: P a -> Text -> P a Source

freeform :: Text -> P a Source

malformed :: Reason -> Text -> P a Source

  • Error types

data Loc Source

Constructors

Header (CI Text) 
Param Text 

Instances

type Reason = Text Source

  • Generating parsing environment

toEnv :: Request -> ByteString -> Env Source

  • Parser driving type class

data Env Source

Instances

class FromEnv a where Source

Methods

fromEnv :: Env -> P a Source

  • Derived combinators, query parameters

intQ :: (Read a, Integral a) => Text -> Env -> P a Source

Require a parameter as an integral type

boolQ :: Text -> Env -> P Bool Source

Require a parameter as a boolean: "true" | "false"

floatQ :: (Read a, Fractional a) => Text -> Env -> P a Source

Require a parameter as a fractional type

textQ :: Text -> Env -> P Text Source

Require a parameter as text

bytesQ :: (Text -> ByteString) -> Text -> Env -> P ByteString Source

Require a parameter as bytes, applying the encoding function f

intQM :: (Read a, Integral a) => Text -> Env -> P (Maybe a) Source

Optional parameter as integral

floatQM :: (Read a, Fractional a) => Text -> Env -> P (Maybe a) Source

Optional parameter as fractional

textQM :: Text -> Env -> P (Maybe Text) Source

Optional parameter as text

bytesQM :: (Text -> ByteString) -> Text -> Env -> P (Maybe ByteString) Source

Optional header as bytes, applying the encoding function f

  • Derived combinators, form parameters

intF :: (Read a, Integral a) => Text -> Env -> P a Source

Require a parameter as an integral type

boolF :: Text -> Env -> P Bool Source

Require a parameter as a boolean: "true" | "false"

floatF :: (Read a, Fractional a) => Text -> Env -> P a Source

Require a parameter as a fractional type

textF :: Text -> Env -> P Text Source

Require a parameter as text

bytesF :: (Text -> ByteString) -> Text -> Env -> P ByteString Source

Require a parameter as bytes, applying the encoding function f

intFM :: (Read a, Integral a) => Text -> Env -> P (Maybe a) Source

Optional parameter as integral

floatFM :: (Read a, Fractional a) => Text -> Env -> P (Maybe a) Source

Optional parameter as fractional

textFM :: Text -> Env -> P (Maybe Text) Source

Optional parameter as text

bytesFM :: (Text -> ByteString) -> Text -> Env -> P (Maybe ByteString) Source

Optional header as bytes, applying the encoding function f

  • Derived combinators, headers

intH :: (Integral a, Read a) => CI Text -> Env -> P a Source

Require a header as an integral type

boolH :: CI Text -> Env -> P Bool Source

Require a header as a boolean: "true" | "false"

floatH :: (Fractional a, Read a) => CI Text -> Env -> P a Source

Require a header a fractional type

textH :: CI Text -> Env -> P Text Source

Require a header as text

bytesH :: (Text -> ByteString) -> CI Text -> Env -> P ByteString Source

Require a header as bytes, applying the encoding function f

intHM :: (Integral a, Read a) => CI Text -> Env -> P (Maybe a) Source

Optional header as integral

floatHM :: (Fractional a, Read a) => CI Text -> Env -> P (Maybe a) Source

Optional header as floating

textHM :: CI Text -> Env -> P (Maybe Text) Source

Optional header as text

bytesHM :: (Text -> ByteString) -> CI Text -> Env -> P (Maybe ByteString) Source

Optional header as bytes, applying the encoding function f

  • Derived combinators, utility

choice :: [P a] -> P a Source

Combine a series of alternatives choice [a, b, c] == a | b | c | empty