servant-0.20.3.0: A family of combinators for defining webservices APIs

Safe Haskell | None
Language | Haskell2010

Servant.API

Contents

- Combinators
- Accessing information from the request
- Actual endpoints, distinguished by HTTP method
- Sub-APIs defined as records of routes
- Streaming endpoints, distinguished by HTTP method
- Server-sent events (SSE)
- Authentication
- Endpoints description
- Content Types
- Response Headers
- Untyped endpoints
- FromHttpApiData and ToHttpApiData
- Experimental modules
- Links
- Re-exports

Synopsis

- module Servant.API.Sub
- module Servant.API.Alternative
- module Servant.API.Empty
- data Strict
- data Lenient
- data Optional
- data Required
- module Servant.API.Capture
- module Servant.API.Header
- module Servant.API.Host
- module Servant.API.HttpVersion
- module Servant.API.QueryParam
- data QueryString
- data DeepQuery (sym :: Symbol) a
- module Servant.API.Fragment
- module Servant.API.ReqBody
- module Servant.API.RemoteHost
- module Servant.API.IsSecure
- module Servant.API.Vault
- module Servant.API.WithNamedContext
- module Servant.API.WithResource
- type Get = Verb 'GET 200
- type Put = Verb 'PUT 200
- data StdMethod
  - = GET
  - | POST
  - | HEAD
  - | PUT
  - | DELETE
  - | TRACE
  - | CONNECT
  - | OPTIONS
  - | PATCH
- type Delete = Verb 'DELETE 200
- type DeleteAccepted = Verb 'DELETE 202
- type DeleteNoContent = NoContentVerb 'DELETE
- type DeleteNonAuthoritative = Verb 'DELETE 203
- type GetAccepted = Verb 'GET 202
- type GetNoContent = NoContentVerb 'GET
- type GetNonAuthoritative = Verb 'GET 203
- type GetPartialContent = Verb 'GET 206
- type GetResetContent = Verb 'GET 205
- data NoContentVerb (method :: k1)
- type Patch = Verb 'PATCH 200
- type PatchAccepted = Verb 'PATCH 202
- type PatchNoContent = NoContentVerb 'PATCH
- type PatchNonAuthoritative = Verb 'PATCH 203
- type Post = Verb 'POST 200
- type PostAccepted = Verb 'POST 202
- type PostCreated = Verb 'POST 201
- type PostNoContent = NoContentVerb 'POST
- type PostNonAuthoritative = Verb 'POST 203
- type PostResetContent = Verb 'POST 205
- type PutAccepted = Verb 'PUT 202
- type PutCreated = Verb 'PUT 201
- type PutNoContent = NoContentVerb 'PUT
- type PutNonAuthoritative = Verb 'PUT 203
- class ReflectMethod (a :: k) where
  - reflectMethod :: Proxy a -> Method
- data Verb (method :: k1) (statusCode :: Nat) (contentTypes :: [Type]) a
- type family Unique (xs :: [k]) where ...
- type Union = NS I
- data UVerb (method :: StdMethod) (contentTypes :: [Type]) (as :: [Type])
- class KnownStatus (StatusOf a) => HasStatus a where
  - type StatusOf a :: Nat
- type IsMember (a :: u) (as :: [u]) = (Unique as, CheckElemIsMember a as, UElem a as)
- type family StatusOf a :: Nat
- type family Statuses (as :: [Type]) :: [Nat]
- type family Statuses (as :: [Type]) :: [Nat]
- newtype WithStatus (k :: Nat) a = WithStatus a
- inject :: UElem x xs => f x -> NS f xs
- statusOf :: HasStatus a => proxy a -> Status
- module Servant.API.NamedRoutes
- class GenericMode (mode :: k) where
  - type (mode :: k) :- api
- type family (mode :: k) :- api
- data AsApi
- class GServantProduct (f :: k -> Type)
- type GenericServant (routes :: k -> Type) (mode :: k) = (GenericMode mode, Generic (routes mode), GServantProduct (Rep (routes mode)))
- type ToServant (routes :: k -> Type) (mode :: k) = GToServant (Rep (routes mode))
- type ToServantApi (routes :: Type -> Type) = ToServant routes AsApi
- fromServant :: forall {k} routes (mode :: k). GenericServant routes mode => ToServant routes mode -> routes mode
- genericApi :: forall (routes :: Type -> Type). GenericServant routes AsApi => Proxy routes -> Proxy (ToServantApi routes)
- toServant :: forall {k} routes (mode :: k). GenericServant routes mode => routes mode -> ToServant routes mode
- data Stream (method :: k1) (status :: Nat) framing contentType a
- class FramingRender (strategy :: k) where
  - framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy strategy -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString
- class FramingUnrender (strategy :: k) where
  - framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy strategy -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a
- class FromSourceIO chunk a | a -> chunk where
  - fromSourceIO :: SourceIO chunk -> IO a
- data NetstringFraming
- data NewlineFraming
- data NoFraming
- type SourceIO = SourceT IO
- type StreamBody = StreamBody' ('[] :: [Type])
- data StreamBody' (mods :: [Type]) framing contentType a
- type StreamGet = Stream 'GET 200
- type StreamPost = Stream 'POST 200
- class ToSourceIO chunk a | a -> chunk where
  - toSourceIO :: a -> SourceIO chunk
- module Servant.API.ServerSentEvents
- module Servant.API.BasicAuth
- data Description (sym :: Symbol)
- data Summary (sym :: Symbol)
- class Accept (ctype :: k) where
  - contentType :: Proxy ctype -> MediaType
  - contentTypes :: Proxy ctype -> NonEmpty MediaType
- data FormUrlEncoded
- data JSON
- class Accept ctype => MimeRender (ctype :: k) a where
  - mimeRender :: Proxy ctype -> a -> ByteString
- class Accept ctype => MimeUnrender (ctype :: k) a where
  - mimeUnrender :: Proxy ctype -> ByteString -> Either String a
  - mimeUnrenderWithType :: Proxy ctype -> MediaType -> ByteString -> Either String a
- data NoContent = NoContent
- data OctetStream
- data PlainText
- data ResponseHeader (sym :: Symbol) a
  - = Header a
  - | MissingHeader
  - | UndecodableHeader ByteString
- class AddHeader (mods :: [Type]) (h :: Symbol) v orig new | mods h v orig -> new, new -> mods, new -> h, new -> v, new -> orig
- class BuildHeadersTo (hs :: [Type]) where
  - buildHeadersTo :: [Header] -> HList hs
- class GetHeaders ls where
  - getHeaders :: ls -> [Header]
