wai-route-1.0.0: WAI middleware for path-based request routing with captures.

Safe HaskellNone
LanguageHaskell2010

Network.Wai.Route

Contents

Description

This module provides a WAI Middleware for routing requests to handlers (i.e. Applications) based on the request path, thereby optionally capturing variables.

The basic functionality is provided by route and routePrefix. The RoutingTries for the middleware can be constructed directly or by compiling Routes via the construction of Paths, which offers enhanced type-safety.

Handlers may furthermore parse parameters from query strings, via the construction of Querys. Some additional functions for working with HTTP methods and request headers are also provided.

The sources contain some examples.

Strictness: This module uses -XStrictData.

Synopsis

Documentation

The following extensions are used for all inline examples.

>>> :set -XDataKinds
>>> :set -XOverloadedStrings
>>> :set -XTypeApplications

More extensive examples can be found in the examples directory of the source distribution.

Middleware

type App m = Request -> (Response -> m ResponseReceived) -> m ResponseReceived Source #

An App is a WAI Application generalised to any type of kind * -> *, and thus in particular any monad, i.e. App IO ~ Application.

type Handler m = Seq (Capture Text) -> App m Source #

A handler function for a routed request.

type RoutingTrie m = Trie Text (Handler m) Source #

A routing trie for request paths.

route :: Monad m => RoutingTrie m -> App m -> App m Source #

Routes requests to Handlers via a routing trie, passing along captured path parameters. The request path must fully match a route in order for the associated handler function to be called. If no route matches the request path, the request is forwarded to the Application given as second argument.

routePrefix :: Monad m => RoutingTrie m -> App m -> App m Source #

Routes requests to Handlers via a routing trie, passing along captured path parameters. A prefix of the request path must match a route in order for the associated handler function to be called. Thereby the route for the longest matching prefix is chosen. If no route matches a prefix of the request path, the request is forward to the Application given as second argument.

Note: With prefix routing, the pathInfo of the Request passed to a handler contains only the (unmatched) suffix of the request path, enabling nested / chained routing with multiple routing tries. An example for the composition of routing tries can be seen here.

Routes

data Route m Source #

A route whose handler is run if the path is a match for a request path. The handler function is thereby given the captured and parsed Params.

Constructors

Route 

Fields

Instances
Eq (Route m) Source #

Two routes are equal if they have the same path.

Instance details

Defined in Network.Wai.Route

Methods

(==) :: Route m -> Route m -> Bool #

(/=) :: Route m -> Route m -> Bool #

Show (Route m) Source #

Shows the path of the route.

Instance details

Defined in Network.Wai.Route

Methods

showsPrec :: Int -> Route m -> ShowS #

show :: Route m -> String #

showList :: [Route m] -> ShowS #

defRoute :: Monad m => Path vars -> (Params vars -> App m) -> Route m Source #

Define a Route with the given path and handler, using default values for other arguments.

compileRoute :: Monad m => Route m -> (Pattern Text, Handler m) Source #

Compile a Route into a pair of a Pattern and a Handler, suitable for insertion into a RoutingTrie.

compileRoutes :: Monad m => [Route m] -> RoutingTrie m Source #

Compile a list of Routes into a RoutingTrie.

Parameters

data Params :: Vars -> Type where Source #

A heterogenous list of parameters.

Constructors

