http-response-decoder-0.2.2: Declarative DSL for parsing an HTTP response

Safe HaskellNone
LanguageHaskell2010

HTTPResponseDecoder

Contents

Description

A DSL of HTTP-response decoders.

Synopsis

Documentation

Response

data Response a Source #

Response decoder.

Instances

Functor Response Source # 

Methods

fmap :: (a -> b) -> Response a -> Response b #

(<$) :: a -> Response b -> Response a #

headAndBody :: Head a -> Body b -> Response (a, b) Source #

Composes a Response decoder from Head and Body decoders.

You can then merge the tuple in the result using the Functor interface.

Head

data Head a Source #

Response head decoder.

Supports the Applicative and Alternative interfaces.

Instances

Functor Head Source # 

Methods

fmap :: (a -> b) -> Head a -> Head b #

(<$) :: a -> Head b -> Head a #

Applicative Head Source # 

Methods

pure :: a -> Head a #

(<*>) :: Head (a -> b) -> Head a -> Head b #

(*>) :: Head a -> Head b -> Head b #

(<*) :: Head a -> Head b -> Head a #

Alternative Head Source # 

Methods

empty :: Head a #

(<|>) :: Head a -> Head a -> Head a #

some :: Head a -> Head [a] #

many :: Head a -> Head [a] #

Headers

data Headers a Source #

Response headers decoder.

Instances

Functor Headers Source # 

Methods

fmap :: (a -> b) -> Headers a -> Headers b #

(<$) :: a -> Headers b -> Headers a #

Applicative Headers Source # 

Methods

pure :: a -> Headers a #

(<*>) :: Headers (a -> b) -> Headers a -> Headers b #

(*>) :: Headers a -> Headers b -> Headers b #

(<*) :: Headers a -> Headers b -> Headers a #

Alternative Headers Source # 

Methods

empty :: Headers a #

(<|>) :: Headers a -> Headers a -> Headers a #

some :: Headers a -> Headers [a] #

many :: Headers a -> Headers [a] #

Body

data Body a Source #

Body decoder.

Instances

Functor Body Source # 

Methods

fmap :: (a -> b) -> Body a -> Body b #

(<$) :: a -> Body b -> Body a #

Matcher

data Matcher a b :: * -> * -> * #

A composable abstraction for checking or converting a context value.

Instances

Arrow Matcher 

Methods

arr :: (b -> c) -> Matcher b c #

first :: Matcher b c -> Matcher (b, d) (c, d) #

second :: Matcher b c -> Matcher (d, b) (d, c) #

(***) :: Matcher b c -> Matcher b' c' -> Matcher (b, b') (c, c') #

(&&&) :: Matcher b c -> Matcher b c' -> Matcher b (c, c') #

Profunctor Matcher 

Methods

dimap :: (a -> b) -> (c -> d) -> Matcher b c -> Matcher a d #

lmap :: (a -> b) -> Matcher b c -> Matcher a c #

rmap :: (b -> c) -> Matcher a b -> Matcher a c #

(#.) :: Coercible * c b => (b -> c) -> Matcher a b -> Matcher a c #

(.#) :: Coercible * b a => Matcher b c -> (a -> b) -> Matcher a c #

Monad (Matcher a) 

Methods

(>>=) :: Matcher a a -> (a -> Matcher a b) -> Matcher a b #

(>>) :: Matcher a a -> Matcher a b -> Matcher a b #

return :: a -> Matcher a a #

fail :: String -> Matcher a a #

Functor (Matcher a) 

Methods

fmap :: (a -> b) -> Matcher a a -> Matcher a b #

(<$) :: a -> Matcher a b -> Matcher a a #

Applicative (Matcher a) 

Methods

pure :: a -> Matcher a a #

(<*>) :: Matcher a (a -> b) -> Matcher a a -> Matcher a b #

(*>) :: Matcher a a -> Matcher a b -> Matcher a b #

(<*) :: Matcher a a -> Matcher a b -> Matcher a a #

Alternative (Matcher a) 

Methods

empty :: Matcher a a #

(<|>) :: Matcher a a -> Matcher a a -> Matcher a a #

some :: Matcher a a -> Matcher a [a] #

many :: Matcher a a -> Matcher a [a] #

MonadPlus (Matcher a) 

Methods

mzero :: Matcher a a #

mplus :: Matcher a a -> Matcher a a -> Matcher a a #

Category * Matcher 

Methods

id :: cat a a #

(.) :: cat b c -> cat a b -> cat a c #

equals :: Eq a => a -> Matcher a () #

Tests the matched value on equality with the provided value.

satisfies :: (a -> Bool) -> Matcher a () #

Checks whether the matched value satisfies the provided predicate.

converts :: (a -> Either Text b) -> Matcher a b #

Tries to convert the matched value to an output value, with Either encoding the success or failure of the conversion.