- data HList (a :: [Type]) where
  - HNil :: HList ('[] :: [Type])
  - HCons :: forall (h :: Symbol) x (xs :: [Type]) (mods :: [Type]). ResponseHeader h x -> HList xs -> HList (Header' mods h x ': xs)
- class HasResponseHeader (h :: Symbol) a (headers :: [Type])
- data Headers (ls :: [Type]) a = Headers {
  - getResponse :: a
  - getHeadersHList :: HList ls
  }
- addHeader :: forall (h :: Symbol) v orig new. AddHeader '[Optional, Strict] h v orig new => v -> orig -> new
- addHeader' :: forall (mods :: [Type]) (h :: Symbol) v orig new. AddHeader mods h v orig new => v -> orig -> new
- lookupResponseHeader :: forall (h :: Symbol) a (headers :: [Type]) r. HasResponseHeader h a headers => Headers headers r -> ResponseHeader h a
- noHeader :: forall (h :: Symbol) v orig new. AddHeader '[Optional, Strict] h v orig new => orig -> new
- noHeader' :: forall (mods :: [Type]) (h :: Symbol) v orig new. AddHeader mods h v orig new => orig -> new
- module Servant.API.Raw
- class FromHttpApiData a where
  - parseUrlPiece :: Text -> Either Text a
  - parseHeader :: ByteString -> Either Text a
  - parseQueryParam :: Text -> Either Text a
- class ToHttpApiData a where
  - toUrlPiece :: a -> Text
  - toEncodedUrlPiece :: a -> Builder
  - toHeader :: a -> ByteString
  - toQueryParam :: a -> Text
  - toEncodedQueryParam :: a -> Builder
- module Servant.API.Experimental.Auth
- data URI = URI {
  - uriScheme :: String
  - uriAuthority :: Maybe URIAuth
  - uriPath :: String
  - uriQuery :: String
  - uriFragment :: String
  }
- class HasLink (endpoint :: k) where
  - type MkLink (endpoint :: k) a
  - toLink :: (Link -> a) -> Proxy endpoint -> Link -> MkLink endpoint a
- type family IsElem endpoint api where ...
- type family IsElem' a s
- data Link
- safeLink :: (IsElem endpoint api, HasLink endpoint) => Proxy api -> Proxy endpoint -> MkLink endpoint Link
- type family MkLink (endpoint :: k) a
- type family If (cond :: Bool) (tru :: k) (fls :: k) :: k where ...
- data SBool (b :: Bool) where
  - STrue :: SBool 'True
  - SFalse :: SBool 'False
- class SBoolI (b :: Bool) where
  - sbool :: SBool b

# Combinators

module Servant.API.Sub

Type-level combinator for expressing subrouting: ``:>``

module Servant.API.Alternative

Type-level combinator for alternative endpoints: ``:<|>``

module Servant.API.Empty

Type-level combinator for an empty API: ``EmptyAPI``

data Strict Source #

Strictly parsed argument. Not wrapped.

data Lenient Source #

Leniently parsed argument, i.e. parsing never fail. Wrapped in ``Either` `Text``.

data Optional Source #

Optional argument. Wrapped in `Maybe`.

data Required Source #

Required argument. Not wrapped.

Type-level modifiers for `QueryParam`, `Header` and `ReqBody`.

# Accessing information from the request

module Servant.API.Capture

Capturing parts of the url path as parsed values: ``Capture`` and ``CaptureAll``

module Servant.API.Header

Matching the `Host` header.

module Servant.API.Host

Retrieving specific headers from the request

module Servant.API.HttpVersion

Retrieving the HTTP version of the request

module Servant.API.QueryParam

Retrieving parameters from the query string of the `URI`: ``QueryParam``

data QueryString Source #

Extract the whole query string from a request. This is useful for query strings containing dynamic parameter names. For query strings with static parameter names, `QueryParam` is more suited.

Example:

    >>> -- /books?author=<author name>&year=<book year>
    >>> type MyApi = "books" :> QueryString :> Get '[JSON] [Book]

data DeepQuery (sym :: Symbol) a Source #

Extract an deep object from a query string.

Example:

    >>> -- /books?filter[author][name]=<author name>&filter[year]=<book year>
    >>> type MyApi = "books" :> DeepQuery "filter" BookQuery :> Get '[JSON] [Book]

#### Instances

Instances details

(KnownSymbol sym, ToDeepQuery record, HasLink sub) => HasLink (DeepQuery sym record :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (DeepQuery sym record :> sub) -> Link -> MkLink (DeepQuery sym record :> sub) a Source #
type MkLink (DeepQuery sym record :> sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (DeepQuery sym record :> sub :: Type) a = record -> MkLink sub a

Retrieving the complete query string of the `URI`: ``QueryString``

module Servant.API.Fragment

Documenting the fragment of the `URI`: ``Fragment``

module Servant.API.ReqBody

Accessing the request body as a JSON-encoded type: ``ReqBody``

module Servant.API.RemoteHost

Retrieving the IP of the client

module Servant.API.IsSecure

Is the request made through HTTPS?

module Servant.API.Vault

Access the location for arbitrary data to be shared by applications and middleware

module Servant.API.WithNamedContext

Access context entries in combinators in servant-server

module Servant.API.WithResource

Access a managed resource scoped to a single request

# Actual endpoints, distinguished by HTTP method

type Get = Verb 'GET 200 Source #

`GET` with 200 status code.

type Put = Verb 'PUT 200 Source #

`PUT` with 200 status code.

data StdMethod Source #

HTTP standard method (as defined by RFC 2616, and PATCH which is defined by RFC 5789).

Since: http-types-0.2.0

Constructors

GET |
POST |
HEAD |
PUT |
DELETE |
TRACE |
CONNECT |
OPTIONS |
PATCH | Since: http-types-0.8.0

#### Instances

Instances details

Data StdMethod | Since: http-types-0.12.4

Instance details

Defined in Network.HTTP.Types.Method

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> StdMethod -> c StdMethod Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c StdMethod Source #

toConstr :: StdMethod -> Constr Source #

dataTypeOf :: StdMethod -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c StdMethod) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c StdMethod) Source #

gmapT :: (forall b. Data b => b -> b) -> StdMethod -> StdMethod Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> StdMethod -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> StdMethod -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> StdMethod -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> StdMethod -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> StdMethod -> m StdMethod Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> StdMethod -> m StdMethod Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> StdMethod -> m StdMethod Source #

Bounded StdMethod |
Instance details Defined in Network.HTTP.Types.Method Methods minBound :: StdMethod Source # maxBound :: StdMethod Source #
Enum StdMethod |

Instance details

Defined in Network.HTTP.Types.Method

Methods

succ :: StdMethod -> StdMethod Source #

pred :: StdMethod -> StdMethod Source #

toEnum :: Int -> StdMethod Source #

fromEnum :: StdMethod -> Int Source #

enumFrom :: StdMethod -> [StdMethod] Source #

enumFromThen :: StdMethod -> StdMethod -> [StdMethod] Source #

enumFromTo :: StdMethod -> StdMethod -> [StdMethod] Source #

enumFromThenTo :: StdMethod -> StdMethod -> StdMethod -> [StdMethod] Source #

Generic StdMethod |

Instance details

Defined in Network.HTTP.Types.Method

Associated Types

type Rep StdMethod | Since: http-types-0.12.4

Instance details

Defined in Network.HTTP.Types.Method

type Rep StdMethod = D1 ('MetaData "StdMethod" "Network.HTTP.Types.Method" "http-types-0.12.4-1OvlBK9BqlVDFTI6Nz1ui2" 'False) (((C1 ('MetaCons "GET" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "POST" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "HEAD" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PUT" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "DELETE" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TRACE" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "CONNECT" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OPTIONS" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PATCH" 'PrefixI 'False) (U1 :: Type -> Type)))))

Methods

from :: StdMethod -> Rep StdMethod x Source #

to :: Rep StdMethod x -> StdMethod Source #

Ix StdMethod |

Instance details

Defined in Network.HTTP.Types.Method

Methods

range :: (StdMethod, StdMethod) -> [StdMethod] Source #

index :: (StdMethod, StdMethod) -> StdMethod -> Int Source #

unsafeIndex :: (StdMethod, StdMethod) -> StdMethod -> Int Source #

inRange :: (StdMethod, StdMethod) -> StdMethod -> Bool Source #

rangeSize :: (StdMethod, StdMethod) -> Int Source #

unsafeRangeSize :: (StdMethod, StdMethod) -> Int Source #

Read StdMethod |
Instance details Defined in Network.HTTP.Types.Method Methods readsPrec :: Int -> ReadS StdMethod Source # readList :: ReadS [StdMethod] Source # readPrec :: ReadPrec StdMethod Source # readListPrec :: ReadPrec [StdMethod] Source #
Show StdMethod |
Instance details Defined in Network.HTTP.Types.Method Methods showsPrec :: Int -> StdMethod -> ShowS Source # show :: StdMethod -> String Source # showList :: [StdMethod] -> ShowS Source #
Eq StdMethod |
Instance details Defined in Network.HTTP.Types.Method Methods (==) :: StdMethod -> StdMethod -> Bool Source # (/=) :: StdMethod -> StdMethod -> Bool Source #
Ord StdMethod |

Instance details

Defined in Network.HTTP.Types.Method

Methods

compare :: StdMethod -> StdMethod -> Ordering Source #

(<) :: StdMethod -> StdMethod -> Bool Source #

(<=) :: StdMethod -> StdMethod -> Bool Source #

(>) :: StdMethod -> StdMethod -> Bool Source #

(>=) :: StdMethod -> StdMethod -> Bool Source #

max :: StdMethod -> StdMethod -> StdMethod Source #

min :: StdMethod -> StdMethod -> StdMethod Source #

ReflectMethod 'CONNECT Source # |
Instance details Defined in Servant.API.Verbs Methods reflectMethod :: Proxy 'CONNECT -> Method Source #
ReflectMethod 'DELETE Source # |
Instance details Defined in Servant.API.Verbs Methods reflectMethod :: Proxy 'DELETE -> Method Source #
ReflectMethod 'GET Source # |
Instance details Defined in Servant.API.Verbs Methods reflectMethod :: Proxy 'GET -> Method Source #
ReflectMethod 'HEAD Source # |
Instance details Defined in Servant.API.Verbs Methods reflectMethod :: Proxy 'HEAD -> Method Source #
ReflectMethod 'OPTIONS Source # |
Instance details Defined in Servant.API.Verbs Methods reflectMethod :: Proxy 'OPTIONS -> Method Source #
ReflectMethod 'PATCH Source # |
Instance details Defined in Servant.API.Verbs Methods reflectMethod :: Proxy 'PATCH -> Method Source #
ReflectMethod 'POST Source # |
Instance details Defined in Servant.API.Verbs Methods reflectMethod :: Proxy 'POST -> Method Source #
ReflectMethod 'PUT Source # |
Instance details Defined in Servant.API.Verbs Methods reflectMethod :: Proxy 'PUT -> Method Source #
ReflectMethod 'TRACE Source # |
Instance details Defined in Servant.API.Verbs Methods reflectMethod :: Proxy 'TRACE -> Method Source #
type Rep StdMethod | Since: http-types-0.12.4

Instance details

Defined in Network.HTTP.Types.Method

type Rep StdMethod = D1 ('MetaData "StdMethod" "Network.HTTP.Types.Method" "http-types-0.12.4-1OvlBK9BqlVDFTI6Nz1ui2" 'False) (((C1 ('MetaCons "GET" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "POST" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "HEAD" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PUT" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "DELETE" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TRACE" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "CONNECT" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OPTIONS" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PATCH" 'PrefixI 'False) (U1 :: Type -> Type)))))

type Delete = Verb 'DELETE 200 Source #

`DELETE` with 200 status code.

type DeleteAccepted = Verb 'DELETE 202 Source #

`DELETE` with 202 status code.

type DeleteNoContent = NoContentVerb 'DELETE Source #

`DELETE` with 204 status code.

type DeleteNonAuthoritative = Verb 'DELETE 203 Source #

`DELETE` with 203 status code.

type GetAccepted = Verb 'GET 202 Source #

`GET` with 202 status code.

type GetNoContent = NoContentVerb 'GET Source #

`GET` with 204 status code.

type GetNonAuthoritative = Verb 'GET 203 Source #

`GET` with 203 status code.

type GetPartialContent = Verb 'GET 206 Source #

`GET` with 206 status code.

type GetResetContent = Verb 'GET 205 Source #

`GET` with 205 status code.

data NoContentVerb (method :: k1) Source #

`NoContentVerb` is a specific type to represent `NoContent` responses. It does not require either a list of content types (because there's no content) or a status code (because it should always be 204).

#### Instances

Instances details

HasLink (NoContentVerb m :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (NoContentVerb m) -> Link -> MkLink (NoContentVerb m) a Source #
Generic (NoContentVerb method) Source # |

Instance details

Defined in Servant.API.Verbs

Associated Types

type Rep (NoContentVerb method) |
Instance details Defined in Servant.API.Verbs type Rep (NoContentVerb method) = D1 ('MetaData "NoContentVerb" "Servant.API.Verbs" "servant-0.20.3.0-FHJyKhVqWFv2rTftFmLybU" 'False) (V1 :: Type -> Type)

Methods

from :: NoContentVerb method -> Rep (NoContentVerb method) x Source #

to :: Rep (NoContentVerb method) x -> NoContentVerb method Source #

type MkLink (NoContentVerb m :: Type) r Source # |
Instance details Defined in Servant.Links type MkLink (NoContentVerb m :: Type) r = r
type Rep (NoContentVerb method) Source # |
Instance details Defined in Servant.API.Verbs type Rep (NoContentVerb method) = D1 ('MetaData "NoContentVerb" "Servant.API.Verbs" "servant-0.20.3.0-FHJyKhVqWFv2rTftFmLybU" 'False) (V1 :: Type -> Type)

type Patch = Verb 'PATCH 200 Source #

`PATCH` with 200 status code.

type PatchAccepted = Verb 'PATCH 202 Source #

`PATCH` with 202 status code.

type PatchNoContent = NoContentVerb 'PATCH Source #

`PATCH` with 204 status code.

type PatchNonAuthoritative = Verb 'PATCH 203 Source #

`PATCH` with 203 status code.

type Post = Verb 'POST 200 Source #

`POST` with 200 status code.

type PostAccepted = Verb 'POST 202 Source #

`POST` with 202 status code.

type PostCreated = Verb 'POST 201 Source #

`POST` with 201 status code.

type PostNoContent = NoContentVerb 'POST Source #

`POST` with 204 status code.

type PostNonAuthoritative = Verb 'POST 203 Source #

`POST` with 203 status code.

type PostResetContent = Verb 'POST 205 Source #

`POST` with 205 status code.

type PutAccepted = Verb 'PUT 202 Source #

`PUT` with 202 status code.

type PutCreated = Verb 'PUT 201 Source #

`PUT` with 201 status code.

type PutNoContent = NoContentVerb 'PUT Source #

`PUT` with 204 status code.

type PutNonAuthoritative = Verb 'PUT 203 Source #

`PUT` with 203 status code.

class ReflectMethod (a :: k) where Source #

Methods

reflectMethod :: Proxy a -> Method Source #

#### Instances

Instances details

ReflectMethod 'CONNECT Source # |
Instance details Defined in Servant.API.Verbs Methods reflectMethod :: Proxy 'CONNECT -> Method Source #
ReflectMethod 'DELETE Source # |
Instance details Defined in Servant.API.Verbs Methods reflectMethod :: Proxy 'DELETE -> Method Source #
ReflectMethod 'GET Source # |
Instance details Defined in Servant.API.Verbs Methods reflectMethod :: Proxy 'GET -> Method Source #
ReflectMethod 'HEAD Source # |
Instance details Defined in Servant.API.Verbs Methods reflectMethod :: Proxy 'HEAD -> Method Source #
ReflectMethod 'OPTIONS Source # |
Instance details Defined in Servant.API.Verbs Methods reflectMethod :: Proxy 'OPTIONS -> Method Source #
ReflectMethod 'PATCH Source # |
Instance details Defined in Servant.API.Verbs Methods reflectMethod :: Proxy 'PATCH -> Method Source #
ReflectMethod 'POST Source # |
Instance details Defined in Servant.API.Verbs Methods reflectMethod :: Proxy 'POST -> Method Source #
ReflectMethod 'PUT Source # |
Instance details Defined in Servant.API.Verbs Methods reflectMethod :: Proxy 'PUT -> Method Source #
ReflectMethod 'TRACE Source # |
Instance details Defined in Servant.API.Verbs Methods reflectMethod :: Proxy 'TRACE -> Method Source #

data Verb (method :: k1) (statusCode :: Nat) (contentTypes :: [Type]) a Source #

`Verb` is a general type for representing HTTP verbs (a.k.a. methods). For convenience, type synonyms for each verb with a 200 response code are provided, but you are free to define your own:

    >>> type Post204 contentTypes a = Verb 'POST 204 contentTypes a

#### Instances

Instances details

HasLink (Verb m s ct a :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a0) -> Proxy (Verb m s ct a) -> Link -> MkLink (Verb m s ct a) a0 Source #
Generic (Verb method statusCode contentTypes a) Source # |

Instance details

Defined in Servant.API.Verbs

Associated Types

type Rep (Verb method statusCode contentTypes a) |
Instance details Defined in Servant.API.Verbs type Rep (Verb method statusCode contentTypes a) = D1 ('MetaData "Verb" "Servant.API.Verbs" "servant-0.20.3.0-FHJyKhVqWFv2rTftFmLybU" 'False) (V1 :: Type -> Type)

Methods

from :: Verb method statusCode contentTypes a -> Rep (Verb method statusCode contentTypes a) x Source #

to :: Rep (Verb method statusCode contentTypes a) x -> Verb method statusCode contentTypes a Source #

AtMostOneFragment (Verb m s ct typ) Source # |
Instance details Defined in Servant.API.TypeLevel
type MkLink (Verb m s ct a :: Type) r Source # |
Instance details Defined in Servant.Links type MkLink (Verb m s ct a :: Type) r = r
type Rep (Verb method statusCode contentTypes a) Source # |
Instance details Defined in Servant.API.Verbs type Rep (Verb method statusCode contentTypes a) = D1 ('MetaData "Verb" "Servant.API.Verbs" "servant-0.20.3.0-FHJyKhVqWFv2rTftFmLybU" 'False) (V1 :: Type -> Type)

type family Unique (xs :: [k]) where ... Source #

Check whether all values in a type-level list are distinct. This will throw a nice error if there are any duplicate elements in the list.

Equations

Unique (xs :: [k]) = If (Nubbed xs == 'True) () (TypeError (DuplicateElementError xs) :: Constraint) |

type Union = NS I Source #

data UVerb (method :: StdMethod) (contentTypes :: [Type]) (as :: [Type]) Source #

A variant of `Verb` that can have any of a number of response values and status codes.

FUTUREWORK: it would be nice to make `Verb` a special case of `UVerb`, and only write instances for `HasServer` etc. for the latter, getting them for the former for free. Something like:

    type Verb method statusCode contentTypes a = UVerb method contentTypes [WithStatus statusCode a]

Backwards compatibility is tricky, though: this type alias would mean people would have to use `respond` instead of `pure` or `return`, so all old handlers would have to be rewritten.

#### Instances

Instances details

HasLink (UVerb m ct a :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a0) -> Proxy (UVerb m ct a) -> Link -> MkLink (UVerb m ct a) a0 Source #
AtMostOneFragment (UVerb m cts as) Source # |
Instance details Defined in Servant.API.TypeLevel
type MkLink (UVerb m ct a :: Type) r Source # |
Instance details Defined in Servant.Links type MkLink (UVerb m ct a :: Type) r = r

class KnownStatus (StatusOf a) => HasStatus a Source #

Associated Types

type StatusOf a :: Nat Source #

#### Instances

Instances details

HasStatus NoContent Source # | If an API can respond with `NoContent` we assume that this will happen with the status code 204 No Content. If this needs to be overridden, `WithStatus` can be used.

Instance details

Defined in Servant.API.UVerb

Associated Types

type StatusOf NoContent |
Instance details Defined in Servant.API.UVerb type StatusOf NoContent = 204

HasStatus a => HasStatus (Headers ls a) Source # |

Instance details

Defined in Servant.API.UVerb

Associated Types

type StatusOf (Headers ls a) |
Instance details Defined in Servant.API.UVerb type StatusOf (Headers ls a) = StatusOf a

KnownStatus n => HasStatus (WithStatus n a) Source #

an instance of this typeclass assigns a HTTP status code to a return type

Example:

       data NotFoundError = NotFoundError String

       instance HasStatus NotFoundError where
         type StatusOf NotFoundError = 404

You can also use the convience newtype wrapper `WithStatus` if you want to avoid writing a `HasStatus` instance manually. It also has the benefit of showing the status code in the type; which might aid in readability.

Instance details

Defined in Servant.API.UVerb

Associated Types

type StatusOf (WithStatus n a) |
Instance details Defined in Servant.API.UVerb type StatusOf (WithStatus n a) = n

type IsMember (a :: u) (as :: [u]) = (Unique as, CheckElemIsMember a as, UElem a as) Source #

type family StatusOf a :: Nat Source #

#### Instances

Instances details

type StatusOf NoContent Source # |
Instance details Defined in Servant.API.UVerb type StatusOf NoContent = 204
type StatusOf (Headers ls a) Source # |
Instance details Defined in Servant.API.UVerb type StatusOf (Headers ls a) = StatusOf a
type StatusOf (WithStatus n a) Source # |
Instance details Defined in Servant.API.UVerb type StatusOf (WithStatus n a) = n

type family Statuses (as :: [Type]) :: [Nat] Source #

#### Instances

Instances details

type Statuses ('[] :: [Type]) Source # |
Instance details Defined in Servant.API.UVerb type Statuses ('[] :: [Type]) = '[] :: [Nat]
type Statuses (a ': as) Source # |
Instance details Defined in Servant.API.UVerb type Statuses (a ': as) = StatusOf a ': Statuses as

type family Statuses (as :: [Type]) :: [Nat] Source #

#### Instances

Instances details

type Statuses ('[] :: [Type]) Source # |
Instance details Defined in Servant.API.UVerb type Statuses ('[] :: [Type]) = '[] :: [Nat]
type Statuses (a ': as) Source # |
Instance details Defined in Servant.API.UVerb type Statuses (a ': as) = StatusOf a ': Statuses as

newtype WithStatus (k :: Nat) a Source #

A simple newtype wrapper that pairs a type with its status code. It implements all the content types that Servant ships with by default.

Constructors

WithStatus a |

#### Instances

Instances details

MimeRender FormUrlEncoded a => MimeRender FormUrlEncoded (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeRender :: Proxy FormUrlEncoded -> WithStatus _status a -> ByteString Source #
MimeRender JSON a => MimeRender JSON (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeRender :: Proxy JSON -> WithStatus _status a -> ByteString Source #
MimeRender OctetStream a => MimeRender OctetStream (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeRender :: Proxy OctetStream -> WithStatus _status a -> ByteString Source #
MimeRender PlainText a => MimeRender PlainText (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeRender :: Proxy PlainText -> WithStatus _status a -> ByteString Source #
MimeUnrender FormUrlEncoded a => MimeUnrender FormUrlEncoded (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy FormUrlEncoded -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy FormUrlEncoded -> MediaType -> ByteString -> Either String (WithStatus _status a) Source #
MimeUnrender JSON a => MimeUnrender JSON (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy JSON -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy JSON -> MediaType -> ByteString -> Either String (WithStatus _status a) Source #
MimeUnrender OctetStream a => MimeUnrender OctetStream (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy OctetStream -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy OctetStream -> MediaType -> ByteString -> Either String (WithStatus _status a) Source #
MimeUnrender PlainText a => MimeUnrender PlainText (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy PlainText -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy PlainText -> MediaType -> ByteString -> Either String (WithStatus _status a) Source #
Show a => Show (WithStatus k a) Source # |
Instance details Defined in Servant.API.UVerb Methods showsPrec :: Int -> WithStatus k a -> ShowS Source # show :: WithStatus k a -> String Source # showList :: [WithStatus k a] -> ShowS Source #
Eq a => Eq (WithStatus k a) Source # |
Instance details Defined in Servant.API.UVerb Methods (==) :: WithStatus k a -> WithStatus k a -> Bool Source # (/=) :: WithStatus k a -> WithStatus k a -> Bool Source #

KnownStatus n => HasStatus (WithStatus n a) Source #

an instance of this typeclass assigns a HTTP status code to a return type

Example:

       data NotFoundError = NotFoundError String

       instance HasStatus NotFoundError where
         type StatusOf NotFoundError = 404

You can also use the convience newtype wrapper `WithStatus` if you want to avoid writing a `HasStatus` instance manually. It also has the benefit of showing the status code in the type; which might aid in readability.

Instance details

Defined in Servant.API.UVerb

Associated Types

type StatusOf (WithStatus n a) |
Instance details Defined in Servant.API.UVerb type StatusOf (WithStatus n a) = n

type StatusOf (WithStatus n a) Source # |
Instance details Defined in Servant.API.UVerb type StatusOf (WithStatus n a) = n

inject :: UElem x xs => f x -> NS f xs Source #

statusOf :: HasStatus a => proxy a -> Status Source #

# Sub-APIs defined as records of routes

module Servant.API.NamedRoutes

class GenericMode (mode :: k) Source #

A class with a type family that applies an appropriate type family to the `api` parameter. For example, `AsApi` will leave `api` untouched, while ``AsServerT` m` will produce ``ServerT` api m`.

Associated Types

type (mode :: k) :- api infixl 0 Source #

#### Instances

Instances details

GenericMode AsApi Source # |

Instance details

Defined in Servant.API.Generic

Associated Types

type AsApi :- api |
Instance details Defined in Servant.API.Generic type AsApi :- api = api

GenericMode (AsLink a :: Type) Source # |
Instance details Defined in Servant.Links

type family (mode :: k) :- api infixl 0 Source #

#### Instances

Instances details

type AsApi :- api Source # |
Instance details Defined in Servant.API.Generic type AsApi :- api = api
type (AsLink a :: Type) :- api Source # |
Instance details Defined in Servant.Links type (AsLink a :: Type) :- api = MkLink api a

data AsApi Source #

A type that specifies that an API record contains an API definition. Only useful at type-level.

#### Instances

Instances details

GenericMode AsApi Source # |

Instance details

Defined in Servant.API.Generic

Associated Types

type AsApi :- api |
Instance details Defined in Servant.API.Generic type AsApi :- api = api

type AsApi :- api Source # |
Instance details Defined in Servant.API.Generic type AsApi :- api = api

class GServantProduct (f :: k -> Type) Source #

Minimal complete definition

gtoServant, gfromServant

#### Instances

Instances details

(GServantProduct l, GServantProduct r) => GServantProduct (l :*: r :: k -> Type) Source # |
Instance details Defined in Servant.API.Generic Methods gtoServant :: forall (p :: k). (l :*: r) p -> GToServant (l :*: r) gfromServant :: forall (p :: k). GToServant (l :*: r) -> (l :*: r) p
GServantProduct (K1 i c :: k -> Type) Source # |
Instance details Defined in Servant.API.Generic Methods gtoServant :: forall (p :: k). K1 i c p -> GToServant (K1 i c :: k -> Type) gfromServant :: forall (p :: k). GToServant (K1 i c :: k -> Type) -> K1 i c p
GServantProduct f => GServantProduct (M1 i c f :: k -> Type) Source # |
Instance details Defined in Servant.API.Generic Methods gtoServant :: forall (p :: k). M1 i c f p -> GToServant (M1 i c f) gfromServant :: forall (p :: k). GToServant (M1 i c f) -> M1 i c f p

type GenericServant (routes :: k -> Type) (mode :: k) = (GenericMode mode, Generic (routes mode), GServantProduct (Rep (routes mode))) Source #

A constraint alias, for work with `mode` and `routes`.

type ToServant (routes :: k -> Type) (mode :: k) = GToServant (Rep (routes mode)) Source #

Turns a generic product type into a tree of `:<|>` combinators.

type ToServantApi (routes :: Type -> Type) = ToServant routes AsApi Source #

fromServant :: forall {k} routes (mode :: k). GenericServant routes mode => ToServant routes mode -> routes mode Source #

Inverse of `toServant`.

This can be used to turn `generated` values such as client functions into records.

You may need to provide a type signature for the output type (your record type).

genericApi :: forall (routes :: Type -> Type). GenericServant routes AsApi => Proxy routes -> Proxy (ToServantApi routes) Source #

Get a `Proxy` of an API type.

toServant :: forall {k} routes (mode :: k). GenericServant routes mode => routes mode -> ToServant routes mode Source #

See `ToServant`, but at value-level.

# Streaming endpoints, distinguished by HTTP method

data Stream (method :: k1) (status :: Nat) framing contentType a Source #

A Stream endpoint for a given method emits a stream of encoded values at a given `Content-Type`, delimited by a `framing` strategy. Type synonyms are provided for standard methods.

#### Instances

Instances details

HasLink (Stream m status fr ct a :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a0) -> Proxy (Stream m status fr ct a) -> Link -> MkLink (Stream m status fr ct a) a0 Source #
Generic (Stream method status framing contentType a) Source # |

Instance details

Defined in Servant.API.Stream

Associated Types

type Rep (Stream method status framing contentType a) |
Instance details Defined in Servant.API.Stream type Rep (Stream method status framing contentType a) = D1 ('MetaData "Stream" "Servant.API.Stream" "servant-0.20.3.0-FHJyKhVqWFv2rTftFmLybU" 'False) (V1 :: Type -> Type)

Methods

from :: Stream method status framing contentType a -> Rep (Stream method status framing contentType a) x Source #

to :: Rep (Stream method status framing contentType a) x -> Stream method status framing contentType a Source #

type MkLink (Stream m status fr ct a :: Type) r Source # |
Instance details Defined in Servant.Links type MkLink (Stream m status fr ct a :: Type) r = r
type Rep (Stream method status framing contentType a) Source # |
Instance details Defined in Servant.API.Stream type Rep (Stream method status framing contentType a) = D1 ('MetaData "Stream" "Servant.API.Stream" "servant-0.20.3.0-FHJyKhVqWFv2rTftFmLybU" 'False) (V1 :: Type -> Type)

class FramingRender (strategy :: k) where Source #

The `FramingRender` class provides the logic for emitting a framing strategy. The strategy transforms a ``SourceT` m a` into ``SourceT` m `ByteString``, therefore it can prepend, append and intercalate framing structure around chunks.

Note: as the ``Monad` m` is generic, this is pure transformation.

Methods

framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy strategy -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString Source #

#### Instances

Instances details

FramingRender NetstringFraming Source # |
Instance details Defined in Servant.API.Stream Methods framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy NetstringFraming -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString Source #
FramingRender NewlineFraming Source # |
Instance details Defined in Servant.API.Stream Methods framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy NewlineFraming -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString Source #
FramingRender NoFraming Source # |
Instance details Defined in Servant.API.Stream Methods framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy NoFraming -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString Source #

class FramingUnrender (strategy :: k) where Source #

The `FramingUnrender` class provides the logic for parsing a framing strategy.

Methods

framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy strategy -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a Source #

#### Instances

Instances details

FramingUnrender NetstringFraming Source # |
Instance details Defined in Servant.API.Stream Methods framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy NetstringFraming -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a Source #
FramingUnrender NewlineFraming Source # |
Instance details Defined in Servant.API.Stream Methods framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy NewlineFraming -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a Source #
FramingUnrender NoFraming Source # | As `NoFraming` doesn't have frame separators, we take the chunks as given and try to convert them one by one. That works well when `a` is a `ByteString`.
Instance details Defined in Servant.API.Stream Methods framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy NoFraming -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a Source #

class FromSourceIO chunk a | a -> chunk where Source #

`FromSourceIO` is intended to be implemented for types such as Conduit, Pipe, etc. By implementing this class, all such streaming abstractions can be used directly on the client side for talking to streaming endpoints.

Methods

fromSourceIO :: SourceIO chunk -> IO a Source #

#### Instances

Instances details

MonadIO m => FromSourceIO a (SourceT m a) Source # |
Instance details Defined in Servant.API.Stream Methods fromSourceIO :: SourceIO a -> IO (SourceT m a) Source #

data NetstringFraming Source #

The netstring framing strategy as defined by djb: http://cr.yp.to/proto/netstrings.txt

Any string of 8-bit bytes may be encoded as `[len]":"[string]","`. Here `[string]` is the string and `[len]` is a nonempty sequence of ASCII digits giving the length of `[string]` in decimal. The ASCII digits are `30` for 0, `31` for 1, and so on up through `39` for 9. Extra zeros at the front of `[len]` are prohibited: `[len]` begins with `30` exactly when `[string]` is empty.

For example, the string `"hello world!"` is encoded as `32 3a 68 65 6c 6c 6f 20 77 6f 72 6c 64 21 2c`, i.e., `"12:hello world!,"`. The empty string is encoded as `"0:,"`.

#### Instances

Instances details

FramingRender NetstringFraming Source # |
Instance details Defined in Servant.API.Stream Methods framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy NetstringFraming -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString Source #
FramingUnrender NetstringFraming Source # |
Instance details Defined in Servant.API.Stream Methods framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy NetstringFraming -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a Source #

data NewlineFraming Source #

A simple framing strategy that has no header, and inserts a newline character after each frame. This assumes that it is used with a Content-Type that encodes without newlines (e.g. JSON).

#### Instances

Instances details

FramingRender NewlineFraming Source # |
Instance details Defined in Servant.API.Stream Methods framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy NewlineFraming -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString Source #
FramingUnrender NewlineFraming Source # |
Instance details Defined in Servant.API.Stream Methods framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy NewlineFraming -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a Source #

data NoFraming Source #

A framing strategy that does not do any framing at all, it just passes the input data This will be used most of the time with binary data, such as files

#### Instances

Instances details

FramingRender NoFraming Source # |
Instance details Defined in Servant.API.Stream Methods framingRender :: forall (m :: Type -> Type) a. Monad m => Proxy NoFraming -> (a -> ByteString) -> SourceT m a -> SourceT m ByteString Source #
FramingUnrender NoFraming Source # | As `NoFraming` doesn't have frame separators, we take the chunks as given and try to convert them one by one. That works well when `a` is a `ByteString`.
Instance details Defined in Servant.API.Stream Methods framingUnrender :: forall (m :: Type -> Type) a. Monad m => Proxy NoFraming -> (ByteString -> Either String a) -> SourceT m ByteString -> SourceT m a Source #

type SourceIO = SourceT IO Source #

Stream endpoints may be implemented as producing a ``SourceIO` chunk`.

Clients reading from streaming endpoints can be implemented as consuming a ``SourceIO` chunk`.

type StreamBody = StreamBody' ('[] :: [Type]) Source #

A stream request body.

data StreamBody' (mods :: [Type]) framing contentType a Source #

#### Instances

Instances details

HasLink sub => HasLink (StreamBody' mods framing ct a :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a0) -> Proxy (StreamBody' mods framing ct a :> sub) -> Link -> MkLink (StreamBody' mods framing ct a :> sub) a0 Source #
Generic (StreamBody' mods framing contentType a) Source # |

Instance details

Defined in Servant.API.Stream

Associated Types

type Rep (StreamBody' mods framing contentType a) |
Instance details Defined in Servant.API.Stream type Rep (StreamBody' mods framing contentType a) = D1 ('MetaData "StreamBody'" "Servant.API.Stream" "servant-0.20.3.0-FHJyKhVqWFv2rTftFmLybU" 'False) (V1 :: Type -> Type)

Methods

from :: StreamBody' mods framing contentType a -> Rep (StreamBody' mods framing contentType a) x Source #

to :: Rep (StreamBody' mods framing contentType a) x -> StreamBody' mods framing contentType a Source #

type MkLink (StreamBody' mods framing ct a :> sub :: Type) r Source # |
Instance details Defined in Servant.Links type MkLink (StreamBody' mods framing ct a :> sub :: Type) r = MkLink sub r
type Rep (StreamBody' mods framing contentType a) Source # |
Instance details Defined in Servant.API.Stream type Rep (StreamBody' mods framing contentType a) = D1 ('MetaData "StreamBody'" "Servant.API.Stream" "servant-0.20.3.0-FHJyKhVqWFv2rTftFmLybU" 'False) (V1 :: Type -> Type)

type StreamGet = Stream 'GET 200 Source #

type StreamPost = Stream 'POST 200 Source #

class ToSourceIO chunk a | a -> chunk where Source #

`ToSourceIO` is intended to be implemented for types such as Conduit, Pipe, etc. By implementing this class, all such streaming abstractions can be used directly as endpoints.

Methods

toSourceIO :: a -> SourceIO chunk Source #

#### Instances

Instances details

ToSourceIO a (NonEmpty a) Source # |
Instance details Defined in Servant.API.Stream Methods toSourceIO :: NonEmpty a -> SourceIO a Source #
ToSourceIO a [a] Source # |
Instance details Defined in Servant.API.Stream Methods toSourceIO :: [a] -> SourceIO a Source #
SourceToSourceIO m => ToSourceIO chunk (SourceT m chunk) Source # | Relax to use auxiliary class, have m
Instance details Defined in Servant.API.Stream Methods toSourceIO :: SourceT m chunk -> SourceIO chunk Source #

# Server-sent events (SSE)

module Servant.API.ServerSentEvents

# Authentication

module Servant.API.BasicAuth

# Endpoints description

data Description (sym :: Symbol) Source #

Add more verbose description for (part of) API.

Example:

    >>> :{
    type MyApi = Description
     "This comment is visible in multiple Servant interpretations \
     \and can be really long if necessary. \
     \Haskell multiline String support is not perfect \
     \but it's still very readable."
    :> Get '[JSON] Book
    :}

#### Instances

Instances details

HasLink sub => HasLink (Description s :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (Description s :> sub) -> Link -> MkLink (Description s :> sub) a Source #
type MkLink (Description s :> sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (Description s :> sub :: Type) a = MkLink sub a

data Summary (sym :: Symbol) Source #

Add a short summary for (part of) API.

Example:

    >>> type MyApi = Summary "Get book by ISBN." :> "books" :> Capture "isbn" Text :> Get '[JSON] Book

#### Instances

Instances details

HasLink sub => HasLink (Summary s :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (Summary s :> sub) -> Link -> MkLink (Summary s :> sub) a Source #
type MkLink (Summary s :> sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (Summary s :> sub :: Type) a = MkLink sub a

# Content Types

class Accept (ctype :: k) where Source #

Instances of `Accept` represent mimetypes. They are used for matching against the `Accept` HTTP header of the request, and for setting the `Content-Type` header of the response

Example:

    >>> import Network.HTTP.Media ((//), (/:))
    >>> data HTML
    >>> :{
    instance Accept HTML where
       contentType _ = "text" // "html" /: ("charset", "utf-8")
    :}

Minimal complete definition

contentType | contentTypes

Methods

contentType :: Proxy ctype -> MediaType Source #

contentTypes :: Proxy ctype -> NonEmpty MediaType Source #

#### Instances

Instances details

Accept EventStream Source #

    text/event-stream

Instance details Defined in Servant.API.ContentTypes Methods contentType :: Proxy EventStream -> MediaType Source # contentTypes :: Proxy EventStream -> NonEmpty MediaType Source #

Accept FormUrlEncoded Source #

    application/x-www-form-urlencoded

Instance details Defined in Servant.API.ContentTypes Methods contentType :: Proxy FormUrlEncoded -> MediaType Source # contentTypes :: Proxy FormUrlEncoded -> NonEmpty MediaType Source #

Accept JSON Source #

    application/json

Instance details Defined in Servant.API.ContentTypes Methods contentType :: Proxy JSON -> MediaType Source # contentTypes :: Proxy JSON -> NonEmpty MediaType Source #

Accept OctetStream Source #

    application/octet-stream

Instance details Defined in Servant.API.ContentTypes Methods contentType :: Proxy OctetStream -> MediaType Source # contentTypes :: Proxy OctetStream -> NonEmpty MediaType Source #

Accept PlainText Source #

    text/plain;charset=utf-8

Instance details Defined in Servant.API.ContentTypes Methods contentType :: Proxy PlainText -> MediaType Source # contentTypes :: Proxy PlainText -> NonEmpty MediaType Source #

data FormUrlEncoded Source #

#### Instances

Instances details

Accept FormUrlEncoded Source #

    application/x-www-form-urlencoded

Instance details Defined in Servant.API.ContentTypes Methods contentType :: Proxy FormUrlEncoded -> MediaType Source # contentTypes :: Proxy FormUrlEncoded -> NonEmpty MediaType Source #
ToForm a => MimeRender FormUrlEncoded a Source # | `urlEncodeAsForm` Note that the `mimeUnrender p (mimeRender p x) == Right x` law only holds if every element of x is non-null (i.e., not `("", "")`)
Instance details Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy FormUrlEncoded -> a -> ByteString Source #
FromForm a => MimeUnrender FormUrlEncoded a Source # | `urlDecodeAsForm` Note that the `mimeUnrender p (mimeRender p x) == Right x` law only holds if every element of x is non-null (i.e., not `("", "")`)
Instance details Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy FormUrlEncoded -> ByteString -> Either String a Source # mimeUnrenderWithType :: Proxy FormUrlEncoded -> MediaType -> ByteString -> Either String a Source #
MimeRender FormUrlEncoded a => MimeRender FormUrlEncoded (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeRender :: Proxy FormUrlEncoded -> WithStatus _status a -> ByteString Source #
MimeUnrender FormUrlEncoded a => MimeUnrender FormUrlEncoded (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy FormUrlEncoded -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy FormUrlEncoded -> MediaType -> ByteString -> Either String (WithStatus _status a) Source #

data JSON Source #

#### Instances

Instances details

Accept JSON Source #

    application/json

Instance details Defined in Servant.API.ContentTypes Methods contentType :: Proxy JSON -> MediaType Source # contentTypes :: Proxy JSON -> NonEmpty MediaType Source #
ToJSON a => MimeRender JSON a Source # | `encode`
Instance details Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy JSON -> a -> ByteString Source #
FromJSON a => MimeUnrender JSON a Source # | `eitherDecode`
Instance details Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy JSON -> ByteString -> Either String a Source # mimeUnrenderWithType :: Proxy JSON -> MediaType -> ByteString -> Either String a Source #
MimeRender JSON a => MimeRender JSON (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeRender :: Proxy JSON -> WithStatus _status a -> ByteString Source #
MimeUnrender JSON a => MimeUnrender JSON (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy JSON -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy JSON -> MediaType -> ByteString -> Either String (WithStatus _status a) Source #

class Accept ctype => MimeRender (ctype :: k) a where Source #

Instantiate this class to register a way of serializing a type based on the `Accept` header.

Example:

    data MyContentType

    instance Accept MyContentType where
       contentType _ = "example" // "prs.me.mine" /: ("charset", "utf-8")

    instance Show a => MimeRender MyContentType a where
       mimeRender _ val = pack ("This is MINE! " ++ show val)

    type MyAPI = "path" :> Get '[MyContentType] Int

Methods

mimeRender :: Proxy ctype -> a -> ByteString Source #

#### Instances

Instances details

ToForm a => MimeRender FormUrlEncoded a Source # | `urlEncodeAsForm` Note that the `mimeUnrender p (mimeRender p x) == Right x` law only holds if every element of x is non-null (i.e., not `("", "")`)
Instance details Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy FormUrlEncoded -> a -> ByteString Source #
ToJSON a => MimeRender JSON a Source # | `encode`
Instance details Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy JSON -> a -> ByteString Source #
MimeRender OctetStream ByteString Source # | `fromStrict`
Instance details Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy OctetStream -> ByteString -> ByteString Source #

MimeRender OctetStream ByteString Source #

    id

Instance details Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy OctetStream -> ByteString -> ByteString Source #

MimeRender PlainText Text Source #

    fromStrict . TextS.encodeUtf8

Instance details Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy PlainText -> Text -> ByteString Source #
MimeRender PlainText Text Source # | `encodeUtf8`
Instance details Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy PlainText -> Text -> ByteString Source #

MimeRender PlainText String Source #

    BC.pack

Instance details Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy PlainText -> String -> ByteString Source #
MimeRender FormUrlEncoded a => MimeRender FormUrlEncoded (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeRender :: Proxy FormUrlEncoded -> WithStatus _status a -> ByteString Source #
MimeRender JSON a => MimeRender JSON (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeRender :: Proxy JSON -> WithStatus _status a -> ByteString Source #
MimeRender OctetStream a => MimeRender OctetStream (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeRender :: Proxy OctetStream -> WithStatus _status a -> ByteString Source #
MimeRender PlainText a => MimeRender PlainText (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeRender :: Proxy PlainText -> WithStatus _status a -> ByteString Source #

class Accept ctype => MimeUnrender (ctype :: k) a where Source #

Instantiate this class to register a way of deserializing a type based on the request's `Content-Type` header.

    >>> import Network.HTTP.Media hiding (Accept)
    >>> import qualified Data.ByteString.Lazy.Char8 as BSC
    >>> data MyContentType = MyContentType String

    >>> :{
    instance Accept MyContentType where
       contentType _ = "example" // "prs.me.mine" /: ("charset", "utf-8")
    :}

    >>> :{
    instance Read a => MimeUnrender MyContentType a where
       mimeUnrender _ bs = case BSC.take 12 bs of
         "MyContentType" -> return . read . BSC.unpack $ BSC.drop 12 bs
         _ -> Left "didn't start with the magic incantation"
    :}

    >>> type MyAPI = "path" :> ReqBody '[MyContentType] Int :> Get '[JSON] Int

Minimal complete definition

mimeUnrender | mimeUnrenderWithType

Methods

mimeUnrender :: Proxy ctype -> ByteString -> Either String a Source #

mimeUnrenderWithType :: Proxy ctype -> MediaType -> ByteString -> Either String a Source #

Variant which is given the actual `MediaType` provided by the other party.

In the most cases you don't want to branch based on the `MediaType`. See pr552 for a motivating example.

#### Instances

Instances details

MimeUnrender EventStream EventStreamChunk Source # |
Instance details Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy EventStream -> ByteString -> Either String EventStreamChunk Source # mimeUnrenderWithType :: Proxy EventStream -> MediaType -> ByteString -> Either String EventStreamChunk Source #
FromForm a => MimeUnrender FormUrlEncoded a Source # | `urlDecodeAsForm` Note that the `mimeUnrender p (mimeRender p x) == Right x` law only holds if every element of x is non-null (i.e., not `("", "")`)
Instance details Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy FormUrlEncoded -> ByteString -> Either String a Source # mimeUnrenderWithType :: Proxy FormUrlEncoded -> MediaType -> ByteString -> Either String a Source #
FromJSON a => MimeUnrender JSON a Source # | `eitherDecode`
Instance details Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy JSON -> ByteString -> Either String a Source # mimeUnrenderWithType :: Proxy JSON -> MediaType -> ByteString -> Either String a Source #

MimeUnrender OctetStream ByteString Source #

    Right . toStrict

Instance details Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy OctetStream -> ByteString -> Either String ByteString Source # mimeUnrenderWithType :: Proxy OctetStream -> MediaType -> ByteString -> Either String ByteString Source #

MimeUnrender OctetStream ByteString Source #

    Right . id

Instance details Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy OctetStream -> ByteString -> Either String ByteString Source # mimeUnrenderWithType :: Proxy OctetStream -> MediaType -> ByteString -> Either String ByteString Source #

MimeUnrender PlainText Text Source #

    left show . TextS.decodeUtf8' . toStrict

Instance details Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy PlainText -> ByteString -> Either String Text Source # mimeUnrenderWithType :: Proxy PlainText -> MediaType -> ByteString -> Either String Text Source #

MimeUnrender PlainText Text Source #

    left show . TextL.decodeUtf8'

Instance details Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy PlainText -> ByteString -> Either String Text Source # mimeUnrenderWithType :: Proxy PlainText -> MediaType -> ByteString -> Either String Text Source #

MimeUnrender PlainText String Source #

    Right . BC.unpack

Instance details Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy PlainText -> ByteString -> Either String String Source # mimeUnrenderWithType :: Proxy PlainText -> MediaType -> ByteString -> Either String String Source #
MimeUnrender FormUrlEncoded a => MimeUnrender FormUrlEncoded (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy FormUrlEncoded -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy FormUrlEncoded -> MediaType -> ByteString -> Either String (WithStatus _status a) Source #
MimeUnrender JSON a => MimeUnrender JSON (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy JSON -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy JSON -> MediaType -> ByteString -> Either String (WithStatus _status a) Source #
MimeUnrender OctetStream a => MimeUnrender OctetStream (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy OctetStream -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy OctetStream -> MediaType -> ByteString -> Either String (WithStatus _status a) Source #
MimeUnrender PlainText a => MimeUnrender PlainText (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy PlainText -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy PlainText -> MediaType -> ByteString -> Either String (WithStatus _status a) Source #

data NoContent Source #

A type for responses without content-body.

Constructors

NoContent |

#### Instances

Instances details

NFData NoContent Source # |
Instance details Defined in Servant.API.ContentTypes Methods rnf :: NoContent -> () Source #
Generic NoContent Source # |

Instance details

Defined in Servant.API.ContentTypes

Associated Types

type Rep NoContent |
Instance details Defined in Servant.API.ContentTypes type Rep NoContent = D1 ('MetaData "NoContent" "Servant.API.ContentTypes" "servant-0.20.3.0-FHJyKhVqWFv2rTftFmLybU" 'False) (C1 ('MetaCons "NoContent" 'PrefixI 'False) (U1 :: Type -> Type))

Methods

from :: NoContent -> Rep NoContent x Source #

to :: Rep NoContent x -> NoContent Source #

Read NoContent Source # |
Instance details Defined in Servant.API.ContentTypes Methods readsPrec :: Int -> ReadS NoContent Source # readList :: ReadS [NoContent] Source # readPrec :: ReadPrec NoContent Source # readListPrec :: ReadPrec [NoContent] Source #
Show NoContent Source # |
Instance details Defined in Servant.API.ContentTypes Methods showsPrec :: Int -> NoContent -> ShowS Source # show :: NoContent -> String Source # showList :: [NoContent] -> ShowS Source #
Eq NoContent Source # |
Instance details Defined in Servant.API.ContentTypes Methods (==) :: NoContent -> NoContent -> Bool Source # (/=) :: NoContent -> NoContent -> Bool Source #
HasStatus NoContent Source # | If an API can respond with `NoContent` we assume that this will happen with the status code 204 No Content. If this needs to be overridden, `WithStatus` can be used.

Instance details

Defined in Servant.API.UVerb

Associated Types

type StatusOf NoContent |
Instance details Defined in Servant.API.UVerb type StatusOf NoContent = 204

AllMime (ctyp ': (ctyp' ': ctyps)) => AllMimeRender (ctyp ': (ctyp' ': ctyps)) NoContent Source # |
Instance details Defined in Servant.API.ContentTypes Methods allMimeRender :: Proxy (ctyp ': (ctyp' ': ctyps)) -> NoContent -> [(MediaType, ByteString)] Source #
Accept ctyp => AllMimeRender '[ctyp] NoContent Source # |
Instance details Defined in Servant.API.ContentTypes Methods allMimeRender :: Proxy '[ctyp] -> NoContent -> [(MediaType, ByteString)] Source #
type Rep NoContent Source # |
Instance details Defined in Servant.API.ContentTypes type Rep NoContent = D1 ('MetaData "NoContent" "Servant.API.ContentTypes" "servant-0.20.3.0-FHJyKhVqWFv2rTftFmLybU" 'False) (C1 ('MetaCons "NoContent" 'PrefixI 'False) (U1 :: Type -> Type))
type StatusOf NoContent Source # |
Instance details Defined in Servant.API.UVerb type StatusOf NoContent = 204

data OctetStream Source #

#### Instances

Instances details

Accept OctetStream Source #

    application/octet-stream

Instance details Defined in Servant.API.ContentTypes Methods contentType :: Proxy OctetStream -> MediaType Source # contentTypes :: Proxy OctetStream -> NonEmpty MediaType Source #
MimeRender OctetStream ByteString Source # | `fromStrict`
Instance details Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy OctetStream -> ByteString -> ByteString Source #

MimeRender OctetStream ByteString Source #

    id

Instance details Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy OctetStream -> ByteString -> ByteString Source #

MimeUnrender OctetStream ByteString Source #

    Right . toStrict

Instance details Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy OctetStream -> ByteString -> Either String ByteString Source # mimeUnrenderWithType :: Proxy OctetStream -> MediaType -> ByteString -> Either String ByteString Source #

MimeUnrender OctetStream ByteString Source #

    Right . id

Instance details Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy OctetStream -> ByteString -> Either String ByteString Source # mimeUnrenderWithType :: Proxy OctetStream -> MediaType -> ByteString -> Either String ByteString Source #
MimeRender OctetStream a => MimeRender OctetStream (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeRender :: Proxy OctetStream -> WithStatus _status a -> ByteString Source #
MimeUnrender OctetStream a => MimeUnrender OctetStream (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy OctetStream -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy OctetStream -> MediaType -> ByteString -> Either String (WithStatus _status a) Source #

data PlainText Source #

#### Instances

Instances details

Accept PlainText Source #

    text/plain;charset=utf-8

Instance details Defined in Servant.API.ContentTypes Methods contentType :: Proxy PlainText -> MediaType Source # contentTypes :: Proxy PlainText -> NonEmpty MediaType Source #

MimeRender PlainText Text Source #

    fromStrict . TextS.encodeUtf8

Instance details Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy PlainText -> Text -> ByteString Source #
MimeRender PlainText Text Source # | `encodeUtf8`
Instance details Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy PlainText -> Text -> ByteString Source #

MimeRender PlainText String Source #

    BC.pack

Instance details Defined in Servant.API.ContentTypes Methods mimeRender :: Proxy PlainText -> String -> ByteString Source #

MimeUnrender PlainText Text Source #

    left show . TextS.decodeUtf8' . toStrict

Instance details Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy PlainText -> ByteString -> Either String Text Source # mimeUnrenderWithType :: Proxy PlainText -> MediaType -> ByteString -> Either String Text Source #

MimeUnrender PlainText Text Source #

    left show . TextL.decodeUtf8'

Instance details Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy PlainText -> ByteString -> Either String Text Source # mimeUnrenderWithType :: Proxy PlainText -> MediaType -> ByteString -> Either String Text Source #

MimeUnrender PlainText String Source #

    Right . BC.unpack

Instance details Defined in Servant.API.ContentTypes Methods mimeUnrender :: Proxy PlainText -> ByteString -> Either String String Source # mimeUnrenderWithType :: Proxy PlainText -> MediaType -> ByteString -> Either String String Source #
MimeRender PlainText a => MimeRender PlainText (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeRender :: Proxy PlainText -> WithStatus _status a -> ByteString Source #
MimeUnrender PlainText a => MimeUnrender PlainText (WithStatus _status a) Source # |
Instance details Defined in Servant.API.UVerb Methods mimeUnrender :: Proxy PlainText -> ByteString -> Either String (WithStatus _status a) Source # mimeUnrenderWithType :: Proxy PlainText -> MediaType -> ByteString -> Either String (WithStatus _status a) Source #

Serializing and deserializing types based on `Accept` and `Content-Type` headers.

# Response Headers

data ResponseHeader (sym :: Symbol) a Source #

Constructors

Header a |
MissingHeader |
UndecodableHeader ByteString |

#### Instances

Instances details

Functor (ResponseHeader sym) Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods fmap :: (a -> b) -> ResponseHeader sym a -> ResponseHeader sym b Source # (<$) :: a -> ResponseHeader sym b -> ResponseHeader sym a Source #
NFData a => NFData (ResponseHeader sym a) Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods rnf :: ResponseHeader sym a -> () Source #
Show a => Show (ResponseHeader sym a) Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods showsPrec :: Int -> ResponseHeader sym a -> ShowS Source # show :: ResponseHeader sym a -> String Source # showList :: [ResponseHeader sym a] -> ShowS Source #
Eq a => Eq (ResponseHeader sym a) Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods (==) :: ResponseHeader sym a -> ResponseHeader sym a -> Bool Source # (/=) :: ResponseHeader sym a -> ResponseHeader sym a -> Bool Source #

class AddHeader (mods :: [Type]) (h :: Symbol) v orig new | mods h v orig -> new, new -> mods, new -> h, new -> v, new -> orig Source #

Minimal complete definition

addOptionalHeader

#### Instances

Instances details

(KnownSymbol h, ToHttpApiData v, new ~ Headers '[Header' mods h v] a) => AddHeader mods h v a new Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods addOptionalHeader :: ResponseHeader h v -> a -> new
(AddHeader mods h v old new, AddHeader mods h v (Union oldrest) (Union newrest), oldrest ~ (a ': as), newrest ~ (b ': bs)) => AddHeader mods h v (Union (old ': (a ': as))) (Union (new ': (b ': bs))) Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods addOptionalHeader :: ResponseHeader h v -> Union (old ': (a ': as)) -> Union (new ': (b ': bs))
AddHeader mods h v old new => AddHeader mods h v (Union '[old]) (Union '[new]) Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods addOptionalHeader :: ResponseHeader h v -> Union '[old] -> Union '[new]
(KnownSymbol h, ToHttpApiData v) => AddHeader mods h v (Headers (fst ': rest) a) (Headers (Header' mods h v ': (fst ': rest)) a) Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods addOptionalHeader :: ResponseHeader h v -> Headers (fst ': rest) a -> Headers (Header' mods h v ': (fst ': rest)) a

class BuildHeadersTo (hs :: [Type]) where Source #

Methods

buildHeadersTo :: [Header] -> HList hs Source #

#### Instances

Instances details

BuildHeadersTo ('[] :: [Type]) Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods buildHeadersTo :: [Header] -> HList ('[] :: [Type]) Source #
(FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h) => BuildHeadersTo (Header' mods h v ': xs) Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods buildHeadersTo :: [Header] -> HList (Header' mods h v ': xs) Source #

class GetHeaders ls where Source #

Methods

getHeaders :: ls -> [Header] Source #

#### Instances

Instances details

GetHeadersFromHList hs => GetHeaders (HList hs) Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods getHeaders :: HList hs -> [Header] Source #
GetHeaders' hs => GetHeaders (Headers hs a) Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods getHeaders :: Headers hs a -> [Header] Source #

data HList (a :: [Type]) where Source #

Constructors

HNil :: HList ('[] :: [Type]) |
HCons :: forall (h :: Symbol) x (xs :: [Type]) (mods :: [Type]). ResponseHeader h x -> HList xs -> HList (Header' mods h x ': xs) |

#### Instances

Instances details

NFDataHList xs => NFData (HList xs) Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods rnf :: HList xs -> () Source #
GetHeadersFromHList hs => GetHeaders (HList hs) Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods getHeaders :: HList hs -> [Header] Source #

class HasResponseHeader (h :: Symbol) a (headers :: [Type]) Source #

Minimal complete definition

hlistLookupHeader

#### Instances

Instances details

HasResponseHeader h a (Header' mods h a ': rest) Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods hlistLookupHeader :: HList (Header' mods h a ': rest) -> ResponseHeader h a
HasResponseHeader h a rest => HasResponseHeader h a (first ': rest) Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods hlistLookupHeader :: HList (first ': rest) -> ResponseHeader h a

data Headers (ls :: [Type]) a Source #

Response Header objects. You should never need to construct one directly. Instead, use `addOptionalHeader`.

Constructors

Headers |

Fields

- getResponse :: a

  The underlying value of a `Headers`

- getHeadersHList :: HList ls

  HList of headers.

#### Instances

Instances details

(KnownSymbol h, ToHttpApiData v) => AddHeader mods h v (Headers (fst ': rest) a) (Headers (Header' mods h v ': (fst ': rest)) a) Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods addOptionalHeader :: ResponseHeader h v -> Headers (fst ': rest) a -> Headers (Header' mods h v ': (fst ': rest)) a
Functor (Headers ls) Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods fmap :: (a -> b) -> Headers ls a -> Headers ls b Source # (<$) :: a -> Headers ls b -> Headers ls a Source #
(NFDataHList ls, NFData a) => NFData (Headers ls a) Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods rnf :: Headers ls a -> () Source #
GetHeaders' hs => GetHeaders (Headers hs a) Source # |
Instance details Defined in Servant.API.ResponseHeaders Methods getHeaders :: Headers hs a -> [Header] Source #
HasStatus a => HasStatus (Headers ls a) Source # |

Instance details

Defined in Servant.API.UVerb

Associated Types

type StatusOf (Headers ls a) |
Instance details Defined in Servant.API.UVerb type StatusOf (Headers ls a) = StatusOf a

type StatusOf (Headers ls a) Source # |
Instance details Defined in Servant.API.UVerb type StatusOf (Headers ls a) = StatusOf a

addHeader :: forall (h :: Symbol) v orig new. AddHeader '[Optional, Strict] h v orig new => v -> orig -> new Source #

`addHeader` adds a header to a response. Note that it changes the type of the value in the following ways:

1. A simple value is wrapped in "Headers '[hdr]":

    >>> let example0 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;
    >>> getHeaders example0
    [("someheader","5")]

1. A value that already has a header has its new header *prepended* to the existing list:

    >>> let example1 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;
    >>> let example2 = addHeader True example1 :: Headers '[Header "1st" Bool, Header "someheader" Int] String
    >>> getHeaders example2
    [("1st","true"),("someheader","5")]

Note that while in your handlers type annotations are not required, since the type can be inferred from the API type, in other cases you may find yourself needing to add annotations.

addHeader' :: forall (mods :: [Type]) (h :: Symbol) v orig new. AddHeader mods h v orig new => v -> orig -> new Source #

Same as `addHeader` but works with `Header'`, so it's possible to use any `mods`.

lookupResponseHeader :: forall (h :: Symbol) a (headers :: [Type]) r. HasResponseHeader h a headers => Headers headers r -> ResponseHeader h a Source #

Look up a specific ResponseHeader, without having to know what position it is in the HList.

    >>> let example1 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String
    >>> let example2 = addHeader True example1 :: Headers '[Header "1st" Bool, Header "someheader" Int] String
    >>> lookupResponseHeader example2 :: ResponseHeader "someheader" Int
    Header 5

    >>> lookupResponseHeader example2 :: ResponseHeader "1st" Bool
    Header True

Usage of this function relies on an explicit type annotation of the header to be looked up. This can be done with type annotations on the result, or with an explicit type application. In this example, the type of header value is determined by the type-inference, we only specify the name of the header:

    >>> :set -XTypeApplications
    >>> case lookupResponseHeader @"1st" example2 of { Header b -> b ; _ -> False }
    True

Since: 0.15

noHeader :: forall (h :: Symbol) v orig new. AddHeader '[Optional, Strict] h v orig new => orig -> new Source #

Deliberately do not add a header to a value.

    >>> let example1 = noHeader "hi" :: Headers '[Header "someheader" Int] String
    >>> getHeaders example1
    []

noHeader' :: forall (mods :: [Type]) (h :: Symbol) v orig new. AddHeader mods h v orig new => orig -> new Source #

Same as `noHeader` but works with `Header'`, so it's possible to use any `mods`.

# Untyped endpoints

module Servant.API.Raw

Plugging in a wai `Application`, serving directories

# FromHttpApiData and ToHttpApiData

class FromHttpApiData a where Source #

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

Methods

parseUrlPiece :: Text -> Either Text a Source #

Parse URL path piece.

parseHeader :: ByteString -> Either Text a Source #

Parse HTTP header value.

parseQueryParam :: Text -> Either Text a Source #

Parse query param value.

#### Instances

Instances details

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, setCookiePartitioned = False})

Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text SetCookie Source # parseHeader :: ByteString -> Either Text SetCookie Source # parseQueryParam :: Text -> Either Text SetCookie Source #
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 Methods parseUrlPiece :: Text -> Either Text Void Source # parseHeader :: ByteString -> Either Text Void Source # parseQueryParam :: Text -> Either Text Void Source #
FromHttpApiData All |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text All Source # parseHeader :: ByteString -> Either Text All Source # parseQueryParam :: Text -> Either Text All Source #
FromHttpApiData Any |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Any Source # parseHeader :: ByteString -> Either Text Any Source # parseQueryParam :: Text -> Either Text Any Source #

FromHttpApiData Version

    >>> showVersion <$> parseUrlPiece "1.2.3"
    Right "1.2.3"

Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Version Source # parseHeader :: ByteString -> Either Text Version Source # parseQueryParam :: Text -> Either Text Version Source #
FromHttpApiData Int16 |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Int16 Source # parseHeader :: ByteString -> Either Text Int16 Source # parseQueryParam :: Text -> Either Text Int16 Source #
FromHttpApiData Int32 |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Int32 Source # parseHeader :: ByteString -> Either Text Int32 Source # parseQueryParam :: Text -> Either Text Int32 Source #
FromHttpApiData Int64 |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Int64 Source # parseHeader :: ByteString -> Either Text Int64 Source # parseQueryParam :: Text -> Either Text Int64 Source #
FromHttpApiData Int8 |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Int8 Source # parseHeader :: ByteString -> Either Text Int8 Source # parseQueryParam :: Text -> Either Text Int8 Source #
FromHttpApiData Word16 |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Word16 Source # parseHeader :: ByteString -> Either Text Word16 Source # parseQueryParam :: Text -> Either Text Word16 Source #
FromHttpApiData Word32 |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Word32 Source # parseHeader :: ByteString -> Either Text Word32 Source # parseQueryParam :: Text -> Either Text Word32 Source #
FromHttpApiData Word64 |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Word64 Source # parseHeader :: ByteString -> Either Text Word64 Source # parseQueryParam :: Text -> Either Text Word64 Source #
FromHttpApiData Word8 |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Word8 Source # parseHeader :: ByteString -> Either Text Word8 Source # parseQueryParam :: Text -> Either Text Word8 Source #
FromHttpApiData Ordering |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Ordering Source # parseHeader :: ByteString -> Either Text Ordering Source # parseQueryParam :: Text -> Either Text Ordering Source #
FromHttpApiData Text |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Text Source # parseHeader :: ByteString -> Either Text Text Source # parseQueryParam :: Text -> Either Text Text Source #
FromHttpApiData Text |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Text Source # parseHeader :: ByteString -> Either Text Text Source # parseQueryParam :: Text -> Either Text Text Source #

FromHttpApiData Day

    >>> toGregorian <$> parseUrlPiece "2016-12-01"
    Right (2016,12,1)

Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Day Source # parseHeader :: ByteString -> Either Text Day Source # parseQueryParam :: Text -> Either Text Day Source #

FromHttpApiData Month

    >>> parseUrlPiece "2021-01" :: Either Text Month
    Right 2021-01

Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Month Source # parseHeader :: ByteString -> Either Text Month Source # parseQueryParam :: Text -> Either Text Month Source #

FromHttpApiData Quarter

    >>> parseUrlPiece "2021-q1" :: Either Text Quarter
    Right 2021-Q1

Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Quarter Source # parseHeader :: ByteString -> Either Text Quarter Source # parseQueryParam :: Text -> Either Text Quarter Source #

FromHttpApiData QuarterOfYear

    >>> parseUrlPiece "q2" :: Either Text QuarterOfYear
    Right Q2

    >>> parseUrlPiece "Q3" :: Either Text QuarterOfYear
    Right Q3

Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text QuarterOfYear Source # parseHeader :: ByteString -> Either Text QuarterOfYear Source # parseQueryParam :: Text -> Either Text QuarterOfYear Source #

FromHttpApiData DayOfWeek

    >>> parseUrlPiece "Monday" :: Either Text DayOfWeek
    Right Monday

Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text DayOfWeek Source # parseHeader :: ByteString -> Either Text DayOfWeek Source # parseQueryParam :: Text -> Either Text DayOfWeek Source #
FromHttpApiData NominalDiffTime |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text NominalDiffTime Source # parseHeader :: ByteString -> Either Text NominalDiffTime Source # parseQueryParam :: Text -> Either Text NominalDiffTime Source #

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 Methods parseUrlPiece :: Text -> Either Text UTCTime Source # parseHeader :: ByteString -> Either Text UTCTime Source # parseQueryParam :: Text -> Either Text UTCTime Source #

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 Methods parseUrlPiece :: Text -> Either Text LocalTime Source # parseHeader :: ByteString -> Either Text LocalTime Source # parseQueryParam :: Text -> Either Text LocalTime Source #

FromHttpApiData TimeOfDay

    >>> parseUrlPiece "14:55:01.333" :: Either Text TimeOfDay
    Right 14:55:01.333

Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text TimeOfDay Source # parseHeader :: ByteString -> Either Text TimeOfDay Source # parseQueryParam :: Text -> Either Text TimeOfDay Source #

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 Methods parseUrlPiece :: Text -> Either Text ZonedTime Source # parseHeader :: ByteString -> Either Text ZonedTime Source # parseQueryParam :: Text -> Either Text ZonedTime Source #
FromHttpApiData UUID |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text UUID Source # parseHeader :: ByteString -> Either Text UUID Source # parseQueryParam :: Text -> Either Text UUID Source #
FromHttpApiData Integer |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Integer Source # parseHeader :: ByteString -> Either Text Integer Source # parseQueryParam :: Text -> Either Text Integer Source #
FromHttpApiData Natural |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Natural Source # parseHeader :: ByteString -> Either Text Natural Source # parseQueryParam :: Text -> Either Text Natural Source #
FromHttpApiData String |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text String Source # parseHeader :: ByteString -> Either Text String Source # parseQueryParam :: Text -> Either Text String Source #

FromHttpApiData ()

    >>> parseUrlPiece "_" :: Either Text ()
    Right ()

Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text () Source # parseHeader :: ByteString -> Either Text () Source # parseQueryParam :: Text -> Either Text () Source #
FromHttpApiData Bool |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Bool Source # parseHeader :: ByteString -> Either Text Bool Source # parseQueryParam :: Text -> Either Text Bool Source #
FromHttpApiData Char |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Char Source # parseHeader :: ByteString -> Either Text Char Source # parseQueryParam :: Text -> Either Text Char Source #
FromHttpApiData Double |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Double Source # parseHeader :: ByteString -> Either Text Double Source # parseQueryParam :: Text -> Either Text Double Source #
FromHttpApiData Float |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Float Source # parseHeader :: ByteString -> Either Text Float Source # parseQueryParam :: Text -> Either Text Float Source #
FromHttpApiData Int |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Int Source # parseHeader :: ByteString -> Either Text Int Source # parseQueryParam :: Text -> Either Text Int Source #
FromHttpApiData Word |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text Word Source # parseHeader :: ByteString -> Either Text Word Source # parseQueryParam :: Text -> Either Text Word Source #
FromHttpApiData a => FromHttpApiData (First a) |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (First a) Source # parseHeader :: ByteString -> Either Text (First a) Source # parseQueryParam :: Text -> Either Text (First a) Source #
FromHttpApiData a => FromHttpApiData (Last a) |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Last a) Source # parseHeader :: ByteString -> Either Text (Last a) Source # parseQueryParam :: Text -> Either Text (Last a) Source #
FromHttpApiData a => FromHttpApiData (Max a) |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Max a) Source # parseHeader :: ByteString -> Either Text (Max a) Source # parseQueryParam :: Text -> Either Text (Max a) Source #
FromHttpApiData a => FromHttpApiData (Min a) |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Min a) Source # parseHeader :: ByteString -> Either Text (Min a) Source # parseQueryParam :: Text -> Either Text (Min a) Source #
FromHttpApiData a => FromHttpApiData (Identity a) | Since: http-api-data-0.4.2
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Identity a) Source # parseHeader :: ByteString -> Either Text (Identity a) Source # parseQueryParam :: Text -> Either Text (Identity a) Source #
FromHttpApiData a => FromHttpApiData (First a) |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (First a) Source # parseHeader :: ByteString -> Either Text (First a) Source # parseQueryParam :: Text -> Either Text (First a) Source #
FromHttpApiData a => FromHttpApiData (Last a) |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Last a) Source # parseHeader :: ByteString -> Either Text (Last a) Source # parseQueryParam :: Text -> Either Text (Last a) Source #
FromHttpApiData a => FromHttpApiData (Dual a) |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Dual a) Source # parseHeader :: ByteString -> Either Text (Dual a) Source # parseQueryParam :: Text -> Either Text (Dual a) Source #
FromHttpApiData a => FromHttpApiData (Product a) |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Product a) Source # parseHeader :: ByteString -> Either Text (Product a) Source # parseQueryParam :: Text -> Either Text (Product a) Source #
FromHttpApiData a => FromHttpApiData (Sum a) |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Sum a) Source # parseHeader :: ByteString -> Either Text (Sum a) Source # parseQueryParam :: Text -> Either Text (Sum a) Source #
FromHttpApiData a => FromHttpApiData (LenientData a) |
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (LenientData a) Source # parseHeader :: ByteString -> Either Text (LenientData a) Source # parseQueryParam :: Text -> Either Text (LenientData a) Source #

FromHttpApiData a => FromHttpApiData (Maybe a)

    >>> parseUrlPiece "Just 123" :: Either Text (Maybe Int)
    Right (Just 123)

Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Maybe a) Source # parseHeader :: ByteString -> Either Text (Maybe a) Source # parseQueryParam :: Text -> Either Text (Maybe a) Source #
HasResolution a => FromHttpApiData (Fixed a) | Note: this instance is not polykinded
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Fixed a) Source # parseHeader :: ByteString -> Either Text (Fixed a) Source # parseQueryParam :: Text -> Either Text (Fixed a) Source #

(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 Methods parseUrlPiece :: Text -> Either Text (Either a b) Source # parseHeader :: ByteString -> Either Text (Either a b) Source # parseQueryParam :: Text -> Either Text (Either a b) Source #
(KnownNat min, KnownNat max) => FromHttpApiData (Range min max) Source # |
Instance details Defined in Servant.API.Range Methods parseUrlPiece :: Text -> Either Text (Range min max) Source # parseHeader :: ByteString -> Either Text (Range min max) Source # parseQueryParam :: Text -> Either Text (Range min max) Source #
FromHttpApiData a => FromHttpApiData (Const a b) | Since: http-api-data-0.4.2
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Const a b) Source # parseHeader :: ByteString -> Either Text (Const a b) Source # parseQueryParam :: Text -> Either Text (Const a b) Source #
FromHttpApiData a => FromHttpApiData (Tagged b a) | Note: this instance is not polykinded
Instance details Defined in Web.Internal.HttpApiData Methods parseUrlPiece :: Text -> Either Text (Tagged b a) Source # parseHeader :: ByteString -> Either Text (Tagged b a) Source # parseQueryParam :: Text -> Either Text (Tagged b a) Source #

class ToHttpApiData a where Source #

Convert value to HTTP API data.

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

Minimal complete definition

toUrlPiece | toQueryParam

Methods

toUrlPiece :: a -> Text Source #

Convert to URL path piece.

toEncodedUrlPiece :: a -> Builder Source #

Convert to a URL path piece, making sure to encode any special chars. The default definition uses ``urlEncodeBuilder` `False`` but this may be overriden with a more efficient version.

toHeader :: a -> ByteString Source #

Convert to HTTP header value.

toQueryParam :: a -> Text Source #

Convert to query param value.

toEncodedQueryParam :: a -> Builder Source #

Convert to URL query param, The default definition uses ``urlEncodeBuilder` `True`` but this may be overriden with a more efficient version.

Since: http-api-data-0.5.1

#### Instances

Instances details

ToHttpApiData SetCookie

Note: this instance works correctly for alphanumeric name and value

    >>> let Right c = parseUrlPiece "SESSID=r2t5uvjq435r4q7ib3vtdjq120" :: Either Text SetCookie
    >>> toUrlPiece c
    "SESSID=r2t5uvjq435r4q7ib3vtdjq120"

    >>> toHeader c
    "SESSID=r2t5uvjq435r4q7ib3vtdjq120"

Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: SetCookie -> Text Source # toEncodedUrlPiece :: SetCookie -> Builder Source # toHeader :: SetCookie -> ByteString Source # toQueryParam :: SetCookie -> Text Source # toEncodedQueryParam :: SetCookie -> Builder Source #
ToHttpApiData Void |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Void -> Text Source # toEncodedUrlPiece :: Void -> Builder Source # toHeader :: Void -> ByteString Source # toQueryParam :: Void -> Text Source # toEncodedQueryParam :: Void -> Builder Source #
ToHttpApiData All |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: All -> Text Source # toEncodedUrlPiece :: All -> Builder Source # toHeader :: All -> ByteString Source # toQueryParam :: All -> Text Source # toEncodedQueryParam :: All -> Builder Source #
ToHttpApiData Any |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Any -> Text Source # toEncodedUrlPiece :: Any -> Builder Source # toHeader :: Any -> ByteString Source # toQueryParam :: Any -> Text Source # toEncodedQueryParam :: Any -> Builder Source #

ToHttpApiData Version

    >>> toUrlPiece (Version [1, 2, 3] [])
    "1.2.3"

Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Version -> Text Source # toEncodedUrlPiece :: Version -> Builder Source # toHeader :: Version -> ByteString Source # toQueryParam :: Version -> Text Source # toEncodedQueryParam :: Version -> Builder Source #
ToHttpApiData Int16 |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int16 -> Text Source # toEncodedUrlPiece :: Int16 -> Builder Source # toHeader :: Int16 -> ByteString Source # toQueryParam :: Int16 -> Text Source # toEncodedQueryParam :: Int16 -> Builder Source #
ToHttpApiData Int32 |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int32 -> Text Source # toEncodedUrlPiece :: Int32 -> Builder Source # toHeader :: Int32 -> ByteString Source # toQueryParam :: Int32 -> Text Source # toEncodedQueryParam :: Int32 -> Builder Source #
ToHttpApiData Int64 |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int64 -> Text Source # toEncodedUrlPiece :: Int64 -> Builder Source # toHeader :: Int64 -> ByteString Source # toQueryParam :: Int64 -> Text Source # toEncodedQueryParam :: Int64 -> Builder Source #
ToHttpApiData Int8 |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int8 -> Text Source # toEncodedUrlPiece :: Int8 -> Builder Source # toHeader :: Int8 -> ByteString Source # toQueryParam :: Int8 -> Text Source # toEncodedQueryParam :: Int8 -> Builder Source #
ToHttpApiData Word16 |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word16 -> Text Source # toEncodedUrlPiece :: Word16 -> Builder Source # toHeader :: Word16 -> ByteString Source # toQueryParam :: Word16 -> Text Source # toEncodedQueryParam :: Word16 -> Builder Source #
ToHttpApiData Word32 |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word32 -> Text Source # toEncodedUrlPiece :: Word32 -> Builder Source # toHeader :: Word32 -> ByteString Source # toQueryParam :: Word32 -> Text Source # toEncodedQueryParam :: Word32 -> Builder Source #
ToHttpApiData Word64 |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word64 -> Text Source # toEncodedUrlPiece :: Word64 -> Builder Source # toHeader :: Word64 -> ByteString Source # toQueryParam :: Word64 -> Text Source # toEncodedQueryParam :: Word64 -> Builder Source #
ToHttpApiData Word8 |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word8 -> Text Source # toEncodedUrlPiece :: Word8 -> Builder Source # toHeader :: Word8 -> ByteString Source # toQueryParam :: Word8 -> Text Source # toEncodedQueryParam :: Word8 -> Builder Source #
ToHttpApiData Ordering |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Ordering -> Text Source # toEncodedUrlPiece :: Ordering -> Builder Source # toHeader :: Ordering -> ByteString Source # toQueryParam :: Ordering -> Text Source # toEncodedQueryParam :: Ordering -> Builder Source #
ToHttpApiData Link Source # |
Instance details Defined in Servant.Links Methods toUrlPiece :: Link -> Text Source # toEncodedUrlPiece :: Link -> Builder Source # toHeader :: Link -> ByteString Source # toQueryParam :: Link -> Text Source # toEncodedQueryParam :: Link -> Builder Source #
ToHttpApiData Text |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Text -> Text Source # toEncodedUrlPiece :: Text -> Builder Source # toHeader :: Text -> ByteString Source # toQueryParam :: Text -> Text Source # toEncodedQueryParam :: Text -> Builder Source #
ToHttpApiData Text |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Text -> Text Source # toEncodedUrlPiece :: Text -> Builder Source # toHeader :: Text -> ByteString Source # toQueryParam :: Text -> Text Source # toEncodedQueryParam :: Text -> Builder Source #

ToHttpApiData Day

    >>> toUrlPiece (fromGregorian 2015 10 03)
    "2015-10-03"

Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Day -> Text Source # toEncodedUrlPiece :: Day -> Builder Source # toHeader :: Day -> ByteString Source # toQueryParam :: Day -> Text Source # toEncodedQueryParam :: Day -> Builder Source #

ToHttpApiData Month

    >>> import Data.Time.Calendar.Month.Compat (Month (..))
    >>> MkMonth 24482
    2040-03

    >>> toUrlPiece $ MkMonth 24482
    "2040-03"

Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Month -> Text Source # toEncodedUrlPiece :: Month -> Builder Source # toHeader :: Month -> ByteString Source # toQueryParam :: Month -> Text Source # toEncodedQueryParam :: Month -> Builder Source #

ToHttpApiData Quarter

    >>> import Data.Time.Calendar.Quarter.Compat (Quarter (..))
    >>> MkQuarter 8040
    2010-Q1

    >>> toUrlPiece $ MkQuarter 8040
    "2010-q1"

Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Quarter -> Text Source # toEncodedUrlPiece :: Quarter -> Builder Source # toHeader :: Quarter -> ByteString Source # toQueryParam :: Quarter -> Text Source # toEncodedQueryParam :: Quarter -> Builder Source #

ToHttpApiData QuarterOfYear

    >>> toUrlPiece Q4
    "q4"

Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: QuarterOfYear -> Text Source # toEncodedUrlPiece :: QuarterOfYear -> Builder Source # toHeader :: QuarterOfYear -> ByteString Source # toQueryParam :: QuarterOfYear -> Text Source # toEncodedQueryParam :: QuarterOfYear -> Builder Source #

ToHttpApiData DayOfWeek

    >>> toUrlPiece Monday
    "monday"

Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: DayOfWeek -> Text Source # toEncodedUrlPiece :: DayOfWeek -> Builder Source # toHeader :: DayOfWeek -> ByteString Source # toQueryParam :: DayOfWeek -> Text Source # toEncodedQueryParam :: DayOfWeek -> Builder Source #
ToHttpApiData NominalDiffTime |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: NominalDiffTime -> Text Source # toEncodedUrlPiece :: NominalDiffTime -> Builder Source # toHeader :: NominalDiffTime -> ByteString Source # toQueryParam :: NominalDiffTime -> Text Source # toEncodedQueryParam :: NominalDiffTime -> Builder Source #

ToHttpApiData UTCTime

    >>> toUrlPiece $ UTCTime (fromGregorian 2015 10 03) 864.5
    "2015-10-03T00:14:24.500Z"

Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: UTCTime -> Text Source # toEncodedUrlPiece :: UTCTime -> Builder Source # toHeader :: UTCTime -> ByteString Source # toQueryParam :: UTCTime -> Text Source # toEncodedQueryParam :: UTCTime -> Builder Source #

ToHttpApiData LocalTime

    >>> toUrlPiece $ LocalTime (fromGregorian 2015 10 03) (TimeOfDay 14 55 21.687)
    "2015-10-03T14:55:21.687"

Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: LocalTime -> Text Source # toEncodedUrlPiece :: LocalTime -> Builder Source # toHeader :: LocalTime -> ByteString Source # toQueryParam :: LocalTime -> Text Source # toEncodedQueryParam :: LocalTime -> Builder Source #

ToHttpApiData TimeOfDay

    >>> toUrlPiece $ TimeOfDay 14 55 23.1
    "14:55:23.100"

Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: TimeOfDay -> Text Source # toEncodedUrlPiece :: TimeOfDay -> Builder Source # toHeader :: TimeOfDay -> ByteString Source # toQueryParam :: TimeOfDay -> Text Source # toEncodedQueryParam :: TimeOfDay -> Builder Source #

ToHttpApiData ZonedTime

    >>> toUrlPiece $ ZonedTime (LocalTime (fromGregorian 2015 10 03) (TimeOfDay 14 55 51.001)) utc
    "2015-10-03T14:55:51.001Z"

    >>> toUrlPiece $ ZonedTime (LocalTime (fromGregorian 2015 10 03) (TimeOfDay 14 55 51.001)) (TimeZone 120 True "EET")
    "2015-10-03T14:55:51.001+02:00"

Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: ZonedTime -> Text Source # toEncodedUrlPiece :: ZonedTime -> Builder Source # toHeader :: ZonedTime -> ByteString Source # toQueryParam :: ZonedTime -> Text Source # toEncodedQueryParam :: ZonedTime -> Builder Source #
ToHttpApiData UUID |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: UUID -> Text Source # toEncodedUrlPiece :: UUID -> Builder Source # toHeader :: UUID -> ByteString Source # toQueryParam :: UUID -> Text Source # toEncodedQueryParam :: UUID -> Builder Source #
ToHttpApiData Integer |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Integer -> Text Source # toEncodedUrlPiece :: Integer -> Builder Source # toHeader :: Integer -> ByteString Source # toQueryParam :: Integer -> Text Source # toEncodedQueryParam :: Integer -> Builder Source #
ToHttpApiData Natural |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Natural -> Text Source # toEncodedUrlPiece :: Natural -> Builder Source # toHeader :: Natural -> ByteString Source # toQueryParam :: Natural -> Text Source # toEncodedQueryParam :: Natural -> Builder Source #
ToHttpApiData String |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: String -> Text Source # toEncodedUrlPiece :: String -> Builder Source # toHeader :: String -> ByteString Source # toQueryParam :: String -> Text Source # toEncodedQueryParam :: String -> Builder Source #

ToHttpApiData ()

    >>> toUrlPiece ()
    "_"

Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: () -> Text Source # toEncodedUrlPiece :: () -> Builder Source # toHeader :: () -> ByteString Source # toQueryParam :: () -> Text Source # toEncodedQueryParam :: () -> Builder Source #
ToHttpApiData Bool |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Bool -> Text Source # toEncodedUrlPiece :: Bool -> Builder Source # toHeader :: Bool -> ByteString Source # toQueryParam :: Bool -> Text Source # toEncodedQueryParam :: Bool -> Builder Source #
ToHttpApiData Char |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Char -> Text Source # toEncodedUrlPiece :: Char -> Builder Source # toHeader :: Char -> ByteString Source # toQueryParam :: Char -> Text Source # toEncodedQueryParam :: Char -> Builder Source #
ToHttpApiData Double |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Double -> Text Source # toEncodedUrlPiece :: Double -> Builder Source # toHeader :: Double -> ByteString Source # toQueryParam :: Double -> Text Source # toEncodedQueryParam :: Double -> Builder Source #
ToHttpApiData Float |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Float -> Text Source # toEncodedUrlPiece :: Float -> Builder Source # toHeader :: Float -> ByteString Source # toQueryParam :: Float -> Text Source # toEncodedQueryParam :: Float -> Builder Source #
ToHttpApiData Int |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Int -> Text Source # toEncodedUrlPiece :: Int -> Builder Source # toHeader :: Int -> ByteString Source # toQueryParam :: Int -> Text Source # toEncodedQueryParam :: Int -> Builder Source #
ToHttpApiData Word |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Word -> Text Source # toEncodedUrlPiece :: Word -> Builder Source # toHeader :: Word -> ByteString Source # toQueryParam :: Word -> Text Source # toEncodedQueryParam :: Word -> Builder Source #
ToHttpApiData a => ToHttpApiData (First a) |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: First a -> Text Source # toEncodedUrlPiece :: First a -> Builder Source # toHeader :: First a -> ByteString Source # toQueryParam :: First a -> Text Source # toEncodedQueryParam :: First a -> Builder Source #
ToHttpApiData a => ToHttpApiData (Last a) |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Last a -> Text Source # toEncodedUrlPiece :: Last a -> Builder Source # toHeader :: Last a -> ByteString Source # toQueryParam :: Last a -> Text Source # toEncodedQueryParam :: Last a -> Builder Source #
ToHttpApiData a => ToHttpApiData (Max a) |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Max a -> Text Source # toEncodedUrlPiece :: Max a -> Builder Source # toHeader :: Max a -> ByteString Source # toQueryParam :: Max a -> Text Source # toEncodedQueryParam :: Max a -> Builder Source #
ToHttpApiData a => ToHttpApiData (Min a) |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Min a -> Text Source # toEncodedUrlPiece :: Min a -> Builder Source # toHeader :: Min a -> ByteString Source # toQueryParam :: Min a -> Text Source # toEncodedQueryParam :: Min a -> Builder Source #
ToHttpApiData a => ToHttpApiData (Identity a) | Since: http-api-data-0.4.2
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Identity a -> Text Source # toEncodedUrlPiece :: Identity a -> Builder Source # toHeader :: Identity a -> ByteString Source # toQueryParam :: Identity a -> Text Source # toEncodedQueryParam :: Identity a -> Builder Source #
ToHttpApiData a => ToHttpApiData (First a) |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: First a -> Text Source # toEncodedUrlPiece :: First a -> Builder Source # toHeader :: First a -> ByteString Source # toQueryParam :: First a -> Text Source # toEncodedQueryParam :: First a -> Builder Source #
ToHttpApiData a => ToHttpApiData (Last a) |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Last a -> Text Source # toEncodedUrlPiece :: Last a -> Builder Source # toHeader :: Last a -> ByteString Source # toQueryParam :: Last a -> Text Source # toEncodedQueryParam :: Last a -> Builder Source #
ToHttpApiData a => ToHttpApiData (Dual a) |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Dual a -> Text Source # toEncodedUrlPiece :: Dual a -> Builder Source # toHeader :: Dual a -> ByteString Source # toQueryParam :: Dual a -> Text Source # toEncodedQueryParam :: Dual a -> Builder Source #
ToHttpApiData a => ToHttpApiData (Product a) |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Product a -> Text Source # toEncodedUrlPiece :: Product a -> Builder Source # toHeader :: Product a -> ByteString Source # toQueryParam :: Product a -> Text Source # toEncodedQueryParam :: Product a -> Builder Source #
ToHttpApiData a => ToHttpApiData (Sum a) |
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Sum a -> Text Source # toEncodedUrlPiece :: Sum a -> Builder Source # toHeader :: Sum a -> ByteString Source # toQueryParam :: Sum a -> Text Source # toEncodedQueryParam :: Sum a -> Builder Source #

ToHttpApiData a => ToHttpApiData (Maybe a)

    >>> toUrlPiece (Just "Hello")
    "just Hello"

Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Maybe a -> Text Source # toEncodedUrlPiece :: Maybe a -> Builder Source # toHeader :: Maybe a -> ByteString Source # toQueryParam :: Maybe a -> Text Source # toEncodedQueryParam :: Maybe a -> Builder Source #
HasResolution a => ToHttpApiData (Fixed a) | Note: this instance is not polykinded
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Fixed a -> Text Source # toEncodedUrlPiece :: Fixed a -> Builder Source # toHeader :: Fixed a -> ByteString Source # toQueryParam :: Fixed a -> Text Source # toEncodedQueryParam :: Fixed a -> Builder Source #

(ToHttpApiData a, ToHttpApiData b) => ToHttpApiData (Either a b)

    >>> toUrlPiece (Left "err" :: Either String Int)
    "left err"
    >>> toUrlPiece (Right 3 :: Either String Int)
    "right 3"

Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Either a b -> Text Source # toEncodedUrlPiece :: Either a b -> Builder Source # toHeader :: Either a b -> ByteString Source # toQueryParam :: Either a b -> Text Source # toEncodedQueryParam :: Either a b -> Builder Source #
ToHttpApiData (Range min max) Source # |
Instance details Defined in Servant.API.Range Methods toUrlPiece :: Range min max -> Text Source # toEncodedUrlPiece :: Range min max -> Builder Source # toHeader :: Range min max -> ByteString Source # toQueryParam :: Range min max -> Text Source # toEncodedQueryParam :: Range min max -> Builder Source #
ToHttpApiData a => ToHttpApiData (Const a b) | Since: http-api-data-0.4.2
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Const a b -> Text Source # toEncodedUrlPiece :: Const a b -> Builder Source # toHeader :: Const a b -> ByteString Source # toQueryParam :: Const a b -> Text Source # toEncodedQueryParam :: Const a b -> Builder Source #
ToHttpApiData a => ToHttpApiData (Tagged b a) | Note: this instance is not polykinded
Instance details Defined in Web.Internal.HttpApiData Methods toUrlPiece :: Tagged b a -> Text Source # toEncodedUrlPiece :: Tagged b a -> Builder Source # toHeader :: Tagged b a -> ByteString Source # toQueryParam :: Tagged b a -> Text Source # toEncodedQueryParam :: Tagged b a -> Builder Source #

Classes and instances for types that can be converted to and from HTTP API data.

# Experimental modules

module Servant.API.Experimental.Auth

General Authentication

# Links

data URI Source #

Represents a general universal resource identifier using its component parts.

For example, for the URI

      foo://anonymous@www.haskell.org:42/ghc?query#frag

the components are:

Constructors

URI |

Fields

- uriScheme :: String

      foo:

- uriAuthority :: Maybe URIAuth

      //anonymous@www.haskell.org:42

- uriPath :: String

      /ghc

- uriQuery :: String

      ?query

- uriFragment :: String

      #frag

#### Instances

Instances details

FromJSON URI | Since: aeson-2.2.0.0
Instance details Defined in Data.Aeson.Types.FromJSON Methods parseJSON :: Value -> Parser URI Source # parseJSONList :: Value -> Parser [URI] Source # omittedField :: Maybe URI Source #
FromJSONKey URI | Since: aeson-2.2.0.0
Instance details Defined in Data.Aeson.Types.FromJSON Methods fromJSONKey :: FromJSONKeyFunction URI Source # fromJSONKeyList :: FromJSONKeyFunction [URI] Source #
ToJSON URI | Since: aeson-2.2.0.0
Instance details Defined in Data.Aeson.Types.ToJSON Methods toJSON :: URI -> Value Source # toEncoding :: URI -> Encoding Source # toJSONList :: [URI] -> Value Source # toEncodingList :: [URI] -> Encoding Source # omitField :: URI -> Bool Source #
ToJSONKey URI | Since: aeson-2.2.0.0
Instance details Defined in Data.Aeson.Types.ToJSON Methods toJSONKey :: ToJSONKeyFunction URI Source # toJSONKeyList :: ToJSONKeyFunction [URI] Source #
NFData URI |
Instance details Defined in Network.URI Methods rnf :: URI -> () Source #
Data URI |

Instance details

Defined in Network.URI

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> URI -> c URI Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c URI Source #

toConstr :: URI -> Constr Source #

dataTypeOf :: URI -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c URI) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c URI) Source #

gmapT :: (forall b. Data b => b -> b) -> URI -> URI Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> URI -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> URI -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> URI -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> URI -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> URI -> m URI Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> URI -> m URI Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> URI -> m URI Source #

Generic URI |

Instance details

Defined in Network.URI

Associated Types

type Rep URI |

Instance details

Defined in Network.URI

type Rep URI = D1 ('MetaData "URI" "Network.URI" "network-uri-2.6.4.2-BXV0MtFcaF6BxSkElkpvb1" 'False) (C1 ('MetaCons "URI" 'PrefixI 'True) ((S1 ('MetaSel ('Just "uriScheme") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Just "uriAuthority") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe URIAuth))) :*: (S1 ('MetaSel ('Just "uriPath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: (S1 ('MetaSel ('Just "uriQuery") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Just "uriFragment") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)))))

Methods

from :: URI -> Rep URI x Source #

to :: Rep URI x -> URI Source #

Show URI |
Instance details Defined in Network.URI Methods showsPrec :: Int -> URI -> ShowS Source # show :: URI -> String Source # showList :: [URI] -> ShowS Source #
Eq URI |
Instance details Defined in Network.URI Methods (==) :: URI -> URI -> Bool Source # (/=) :: URI -> URI -> Bool Source #
Ord URI |
Instance details Defined in Network.URI Methods compare :: URI -> URI -> Ordering Source # (<) :: URI -> URI -> Bool Source # (<=) :: URI -> URI -> Bool Source # (>) :: URI -> URI -> Bool Source # (>=) :: URI -> URI -> Bool Source # max :: URI -> URI -> URI Source # min :: URI -> URI -> URI Source #
Lift URI |
Instance details Defined in Network.URI Methods lift :: Quote m => URI -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => URI -> Code m URI Source #
type Rep URI |

Instance details

Defined in Network.URI

type Rep URI = D1 ('MetaData "URI" "Network.URI" "network-uri-2.6.4.2-BXV0MtFcaF6BxSkElkpvb1" 'False) (C1 ('MetaCons "URI" 'PrefixI 'True) ((S1 ('MetaSel ('Just "uriScheme") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Just "uriAuthority") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe URIAuth))) :*: (S1 ('MetaSel ('Just "uriPath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: (S1 ('MetaSel ('Just "uriQuery") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Just "uriFragment") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)))))

class HasLink (endpoint :: k) where Source #

Construct a toLink for an endpoint.

Associated Types

type MkLink (endpoint :: k) a Source #

Methods

toLink Source #

Arguments

:: (Link -> a) |
-> Proxy endpoint | The API endpoint you would like to point to
-> Link |
-> MkLink endpoint a |

#### Instances

Instances details

HasLink EmptyAPI Source # |

Instance details

Defined in Servant.Links

Associated Types

type MkLink EmptyAPI a |
Instance details Defined in Servant.Links type MkLink EmptyAPI a = EmptyAPI

Methods

toLink :: (Link -> a) -> Proxy EmptyAPI -> Link -> MkLink EmptyAPI a Source #

HasLink Raw Source # |

Instance details

Defined in Servant.Links

Associated Types

type MkLink Raw a |
Instance details Defined in Servant.Links type MkLink Raw a = a

Methods

toLink :: (Link -> a) -> Proxy Raw -> Link -> MkLink Raw a Source #

HasLink RawM Source # |

Instance details

Defined in Servant.Links

Associated Types

type MkLink RawM a |
Instance details Defined in Servant.Links type MkLink RawM a = a

Methods

toLink :: (Link -> a) -> Proxy RawM -> Link -> MkLink RawM a Source #

(TypeError (NoInstanceFor (HasLink api)) :: Constraint) => HasLink (api :: k) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy api -> Link -> MkLink api a Source #
(HasLink (ToServantApi routes), forall a. GLink routes a, ErrorIfNoGeneric routes) => HasLink (NamedRoutes routes :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (NamedRoutes routes) -> Link -> MkLink (NamedRoutes routes) a Source #
(HasLink a, HasLink b) => HasLink (a :<|> b :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a0) -> Proxy (a :<|> b) -> Link -> MkLink (a :<|> b) a0 Source #
HasLink (NoContentVerb m :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (NoContentVerb m) -> Link -> MkLink (NoContentVerb m) a Source #
(TypeError (PartialApplication (HasLink :: Type -> Constraint) arr) :: Constraint) => HasLink (arr :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a0) -> Proxy (arr :> sub) -> Link -> MkLink (arr :> sub) a0 Source #
(KnownSymbol sym, HasLink sub) => HasLink (sym :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (sym :> sub) -> Link -> MkLink (sym :> sub) a Source #
HasLink sub => HasLink (HttpVersion :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (HttpVersion :> sub) -> Link -> MkLink (HttpVersion :> sub) a Source #
HasLink sub => HasLink (BasicAuth realm a :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a0) -> Proxy (BasicAuth realm a :> sub) -> Link -> MkLink (BasicAuth realm a :> sub) a0 Source #
(ToHttpApiData v, HasLink sub) => HasLink (Capture' mods sym v :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (Capture' mods sym v :> sub) -> Link -> MkLink (Capture' mods sym v :> sub) a Source #
(ToHttpApiData v, HasLink sub) => HasLink (CaptureAll sym v :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (CaptureAll sym v :> sub) -> Link -> MkLink (CaptureAll sym v :> sub) a Source #
HasLink sub => HasLink (Description s :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (Description s :> sub) -> Link -> MkLink (Description s :> sub) a Source #
HasLink sub => HasLink (Summary s :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (Summary s :> sub) -> Link -> MkLink (Summary s :> sub) a Source #
HasLink sub => HasLink (AuthProtect tag :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (AuthProtect tag :> sub) -> Link -> MkLink (AuthProtect tag :> sub) a Source #
(HasLink sub, ToHttpApiData v) => HasLink (Fragment v :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (Fragment v :> sub) -> Link -> MkLink (Fragment v :> sub) a Source #
HasLink sub => HasLink (Header' mods sym a :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a0) -> Proxy (Header' mods sym a :> sub) -> Link -> MkLink (Header' mods sym a :> sub) a0 Source #
HasLink sub => HasLink (IsSecure :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (IsSecure :> sub) -> Link -> MkLink (IsSecure :> sub) a Source #
(KnownSymbol sym, HasLink sub) => HasLink (QueryFlag sym :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (QueryFlag sym :> sub) -> Link -> MkLink (QueryFlag sym :> sub) a Source #
(KnownSymbol sym, ToHttpApiData v, HasLink sub, SBoolI (FoldRequired mods)) => HasLink (QueryParam' mods sym v :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (QueryParam' mods sym v :> sub) -> Link -> MkLink (QueryParam' mods sym v :> sub) a Source #
(KnownSymbol sym, ToHttpApiData v, HasLink sub) => HasLink (QueryParams sym v :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (QueryParams sym v :> sub) -> Link -> MkLink (QueryParams sym v :> sub) a Source #
(KnownSymbol sym, ToDeepQuery record, HasLink sub) => HasLink (DeepQuery sym record :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (DeepQuery sym record :> sub) -> Link -> MkLink (DeepQuery sym record :> sub) a Source #
HasLink sub => HasLink (RemoteHost :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (RemoteHost :> sub) -> Link -> MkLink (RemoteHost :> sub) a Source #
HasLink sub => HasLink (ReqBody' mods ct a :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a0) -> Proxy (ReqBody' mods ct a :> sub) -> Link -> MkLink (ReqBody' mods ct a :> sub) a0 Source #
HasLink sub => HasLink (StreamBody' mods framing ct a :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a0) -> Proxy (StreamBody' mods framing ct a :> sub) -> Link -> MkLink (StreamBody' mods framing ct a :> sub) a0 Source #
HasLink sub => HasLink (WithResource res :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (WithResource res :> sub) -> Link -> MkLink (WithResource res :> sub) a Source #
HasLink sub => HasLink (Vault :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (Vault :> sub) -> Link -> MkLink (Vault :> sub) a Source #
(TypeError (NoInstanceForSub (HasLink :: Type -> Constraint) ty) :: Constraint) => HasLink (ty :> sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (ty :> sub) -> Link -> MkLink (ty :> sub) a Source #
HasLink (UVerb m ct a :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a0) -> Proxy (UVerb m ct a) -> Link -> MkLink (UVerb m ct a) a0 Source #
HasLink sub => HasLink (WithNamedContext name context sub :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (WithNamedContext name context sub) -> Link -> MkLink (WithNamedContext name context sub) a Source #
HasLink (MultiVerb method cs as r :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a) -> Proxy (MultiVerb method cs as r) -> Link -> MkLink (MultiVerb method cs as r) a Source #
HasLink (Verb m s ct a :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a0) -> Proxy (Verb m s ct a) -> Link -> MkLink (Verb m s ct a) a0 Source #
HasLink (Stream m status fr ct a :: Type) Source # |
Instance details Defined in Servant.Links Methods toLink :: (Link -> a0) -> Proxy (Stream m status fr ct a) -> Link -> MkLink (Stream m status fr ct a) a0 Source #

type family IsElem endpoint api where ... Source #

Closed type family, check if `endpoint` is within `api`. Uses ``IsElem'`` if it exhausts all other options.

    >>> ok (Proxy :: Proxy (IsElem ("hello" :> Get '[JSON] Int) SampleAPI))
    OK

    >>> ok (Proxy :: Proxy (IsElem ("bye" :> Get '[JSON] Int) SampleAPI))
    ...
    ... Could not ...
    ...

An endpoint is considered within an api even if it is missing combinators that don't affect the URL:

    >>> ok (Proxy :: Proxy (IsElem (Get '[JSON] Int) (Header "h" Bool :> Get '[JSON] Int)))
    OK

    >>> ok (Proxy :: Proxy (IsElem (Get '[JSON] Int) (ReqBody '[JSON] Bool :> Get '[JSON] Int)))
    OK

- N.B.:* `IsElem a b` can be seen as capturing the notion of whether the URL represented by `a` would match the URL represented by `b`, *not* whether a request represented by `a` matches the endpoints serving `b` (for the latter, use `IsIn`).

Equations

IsElem e (sa :<|> sb) = Or (IsElem e sa) (IsElem e sb) |
IsElem (e :> sa) (e :> sb) = IsElem sa sb |
IsElem sa (Header sym x :> sb) = IsElem sa sb |
IsElem sa (Header' mods sym x :> sb) = IsElem sa sb |
IsElem sa (ReqBody y x :> sb) = IsElem sa sb |
IsElem (CaptureAll z y :> sa) (CaptureAll x y :> sb) = IsElem sa sb |
IsElem (Capture z y :> sa) (Capture x y :> sb) = IsElem sa sb |
IsElem sa (QueryParam x y :> sb) = IsElem sa sb |
IsElem sa (QueryParams x y :> sb) = IsElem sa sb |
IsElem sa (QueryFlag x :> sb) = IsElem sa sb |
IsElem sa (Fragment x :> sb) = IsElem sa sb |
IsElem (Verb m s ct typ) (Verb m s ct' typ) = IsSubList ct ct' |
IsElem e e = () |
IsElem e (NamedRoutes rs) = IsElem e (ToServantApi rs) |
IsElem e a = IsElem' e a |

type family IsElem' a s Source #

You may use this type family to tell the type checker that your custom type may be skipped as part of a link. This is useful for things like ``QueryParam`` that are optional in a URI and do not affect them if they are omitted.

    >>> data CustomThing
    >>> type instance IsElem' e (CustomThing :> s) = IsElem e s

Note that ``IsElem`` is called, which will mutually recurse back to ``IsElem'`` if it exhausts all other options again.

Once you have written a `HasLink` instance for `CustomThing` you are ready to go.

data Link Source #

A safe link datatype. The only way of constructing a `Link` is using `safeLink`, which means any `Link` is guaranteed to be part of the mentioned API.

NOTE: If you are writing a custom `HasLink` instance, and need to manipulate the `Link` (adding query params or fragments, perhaps), please use the the `addQueryParam` and `addSegment` functions.

#### Instances

Instances details

Show Link Source # |
Instance details Defined in Servant.Links Methods showsPrec :: Int -> Link -> ShowS Source # show :: Link -> String Source # showList :: [Link] -> ShowS Source #
ToHttpApiData Link Source # |
Instance details Defined in Servant.Links Methods toUrlPiece :: Link -> Text Source # toEncodedUrlPiece :: Link -> Builder Source # toHeader :: Link -> ByteString Source # toQueryParam :: Link -> Text Source # toEncodedQueryParam :: Link -> Builder Source #

safeLink Source #

Arguments

:: (IsElem endpoint api, HasLink endpoint) |
=> Proxy api | The whole API that this endpoint is a part of
-> Proxy endpoint | The API endpoint you would like to point to
-> MkLink endpoint Link |

Create a valid (by construction) relative URI with query params.

This function will only typecheck if `endpoint` is part of the API `api`

type family MkLink (endpoint :: k) a Source #

#### Instances

Instances details

type MkLink EmptyAPI a Source # |
Instance details Defined in Servant.Links type MkLink EmptyAPI a = EmptyAPI
type MkLink Raw a Source # |
Instance details Defined in Servant.Links type MkLink Raw a = a
type MkLink RawM a Source # |
Instance details Defined in Servant.Links type MkLink RawM a = a
type MkLink (NamedRoutes routes :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (NamedRoutes routes :: Type) a = routes (AsLink a)
type MkLink (a :<|> b :: Type) r Source # |
Instance details Defined in Servant.Links type MkLink (a :<|> b :: Type) r = MkLink a r :<|> MkLink b r
type MkLink (NoContentVerb m :: Type) r Source # |
Instance details Defined in Servant.Links type MkLink (NoContentVerb m :: Type) r = r
type MkLink (arr :> sub :: Type) _1 Source # |
Instance details Defined in Servant.Links type MkLink (arr :> sub :: Type) _1 = TypeError (PartialApplication (HasLink :: Type -> Constraint) arr) :: Type
type MkLink (sym :> sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (sym :> sub :: Type) a = MkLink sub a
type MkLink (HttpVersion :> sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (HttpVersion :> sub :: Type) a = MkLink sub a
type MkLink (BasicAuth realm a :> sub :: Type) r Source # |
Instance details Defined in Servant.Links type MkLink (BasicAuth realm a :> sub :: Type) r = MkLink sub r
type MkLink (Capture' mods sym v :> sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (Capture' mods sym v :> sub :: Type) a = v -> MkLink sub a
type MkLink (CaptureAll sym v :> sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (CaptureAll sym v :> sub :: Type) a = [v] -> MkLink sub a
type MkLink (Description s :> sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (Description s :> sub :: Type) a = MkLink sub a
type MkLink (Summary s :> sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (Summary s :> sub :: Type) a = MkLink sub a
type MkLink (AuthProtect tag :> sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (AuthProtect tag :> sub :: Type) a = MkLink sub a
type MkLink (Fragment v :> sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (Fragment v :> sub :: Type) a = v -> MkLink sub a
type MkLink (Header' mods sym a :> sub :: Type) r Source # |
Instance details Defined in Servant.Links type MkLink (Header' mods sym a :> sub :: Type) r = MkLink sub r
type MkLink (IsSecure :> sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (IsSecure :> sub :: Type) a = MkLink sub a
type MkLink (QueryFlag sym :> sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (QueryFlag sym :> sub :: Type) a = Bool -> MkLink sub a
type MkLink (QueryParam' mods sym v :> sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (QueryParam' mods sym v :> sub :: Type) a = If (FoldRequired mods) v (Maybe v) -> MkLink sub a
type MkLink (QueryParams sym v :> sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (QueryParams sym v :> sub :: Type) a = [v] -> MkLink sub a
type MkLink (DeepQuery sym record :> sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (DeepQuery sym record :> sub :: Type) a = record -> MkLink sub a
type MkLink (RemoteHost :> sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (RemoteHost :> sub :: Type) a = MkLink sub a
type MkLink (ReqBody' mods ct a :> sub :: Type) r Source # |
Instance details Defined in Servant.Links type MkLink (ReqBody' mods ct a :> sub :: Type) r = MkLink sub r
type MkLink (StreamBody' mods framing ct a :> sub :: Type) r Source # |
Instance details Defined in Servant.Links type MkLink (StreamBody' mods framing ct a :> sub :: Type) r = MkLink sub r
type MkLink (WithResource res :> sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (WithResource res :> sub :: Type) a = MkLink sub a
type MkLink (Vault :> sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (Vault :> sub :: Type) a = MkLink sub a
type MkLink (UVerb m ct a :: Type) r Source # |
Instance details Defined in Servant.Links type MkLink (UVerb m ct a :: Type) r = r
type MkLink (WithNamedContext name context sub :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (WithNamedContext name context sub :: Type) a = MkLink sub a
type MkLink (MultiVerb method cs as r :: Type) a Source # |
Instance details Defined in Servant.Links type MkLink (MultiVerb method cs as r :: Type) a = a
type MkLink (Verb m s ct a :: Type) r Source # |
Instance details Defined in Servant.Links type MkLink (Verb m s ct a :: Type) r = r
type MkLink (Stream m status fr ct a :: Type) r Source # |
Instance details Defined in Servant.Links type MkLink (Stream m status fr ct a :: Type) r = r

Type-safe internal URIs

# Re-exports

type family If (cond :: Bool) (tru :: k) (fls :: k) :: k where ... Source #

Type-level If. `If True a b` ==> `a`; `If False a b` ==> `b`

Equations

If 'True (tru :: k) (fls :: k) = tru |
If 'False (tru :: k) (fls :: k) = fls |

data SBool (b :: Bool) where Source #

Constructors

STrue :: SBool 'True |
SFalse :: SBool 'False |

#### Instances

Instances details

EqP SBool | Since: singleton-bool-0.1.7
Instance details Defined in Data.Singletons.Bool Methods eqp :: forall (a :: Bool) (b :: Bool). SBool a -> SBool b -> Bool
GNFData SBool | Since: singleton-bool-0.1.6
Instance details Defined in Data.Singletons.Bool Methods grnf :: forall (a :: Bool). SBool a -> ()
GCompare SBool | Since: singleton-bool-0.1.6
Instance details Defined in Data.Singletons.Bool Methods gcompare :: forall (a :: Bool) (b :: Bool). SBool a -> SBool b -> GOrdering a b

GEq SBool

    >>> geq STrue STrue
    Just Refl

    >>> geq STrue SFalse
    Nothing

Since: singleton-bool-0.1.6

Instance details Defined in Data.Singletons.Bool Methods geq :: forall (a :: Bool) (b :: Bool). SBool a -> SBool b -> Maybe (a :~: b)

GRead SBool

    >>> readsPrec 0 "Some STrue" :: [(Some SBool, String)]
    [(Some STrue,"")]

    >>> readsPrec 0 "Some SFalse" :: [(Some SBool, String)]
    [(Some SFalse,"")]

    >>> readsPrec 0 "Some Else" :: [(Some SBool, String)]
    []

Since: singleton-bool-0.1.6

Instance details Defined in Data.Singletons.Bool Methods greadsPrec :: Int -> GReadS SBool

GShow SBool

    >>> showsPrec 0 STrue ""
    "STrue"

Since: singleton-bool-0.1.6

Instance details Defined in Data.Singletons.Bool Methods gshowsPrec :: forall (a :: Bool). Int -> SBool a -> ShowS
OrdP SBool | Since: singleton-bool-0.1.7
Instance details Defined in Data.Singletons.Bool Methods comparep :: forall (a :: Bool) (b :: Bool). SBool a -> SBool b -> Ordering
SBoolI b => Boring (SBool b) | Since: singleton-bool-0.1.6
Instance details Defined in Data.Singletons.Bool Methods boring :: SBool b
NFData (SBool b) | Since: singleton-bool-0.1.6
Instance details Defined in Data.Singletons.Bool Methods rnf :: SBool b -> () Source #
Show (SBool b) | Since: singleton-bool-0.1.5
Instance details Defined in Data.Singletons.Bool Methods showsPrec :: Int -> SBool b -> ShowS Source # show :: SBool b -> String Source # showList :: [SBool b] -> ShowS Source #
Eq (SBool b) | Since: singleton-bool-0.1.5
Instance details Defined in Data.Singletons.Bool Methods (==) :: SBool b -> SBool b -> Bool Source # (/=) :: SBool b -> SBool b -> Bool Source #
Ord (SBool b) | Since: singleton-bool-0.1.5
Instance details Defined in Data.Singletons.Bool Methods compare :: SBool b -> SBool b -> Ordering Source # (<) :: SBool b -> SBool b -> Bool Source # (<=) :: SBool b -> SBool b -> Bool Source # (>) :: SBool b -> SBool b -> Bool Source # (>=) :: SBool b -> SBool b -> Bool Source # max :: SBool b -> SBool b -> SBool b Source # min :: SBool b -> SBool b -> SBool b Source #

class SBoolI (b :: Bool) where Source #

Methods

sbool :: SBool b Source #

#### Instances

Instances details

SBoolI 'False |
Instance details Defined in Data.Singletons.Bool Methods sbool :: SBool 'False Source #
SBoolI 'True |
Instance details Defined in Data.Singletons.Bool Methods sbool :: SBool 'True Source #