Nil :: Params '[] 
(:::) :: Eq a => a -> Params vars -> Params (Var s a ': vars) infixr 5 
Instances
Eq (Params vars) Source # 
Instance details

Defined in Network.Wai.Route

Methods

(==) :: Params vars -> Params vars -> Bool #

(/=) :: Params vars -> Params vars -> Bool #

Paths

data Path :: Vars -> Type Source #

A path of a Route, indexed by the names and types of the captured variables.

Paths are constructed using str, var, some, glued together by ./ and terminated by end, e.g.

>>> let p = str "a" ./ var @"b" @Int ./ str "c" ./ some @Text ./ end
>>> :t p
p :: Path '[Var "b" Int, Some Text]

Two different paths are overlapping iff their underlying Patterns, as given by pathPattern, are overlapping. The preference given to routes based on overlapping paths is given by the preference between the overlapping patterns (see the documentation for Patterns).

Instances
Eq (Path vars) Source #

Equality for paths indexed by the same Vars is subsumed by the structural equality =~=.

Instance details

Defined in Network.Wai.Route

Methods

(==) :: Path vars -> Path vars -> Bool #

(/=) :: Path vars -> Path vars -> Bool #

Show (Path vars) Source #

Shows paths with a leading "/", whereby strings stand in for themselves, unnamed variables are represented by a "*" and named variables are represented by a ":" followed by the name of the variable.

>>> let p = str "a" ./ var @"b" @Int ./ str "c" ./ some @Text ./ end
>>> p
/a/:b/c/*
Instance details

Defined in Network.Wai.Route

Methods

showsPrec :: Int -> Path vars -> ShowS #

show :: Path vars -> String #

showList :: [Path vars] -> ShowS #

type Vars = [(Symbol, Type)] Source #

The names and types of the variables captured in a Path.

type Var s a = '(s, a) Source #

A parameter of type a with (type-level) name s.

type Some a = Var "" a Source #

An unnamed parameter of type a.

(=~=) :: Path vars -> Path vars' -> Bool Source #

Structural equality of paths.

p =~= p \(\iff\) pathPattern p == pathPattern p

str :: Text -> Path vars -> Path vars Source #

Match a fixed string, capturing nothing, e.g.

>>> let p = str "tmp" ./ end
>>> :t p
p :: Path '[]

var :: (KnownSymbol s, Eq a, FromHttpApiData a) => Path vars -> Path (Var s a ': vars) Source #

Capture a parameter as a named variable, e.g.

>>> let p = var @"name" @Text ./ end
>>> :t p
p :: Path '[Var "name" Text]

The type-level variable name can serve at least two purposes:

  • It allows to disambiguate multiple parameters of the same type in the path for extra type safety (i.e. against mixing up the order of parameters).
  • The name is made available at runtime when parsing of a parameter fails in the form of an InvalidParam error, enabling its use in error responses, logs, etc.

some :: (Eq a, FromHttpApiData a) => Path vars -> Path (Some a ': vars) Source #

Capture a parameter as an unnamed variable, e.g.

>>> let p = some @Text ./ end
>>> :t p
p :: Path '[Some Text]

(./) :: (Path vars -> Path vars') -> Path vars -> Path vars' infixr 5 Source #

Right-associative infix operator for constructing Paths:

>>> let p = str "a" ./ some @Int ./ var @"y" @Int ./ end
>>> :t p
p :: Path '[Some Int, Var "y" Int]

end :: Path '[] Source #

Mark the end of a path.

pathVarsLen :: Path vars -> Int Source #

Compute the length of the list of variables in a Path, at runtime.

\(\mathcal{O}(n)\), where n is the total length of the path.

>>> let p = str "a" ./ some @Text ./ end
>>> pathVarsLen p
1

See also knownVarsLen for lengths known at compile-time.

pathPattern :: Path vars -> Pattern Text Source #

The underlying structural Pattern of a Path.

parsePath :: Path vars -> Seq (Capture Text) -> Either PathError (Params vars) Source #

Parse a sequence of captures into a heterogeneous list of Params according to the Vars in the given Path. The number of captures given must be at least as large as the number of variables in the path, in order for the parse to succeed.

data PathError Source #

An error during parsing of the parameters of a Path.

Constructors

PathMissingParams

The path contains more variables than the number of captures given.

PathInvalidParam InvalidParam

A parameter failed to parse into the type expected by the corresponding variable of the path.

data SomePath Source #

A path with existentially quantified variables.

Constructors

SomePath (Path vars) 
Instances
Eq SomePath Source # 
Instance details

Defined in Network.Wai.Route

Show SomePath Source # 
Instance details

Defined in Network.Wai.Route

Query Strings

data Query :: Vars -> Type Source #

A query string with heterogeneously typed variables.

Instances
Show (Query vars) Source # 
Instance details

Defined in Network.Wai.Route

Methods

showsPrec :: Int -> Query vars -> ShowS #

show :: Query vars -> String #

showList :: [Query vars] -> ShowS #

qreq :: (KnownSymbol s, FromHttpApiData a, Eq a) => Query '[Var s a] Source #

A required query parameter.

qdef :: (KnownSymbol s, FromHttpApiData a, Eq a) => a -> Query '[Var s a] Source #

A query parameter with a default value. The default only applies when the parameter is absent or has no value, not if there is a value that fails to parse.

qopt :: (KnownSymbol s, FromHttpApiData a, Eq a) => Query '[Var s (Maybe a)] Source #

An optional query parameter. The parameter value is Nothing only if the parameter is absent or has no value, not if there is a value that fails to parse.

(.&.) :: (Eq a, KnownSymbol s, FromHttpApiData a) => Query '[Var s a] -> Query (Var s' a' ': vars) -> Query (Var s a ': (Var s' a' ': vars)) infixr 5 Source #

Combine a query parameter with one or more other query parameters.

withQuery Source #

Arguments

:: Query vars

The query to parse.

-> (QueryError -> App m)

The application to run when the query failed to parse.

-> (Params vars -> App m)

The application to run with the parsed query parameters.

-> App m 

Run an App after parsing the parameters for the given Query from the request.

parseQuery :: Query vars -> [QueryItem] -> Either QueryError (Params vars) Source #

Parse the variables of a Query for the given list of values into Params.

data QueryError Source #

An error during parsing of the parameters for a Query.

Constructors

QueryMissingParam ParamName

A query parameter is missing.

QueryInvalidParam InvalidParam

A query parameter failed to parse correctly.

Utilities

type family VarsLen vars :: Nat where ... Source #

Compute the length of Vars.

Equations

VarsLen '[] = 0 
VarsLen (_ ': vars) = 1 + VarsLen vars 

knownVarsLen :: forall proxy vars. KnownNat (VarsLen vars) => proxy vars -> Integer Source #

Get the length of a Vars list for a Path or Params, computed at compile-time.

>>> knownVarsLen (1 ::: "a" ::: 3.14 ::: Nil)
3
>>> knownVarsLen (str "a" ./ some @Int ./ var @"x" @Text ./ str "b" ./ end)
2

HTTP Methods

getMethod :: Request -> Either ByteString StdMethod Source #

Get and parse the request method as a StdMethod.

byMethod :: (StdMethod -> App m) -> App m Source #

Dispatch a request to an application based on the standardised HTTP request methods (verbs). If the request method is not a standard method, app405 is called.

withMethod :: Monad m => StdMethod -> App m -> App m Source #

Run an App only if the request method matches, otherwise run app405.

HTTP Query Parameters

getQueryParam :: FromHttpApiData a => Request -> ByteString -> Maybe (Either InvalidParam a) Source #

Get and parse a query parameter by its name, assuming UTF-8 encoding of the value. If the query parameter is not present in the request or has an empty value, Nothing is returned.

If the parameter name is known to contain only ASCII characters (the most common case), this function is more efficient than 'getQueryParam\'', since query parameter names are plain ByteStrings in the WAI.

getQueryParam' :: FromHttpApiData a => Request -> Text -> Maybe (Either InvalidParam a) Source #

Like getQueryParam but supports UTF-8 encoded names of query parameters.

HTTP Headers

getHeader :: FromHttpApiData a => Request -> HeaderName -> Maybe (Either InvalidHeader a) Source #

Get an parse the value of an HTTP header.

Standard Applications

appInvalidParam :: InvalidParam -> App m Source #

An application that always yields a 400 Bad Request plaintext response for an invalid parameter.

appMissingParam :: ParamName -> App m Source #

An application that always yields a 400 Bad Request plaintext response for a missing parameter.

appQueryError :: QueryError -> App m Source #

An application that always yields a 400 Bad Request plaintext response for an invalid or missing query parameter.

app400 :: App m Source #

An application that always yields an empty 400 Bad Request response.

app404 :: App m Source #

An application that always yields an empty 404 Not Found response.

app405 :: App m Source #

An application that always yields an empty 405 Method Not Allowed response.

Re-exports

data Trie s a #

An unordered map from Patterns of strings of type s to values of type a.

Instances
Functor (Trie s) 
Instance details

Defined in Data.Trie.Pattern

Methods

fmap :: (a -> b) -> Trie s a -> Trie s b #

(<$) :: a -> Trie s b -> Trie s a #

Foldable (Trie s) 
Instance details

Defined in Data.Trie.Pattern

Methods

fold :: Monoid m => Trie s m -> m #

foldMap :: Monoid m => (a -> m) -> Trie s a -> m #

foldr :: (a -> b -> b) -> b -> Trie s a -> b #

foldr' :: (a -> b -> b) -> b -> Trie s a -> b #

foldl :: (b -> a -> b) -> b -> Trie s a -> b #

foldl' :: (b -> a -> b) -> b -> Trie s a -> b #

foldr1 :: (a -> a -> a) -> Trie s a -> a #

foldl1 :: (a -> a -> a) -> Trie s a -> a #

toList :: Trie s a -> [a] #

null :: Trie s a -> Bool #

length :: Trie s a -> Int #

elem :: Eq a => a -> Trie s a -> Bool #

maximum :: Ord a => Trie s a -> a #

minimum :: Ord a => Trie s a -> a #

sum :: Num a => Trie s a -> a #

product :: Num a => Trie s a -> a #

Traversable (Trie s) 
Instance details

Defined in Data.Trie.Pattern

Methods

traverse :: Applicative f => (a -> f b) -> Trie s a -> f (Trie s b) #

sequenceA :: Applicative f => Trie s (f a) -> f (Trie s a) #

mapM :: Monad m => (a -> m b) -> Trie s a -> m (Trie s b) #

sequence :: Monad m => Trie s (m a) -> m (Trie s a) #

(Eq s, Eq a) => Eq (Trie s a) 
Instance details

Defined in Data.Trie.Pattern

Methods

(==) :: Trie s a -> Trie s a -> Bool #

(/=) :: Trie s a -> Trie s a -> Bool #

(Eq s, Hashable s, Read s, Read a) => Read (Trie s a) 
Instance details

Defined in Data.Trie.Pattern

Methods

readsPrec :: Int -> ReadS (Trie s a) #

readList :: ReadS [Trie s a] #

readPrec :: ReadPrec (Trie s a) #

readListPrec :: ReadPrec [Trie s a] #

(Show s, Show a) => Show (Trie s a) 
Instance details

Defined in Data.Trie.Pattern

Methods

showsPrec :: Int -> Trie s a -> ShowS #

show :: Trie s a -> String #

showList :: [Trie s a] -> ShowS #

Generic (Trie s a) 
Instance details

Defined in Data.Trie.Pattern

Associated Types

type Rep (Trie s a) :: Type -> Type #

Methods

from :: Trie s a -> Rep (Trie s a) x #

to :: Rep (Trie s a) x -> Trie s a #

(Eq s, Hashable s) => Semigroup (Trie s a)

Note (left preference): If two tries have a value attached to the same Pattern (i.e. to the same key), then t1 <> t2 preserves the value of t1.

Instance details

Defined in Data.Trie.Pattern

Methods

(<>) :: Trie s a -> Trie s a -> Trie s a #

sconcat :: NonEmpty (Trie s a) -> Trie s a #

stimes :: Integral b => b -> Trie s a -> Trie s a #

(Eq s, Hashable s) => Monoid (Trie s a)

Note: mappend = (<>).

Instance details

Defined in Data.Trie.Pattern

Methods

mempty :: Trie s a #

mappend :: Trie s a -> Trie s a -> Trie s a #

mconcat :: [Trie s a] -> Trie s a #

(NFData s, NFData a) => NFData (Trie s a) 
Instance details

Defined in Data.Trie.Pattern

Methods

rnf :: Trie s a -> () #

type Rep (Trie s a) 
Instance details

Defined in Data.Trie.Pattern

type Rep (Trie s a) = D1 (MetaData "Trie" "Data.Trie.Pattern" "pattern-trie-0.1.0-EO2ub3nKhTEUToUvE7Jyd" False) (C1 (MetaCons "Trie" PrefixI True) (S1 (MetaSel (Just "strtries") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (HashMap s (Trie s a))) :*: (S1 (MetaSel (Just "vartrie") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe (Trie s a))) :*: S1 (MetaSel (Just "value") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe a)))))

type Pattern s = Seq (Matcher s) #

A pattern is a sequence of Matchers and serves as a key in a pattern trie.

If two patterns are overlapping for an input string, the preference for a match is given by the partial order EqStr > AnyStr on the competing matchers, i.e. towards the more specific pattern. This partial order is witnessed and subsumed by the total order MatchOrd.

The preference for a prefix match is reversed, i.e. for an input string where only a proper prefix is a match for overlapping patterns, the preference is given by the partial order AnyStr > EqStr, i.e. towards the more general pattern. This partial order is witnessed and subsumed by the total order PrefixMatchOrd.

data Matcher s #

A Matcher is applied on a single chunk of an input String while looking for a match and either succeeds or fails. If it succeeds, it may Capture the chunk.

Constructors

AnyStr

Match and capture an arbitrary chunk of an input string.

EqStr !s

Match a chunk of an input string exactly, capturing nothing.

Instances
Eq s => Eq (Matcher s) 
Instance details

Defined in Data.Trie.Pattern

Methods

(==) :: Matcher s -> Matcher s -> Bool #

(/=) :: Matcher s -> Matcher s -> Bool #

Read s => Read (Matcher s) 
Instance details

Defined in Data.Trie.Pattern

Show s => Show (Matcher s) 
Instance details

Defined in Data.Trie.Pattern

Methods

showsPrec :: Int -> Matcher s -> ShowS #

show :: Matcher s -> String #

showList :: [Matcher s] -> ShowS #

Generic (Matcher s) 
Instance details

Defined in Data.Trie.Pattern

Associated Types

type Rep (Matcher s) :: Type -> Type #

Methods

from :: Matcher s -> Rep (Matcher s) x #

to :: Rep (Matcher s) x -> Matcher s #

NFData s => NFData (Matcher s) 
Instance details

Defined in Data.Trie.Pattern

Methods

rnf :: Matcher s -> () #

type Rep (Matcher s) 
Instance details

Defined in Data.Trie.Pattern

type Rep (Matcher s) = D1 (MetaData "Matcher" "Data.Trie.Pattern" "pattern-trie-0.1.0-EO2ub3nKhTEUToUvE7Jyd" False) (C1 (MetaCons "AnyStr" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "EqStr" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 s)))

newtype Capture s #

A captured chunk of an input String.

Constructors

Capture 

Fields

Instances
Eq s => Eq (Capture s) 
Instance details

Defined in Data.Trie.Pattern

Methods

(==) :: Capture s -> Capture s -> Bool #

(/=) :: Capture s -> Capture s -> Bool #

Ord s => Ord (Capture s) 
Instance details

Defined in Data.Trie.Pattern

Methods

compare :: Capture s -> Capture s -> Ordering #

(<) :: Capture s -> Capture s -> Bool #

(<=) :: Capture s -> Capture s -> Bool #

(>) :: Capture s -> Capture s -> Bool #

(>=) :: Capture s -> Capture s -> Bool #

max :: Capture s -> Capture s -> Capture s #

min :: Capture s -> Capture s -> Capture s #

Read s => Read (Capture s) 
Instance details

Defined in Data.Trie.Pattern

Show s => Show (Capture s) 
Instance details

Defined in Data.Trie.Pattern

Methods

showsPrec :: Int -> Capture s -> ShowS #

show :: Capture s -> String #

showList :: [Capture s] -> ShowS #

Generic (Capture s) 
Instance details

Defined in Data.Trie.Pattern

Associated Types

type Rep (Capture s) :: Type -> Type #

Methods

from :: Capture s -> Rep (Capture s) x #

to :: Rep (Capture s) x -> Capture s #

NFData s => NFData (Capture s) 
Instance details

Defined in Data.Trie.Pattern

Methods

rnf :: Capture s -> () #

type Rep (Capture s) 
Instance details

Defined in Data.Trie.Pattern

type Rep (Capture s) = D1 (MetaData "Capture" "Data.Trie.Pattern" "pattern-trie-0.1.0-EO2ub3nKhTEUToUvE7Jyd" True) (C1 (MetaCons "Capture" PrefixI True) (S1 (MetaSel (Just "captured") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 s)))

class FromHttpApiData a #

Parse value from HTTP API data.

WARNING: Do not derive this using DeriveAnyClass as the generated instance will loop indefinitely.

Minimal complete definition

parseUrlPiece | parseQueryParam

Instances
FromHttpApiData Bool 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Char 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Double 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Float 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Int 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Int8 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Int16 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Int32 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Int64 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Integer 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Natural 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Ordering 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Word 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Word8 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Word16 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Word32 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Word64 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData ()
>>> parseUrlPiece "_" :: Either Text ()
Right ()
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Text 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Text 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData String 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Void

Parsing a Void value is always an error, considering Void as a data type with no constructors.

Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Version
>>> showVersion <$> parseUrlPiece "1.2.3"
Right "1.2.3"
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData All 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Any 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData UTCTime
>>> parseUrlPiece "2015-10-03T00:14:24Z" :: Either Text UTCTime
Right 2015-10-03 00:14:24 UTC
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData SetCookie

Note: this instance works correctly for alphanumeric name and value

>>> parseUrlPiece "SESSID=r2t5uvjq435r4q7ib3vtdjq120" :: Either Text SetCookie
Right (SetCookie {setCookieName = "SESSID", setCookieValue = "r2t5uvjq435r4q7ib3vtdjq120", setCookiePath = Nothing, setCookieExpires = Nothing, setCookieMaxAge = Nothing, setCookieDomain = Nothing, setCookieHttpOnly = False, setCookieSecure = False, setCookieSameSite = Nothing})
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData ZonedTime
>>> parseUrlPiece "2015-10-03T14:55:01+0000" :: Either Text ZonedTime
Right 2015-10-03 14:55:01 +0000
>>> parseQueryParam "2016-12-31T01:00:00Z" :: Either Text ZonedTime
Right 2016-12-31 01:00:00 +0000
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData LocalTime
>>> parseUrlPiece "2015-10-03T14:55:01" :: Either Text LocalTime
Right 2015-10-03 14:55:01
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData TimeOfDay
>>> parseUrlPiece "14:55:01.333" :: Either Text TimeOfDay
Right 14:55:01.333
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData NominalDiffTime 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Day
>>> toGregorian <$> parseUrlPiece "2016-12-01"
Right (2016,12,1)
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData UUID 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (Maybe a)
>>> parseUrlPiece "Just 123" :: Either Text (Maybe Int)
Right (Just 123)
Instance details

Defined in Web.Internal.HttpApiData

HasResolution a => FromHttpApiData (Fixed a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (Min a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (Max a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (First a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (Last a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (First a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (Last a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (Dual a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (Sum a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (Product a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (LenientData a) 
Instance details

Defined in Web.Internal.HttpApiData

(FromHttpApiData a, FromHttpApiData b) => FromHttpApiData (Either a b)
>>> parseUrlPiece "Right 123" :: Either Text (Either String Int)
Right (Right 123)
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (Tagged b a) 
Instance details

Defined in Web.Internal.HttpApiData