servant-server-0.20.3.0: A family of combinators for defining webservices APIs and serving them

Safe Haskell | None
Language | Haskell2010

Servant.Server

Contents

- Run a wai application from an API
- Construct a wai Application from an API
- Handlers for all standard combinators
- Debugging the server layout
- Enter / hoisting server
  - Functions based on mmorph
- Context
  - NamedContext
- Basic Authentication
- General Authentication
- Default error type
  - 3XX
  - 4XX
  - 5XX
- Formatting of errors from combinators
- Re-exports

Description

This module lets you implement `Server`s for defined APIs. You'll most likely just need `serve`.

Synopsis

- serve :: forall {k} (api :: k). HasServer api ('[] :: [Type]) => Proxy api -> Server api -> Application
- serveWithContext :: forall {k} (api :: k) (context :: [Type]). (HasServer api context, ServerContext context) => Proxy api -> Context context -> Server api -> Application
- serveWithContextT :: forall {k} (api :: k) (context :: [Type]) m. (HasServer api context, ServerContext context) => Proxy api -> Context context -> (forall x. m x -> Handler x) -> ServerT api m -> Application
- type ServerContext (context :: [Type]) = HasContextEntry (context .++ DefaultErrorFormatters) ErrorFormatters
- toApplication :: RoutingApplication -> Application
- class HasServer (api :: k) (context :: [Type]) where
  - type ServerT (api :: k) (m :: Type -> Type)
  - route :: Proxy api -> Context context -> Delayed env (Server api) -> Router env
  - hoistServerWithContext :: Proxy api -> Proxy context -> (forall x. m x -> n x) -> ServerT api m -> ServerT api n
- type Server (api :: k) = ServerT api Handler
- data EmptyServer
- emptyServer :: forall (m :: Type -> Type). ServerT EmptyAPI m
- newtype Handler a = Handler {
  - runHandler' :: ExceptT ServerError IO a
  }
- runHandler :: Handler a -> IO (Either ServerError a)
- pattern MkHandler :: IO (Either ServerError a) -> Handler a
- layout :: forall {k} (api :: k). HasServer api ('[] :: [Type]) => Proxy api -> Text
- layoutWithContext :: forall {k} (api :: k) (context :: [Type]). HasServer api context => Proxy api -> Context context -> Text
- hoistServer :: forall {k} (api :: k) m n. HasServer api ('[] :: [Type]) => Proxy api -> (forall x. m x -> n x) -> ServerT api m -> ServerT api n
- tweakResponse :: (RouteResult Response -> RouteResult Response) -> Router env -> Router env
- data Context (contextTypes :: [Type]) where
  - EmptyContext :: Context ('[] :: [Type])
  - (:.) :: forall x (xs :: [Type]). x -> Context xs -> Context (x ': xs)
- class HasContextEntry (context :: [Type]) val where
  - getContextEntry :: Context context -> val
- type family (l1 :: [Type]) .++ (l2 :: [Type]) :: [Type] where ...
- (.++) :: forall (l1 :: [Type]) (l2 :: [Type]). Context l1 -> Context l2 -> Context (l1 .++ l2)
- newtype NamedContext (name :: Symbol) (subContext :: [Type]) = NamedContext (Context subContext)
- descendIntoNamedContext :: forall (context :: [Type]) (name :: Symbol) (subContext :: [Type]). HasContextEntry context (NamedContext name subContext) => Proxy name -> Context context -> Context subContext
- newtype BasicAuthCheck usr = BasicAuthCheck {
  - unBasicAuthCheck :: BasicAuthData -> IO (BasicAuthResult usr)
  }
- data BasicAuthResult usr
  - = Unauthorized
  - | BadPassword
  - | NoSuchUser
  - | Authorized usr
- data ServerError = ServerError {
  - errHTTPCode :: Int
  - errReasonPhrase :: String
  - errBody :: ByteString
  - errHeaders :: [Header]
  }
- err300 :: ServerError
- err301 :: ServerError
- err302 :: ServerError
- err303 :: ServerError
- err304 :: ServerError
- err305 :: ServerError
- err307 :: ServerError
- err400 :: ServerError
- err401 :: ServerError
- err402 :: ServerError
- err403 :: ServerError
- err404 :: ServerError
- err405 :: ServerError
- err406 :: ServerError
- err407 :: ServerError
- err409 :: ServerError
- err410 :: ServerError
- err411 :: ServerError
- err412 :: ServerError
- err413 :: ServerError
- err414 :: ServerError
- err415 :: ServerError
- err416 :: ServerError
- err417 :: ServerError
- err418 :: ServerError
- err422 :: ServerError
- err429 :: ServerError
- err500 :: ServerError
- err501 :: ServerError
- err502 :: ServerError
- err503 :: ServerError
- err504 :: ServerError
- err505 :: ServerError
- type ErrorFormatter = TypeRep -> Request -> String -> ServerError
- type NotFoundErrorFormatter = Request -> ServerError
- data ErrorFormatters
- bodyParserErrorFormatter :: ErrorFormatters -> ErrorFormatter
- urlParseErrorFormatter :: ErrorFormatters -> ErrorFormatter
- headerParseErrorFormatter :: ErrorFormatters -> ErrorFormatter
- notFoundErrorFormatter :: ErrorFormatters -> NotFoundErrorFormatter
- type DefaultErrorFormatters = '[ErrorFormatters]
- defaultErrorFormatters :: ErrorFormatters
- getAcceptHeader :: Request -> AcceptHeader
- type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived
- newtype Tagged (s :: k) b = Tagged {
  - unTagged :: b
  }
- module Servant.Server.UVerb

# Run a wai application from an API

serve :: forall {k} (api :: k). HasServer api ('[] :: [Type]) => Proxy api -> Server api -> Application Source #

`serve` allows you to implement an API and produce a wai `Application`.

Example:

    type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
            :<|> "books" :> ReqBody '[JSON] Book :> Post '[JSON] Book -- POST /books

    server :: Server MyApi
    server = listAllBooks :<|> postBook
      where listAllBooks = ...
            postBook book = ...

    myApi :: Proxy MyApi
    myApi = Proxy

    app :: Application
    app = serve myApi server

    main :: IO ()
    main = Network.Wai.Handler.Warp.run 8080 app

serveWithContext :: forall {k} (api :: k) (context :: [Type]). (HasServer api context, ServerContext context) => Proxy api -> Context context -> Server api -> Application Source #

Like `serve`, but allows you to pass custom context.

`defaultErrorFormatters` will always be appended to the end of the passed context, but if you pass your own formatter, it will override the default one.

serveWithContextT :: forall {k} (api :: k) (context :: [Type]) m. (HasServer api context, ServerContext context) => Proxy api -> Context context -> (forall x. m x -> Handler x) -> ServerT api m -> Application Source #

A general `serve` function that allows you to pass a custom context and hoisting function to apply on all routes.

type ServerContext (context :: [Type]) = HasContextEntry (context .++ DefaultErrorFormatters) ErrorFormatters Source #

Constraints that need to be satisfied on a context for it to be passed to `serveWithContext`.

Typically, this will add default context entries to the context. You shouldn't typically need to worry about these constraints, but if you write a helper function that wraps `serveWithContext`, you might need to include this constraint.

# Construct a wai Application from an API

toApplication :: RoutingApplication -> Application Source #

# Handlers for all standard combinators

class HasServer (api :: k) (context :: [Type]) where Source #

Associated Types

type ServerT (api :: k) (m :: Type -> Type) Source #

The type of a server for this API, given a monad to run effects in.

Note that the result kind is `*`, so it is not a monad transformer, unlike what the `T` in the name might suggest.

Methods

route :: Proxy api -> Context context -> Delayed env (Server api) -> Router env Source #

hoistServerWithContext :: Proxy api -> Proxy context -> (forall x. m x -> n x) -> ServerT api m -> ServerT api n Source #

#### Instances

Instances details

HasServer EmptyAPI context Source #

The server for an `EmptyAPI` is `emptyServer`.

    type MyApi = "nothing" :> EmptyApi

    server :: Server MyApi
    server = emptyServer

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT EmptyAPI m |
Instance details Defined in Servant.Server.Internal type ServerT EmptyAPI m = Tagged m EmptyServer

Methods

route :: Proxy EmptyAPI -> Context context -> Delayed env (Server EmptyAPI) -> Router env Source #

hoistServerWithContext :: Proxy EmptyAPI -> Proxy context -> (forall x. m x -> n x) -> ServerT EmptyAPI m -> ServerT EmptyAPI n Source #

HasServer Raw context Source #

Just pass the request to the underlying application and serve its response.

Example:

    type MyApi = "images" :> Raw

    server :: Server MyApi
    server = serveDirectory "/var/www/images"

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT Raw m |
Instance details Defined in Servant.Server.Internal type ServerT Raw m = Tagged m Application

Methods

route :: Proxy Raw -> Context context -> Delayed env (Server Raw) -> Router env Source #

hoistServerWithContext :: Proxy Raw -> Proxy context -> (forall x. m x -> n x) -> ServerT Raw m -> ServerT Raw n Source #

HasServer RawM context Source #

Just pass the request to the underlying application and serve its response.

Example:

    type MyApi = "images" :> Raw

    server :: Server MyApi
    server = serveDirectory "/var/www/images"

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT RawM m |
Instance details Defined in Servant.Server.Internal type ServerT RawM m = Request -> (Response -> IO ResponseReceived) -> m ResponseReceived

Methods

route :: Proxy RawM -> Context context -> Delayed env (Server RawM) -> Router env Source #

hoistServerWithContext :: Proxy RawM -> Proxy context -> (forall x. m x -> n x) -> ServerT RawM m -> ServerT RawM n Source #

(TypeError (NoInstanceFor (HasServer api context)) :: Constraint) => HasServer (api :: k) context Source # |
Instance details Defined in Servant.Server.Internal Methods route :: Proxy api -> Context context -> Delayed env (Server api) -> Router env Source # hoistServerWithContext :: Proxy api -> Proxy context -> (forall x. m x -> n x) -> ServerT api m -> ServerT api n Source #
(HasServer (ToServantApi api) context, forall (m :: Type -> Type). Generic (api (AsServerT m)), forall (m :: Type -> Type). GServer api m, ErrorIfNoGeneric api) => HasServer (NamedRoutes api :: Type) context Source # |
Instance details Defined in Servant.Server.Internal Methods route :: Proxy (NamedRoutes api) -> Context context -> Delayed env (Server (NamedRoutes api)) -> Router env Source # hoistServerWithContext :: Proxy (NamedRoutes api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (NamedRoutes api) m -> ServerT (NamedRoutes api) n Source #

(HasServer a context, HasServer b context) => HasServer (a :<|> b :: Type) context Source #

A server for `a `:<|>` b` first tries to match the request against the route represented by `a` and if it fails tries `b`. You must provide a request handler for each route.

    type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
            :<|> "books" :> ReqBody Book :> Post '[JSON] Book -- POST /books

    server :: Server MyApi
    server = listAllBooks :<|> postBook
      where listAllBooks = ...
            postBook book = ...

Instance details Defined in Servant.Server.Internal Methods route :: Proxy (a :<|> b) -> Context context -> Delayed env (Server (a :<|> b)) -> Router env Source # hoistServerWithContext :: Proxy (a :<|> b) -> Proxy context -> (forall x. m x -> n x) -> ServerT (a :<|> b) m -> ServerT (a :<|> b) n Source #
ReflectMethod method => HasServer (NoContentVerb method :: Type) context Source # |
Instance details Defined in Servant.Server.Internal Methods route :: Proxy (NoContentVerb method) -> Context context -> Delayed env (Server (NoContentVerb method)) -> Router env Source # hoistServerWithContext :: Proxy (NoContentVerb method) -> Proxy context -> (forall x. m x -> n x) -> ServerT (NoContentVerb method) m -> ServerT (NoContentVerb method) n Source #

(TypeError (HasServerArrowTypeError a b) :: Constraint) => HasServer (a -> b :: Type) context Source #

This instance prevents from accidentally using `->` instead of `:>`

    >>> serve (Proxy :: Proxy (Capture "foo" Int -> Get '[JSON] Int)) (error "...")
    ...
    ...No instance HasServer (a -> b).
    ...Maybe you have used '->' instead of ':>' between
    ...Capture' '[] "foo" Int
    ...and
    ...Verb 'GET 200 '[JSON] Int
    ...

    >>> undefined :: Server (Capture "foo" Int -> Get '[JSON] Int)
    ...
    ...No instance HasServer (a -> b).
    ...Maybe you have used '->' instead of ':>' between
    ...Capture' '[] "foo" Int
    ...and
    ...Verb 'GET 200 '[JSON] Int
    ...

Instance details Defined in Servant.Server.Internal Methods route :: Proxy (a -> b) -> Context context -> Delayed env (Server (a -> b)) -> Router env Source # hoistServerWithContext :: Proxy (a -> b) -> Proxy context -> (forall x. m x -> n x) -> ServerT (a -> b) m -> ServerT (a -> b) n Source #
(TypeError (PartialApplication (HasServer :: Type -> [Type] -> Constraint) arr) :: Constraint) => HasServer (arr :> sub :: Type) context Source # |
Instance details Defined in Servant.Server.Internal Methods route :: Proxy (arr :> sub) -> Context context -> Delayed env (Server (arr :> sub)) -> Router env Source # hoistServerWithContext :: Proxy (arr :> sub) -> Proxy context -> (forall x. m x -> n x) -> ServerT (arr :> sub) m -> ServerT (arr :> sub) n Source #
(KnownSymbol path, HasServer api context) => HasServer (path :> api :: Type) context Source # | Make sure the incoming request starts with `"/path"`, strip it and pass the rest of the request path to `api`.
Instance details Defined in Servant.Server.Internal Methods route :: Proxy (path :> api) -> Context context -> Delayed env (Server (path :> api)) -> Router env Source # hoistServerWithContext :: Proxy (path :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (path :> api) m -> ServerT (path :> api) n Source #
HasServer api context => HasServer (HttpVersion :> api :: Type) context Source # |
Instance details Defined in Servant.Server.Internal Methods route :: Proxy (HttpVersion :> api) -> Context context -> Delayed env (Server (HttpVersion :> api)) -> Router env Source # hoistServerWithContext :: Proxy (HttpVersion :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (HttpVersion :> api) m -> ServerT (HttpVersion :> api) n Source #
(KnownSymbol realm, HasServer api context, HasContextEntry context (BasicAuthCheck usr)) => HasServer (BasicAuth realm usr :> api :: Type) context Source # | Basic Authentication
Instance details Defined in Servant.Server.Internal Methods route :: Proxy (BasicAuth realm usr :> api) -> Context context -> Delayed env (Server (BasicAuth realm usr :> api)) -> Router env Source # hoistServerWithContext :: Proxy (BasicAuth realm usr :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (BasicAuth realm usr :> api) m -> ServerT (BasicAuth realm usr :> api) n Source #

(KnownSymbol capture, FromHttpApiData a, Typeable a, HasServer api context, SBoolI (FoldLenient mods), HasContextEntry (MkContextWithErrorFormatter context) ErrorFormatters) => HasServer (Capture' mods capture a :> api :: Type) context Source #

If you use `Capture` in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of the type specified by the `Capture`. This lets servant worry about getting it from the URL and turning it into a value of the type you specify.

You can control how it'll be converted from `Text` to your type by simply providing an instance of `FromHttpApiData` for your type.

Example:

    type MyApi = "books" :> Capture "isbn" Text :> Get '[JSON] Book

    server :: Server MyApi
    server = getBook
      where getBook :: Text -> Handler Book
            getBook isbn = ...

Instance details

Defined in Servant.Server.Internal

Methods

route :: Proxy (Capture' mods capture a :> api) -> Context context -> Delayed env (Server (Capture' mods capture a :> api)) -> Router env Source #

hoistServerWithContext :: Proxy (Capture' mods capture a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Capture' mods capture a :> api) m -> ServerT (Capture' mods capture a :> api) n Source #

(KnownSymbol capture, FromHttpApiData a, Typeable a, HasServer api context, HasContextEntry (MkContextWithErrorFormatter context) ErrorFormatters) => HasServer (CaptureAll capture a :> api :: Type) context Source #

If you use `CaptureAll` in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of a list of the type specified by the `CaptureAll`. This lets servant worry about getting values from the URL and turning them into values of the type you specify.

You can control how they'll be converted from `Text` to your type by simply providing an instance of `FromHttpApiData` for your type.

Example:

    type MyApi = "src" :> CaptureAll "segments" Text :> Get '[JSON] SourceFile

    server :: Server MyApi
    server = getSourceFile
      where getSourceFile :: [Text] -> Handler Book
            getSourceFile pathSegments = ...

Instance details Defined in Servant.Server.Internal Methods route :: Proxy (CaptureAll capture a :> api) -> Context context -> Delayed env (Server (CaptureAll capture a :> api)) -> Router env Source # hoistServerWithContext :: Proxy (CaptureAll capture a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (CaptureAll capture a :> api) m -> ServerT (CaptureAll capture a :> api) n Source #
HasServer api ctx => HasServer (Description desc :> api :: Type) ctx Source # | Ignore ``Description`` in server handlers.
Instance details Defined in Servant.Server.Internal Methods route :: Proxy (Description desc :> api) -> Context ctx -> Delayed env (Server (Description desc :> api)) -> Router env Source # hoistServerWithContext :: Proxy (Description desc :> api) -> Proxy ctx -> (forall x. m x -> n x) -> ServerT (Description desc :> api) m -> ServerT (Description desc :> api) n Source #
HasServer api ctx => HasServer (Summary desc :> api :: Type) ctx Source # | Ignore ``Summary`` in server handlers.
Instance details Defined in Servant.Server.Internal Methods route :: Proxy (Summary desc :> api) -> Context ctx -> Delayed env (Server (Summary desc :> api)) -> Router env Source # hoistServerWithContext :: Proxy (Summary desc :> api) -> Proxy ctx -> (forall x. m x -> n x) -> ServerT (Summary desc :> api) m -> ServerT (Summary desc :> api) n Source #
HasServer api context => HasServer (EmptyAPI :> api :: Type) context Source # | Ignore ``EmptyAPI`` as part of route in server handlers.
Instance details Defined in Servant.Server.Internal Methods route :: Proxy (EmptyAPI :> api) -> Context context -> Delayed env (Server (EmptyAPI :> api)) -> Router env Source # hoistServerWithContext :: Proxy (EmptyAPI :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (EmptyAPI :> api) m -> ServerT (EmptyAPI :> api) n Source #
(HasServer api context, HasContextEntry context (AuthHandler Request (AuthServerData (AuthProtect tag)))) => HasServer (AuthProtect tag :> api :: Type) context Source # | Known orphan instance.
Instance details Defined in Servant.Server.Experimental.Auth Methods route :: Proxy (AuthProtect tag :> api) -> Context context -> Delayed env (Server (AuthProtect tag :> api)) -> Router env Source # hoistServerWithContext :: Proxy (AuthProtect tag :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (AuthProtect tag :> api) m -> ServerT (AuthProtect tag :> api) n Source #

(AtMostOneFragment api, FragmentUnique (Fragment a1 :> api), HasServer api context) => HasServer (Fragment a1 :> api :: Type) context Source #

Ignore ``Fragment`` in server handlers. See https://ietf.org/rfc/rfc2616.html#section-15.1.3 for more details.

Example:

    type MyApi = "books" :> Fragment Text :> Get '[JSON] [Book]

    server :: Server MyApi
    server = getBooks
      where getBooks :: Handler [Book]
            getBooks = ...return all books...

Instance details Defined in Servant.Server.Internal Methods route :: Proxy (Fragment a1 :> api) -> Context context -> Delayed env (Server (Fragment a1 :> api)) -> Router env Source # hoistServerWithContext :: Proxy (Fragment a1 :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Fragment a1 :> api) m -> ServerT (Fragment a1 :> api) n Source #

(KnownSymbol sym, FromHttpApiData a, HasServer api context, SBoolI (FoldRequired mods), SBoolI (FoldLenient mods), HasContextEntry (MkContextWithErrorFormatter context) ErrorFormatters) => HasServer (Header' mods sym a :> api :: Type) context Source #

If you use `Header` in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of the type specified by `Header`. This lets servant worry about extracting it from the request and turning it into a value of the type you specify.

All it asks is for a `FromHttpApiData` instance.

Example:

    newtype Referer = Referer Text
      deriving (Eq, Show, FromHttpApiData)

               -- GET /view-my-referer
    type MyApi = "view-my-referer" :> Header "Referer" Referer :> Get '[JSON] Referer

    server :: Server MyApi
    server = viewReferer
      where viewReferer :: Referer -> Handler referer
            viewReferer referer = return referer

Instance details Defined in Servant.Server.Internal Methods route :: Proxy (Header' mods sym a :> api) -> Context context -> Delayed env (Server (Header' mods sym a :> api)) -> Router env Source # hoistServerWithContext :: Proxy (Header' mods sym a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Header' mods sym a :> api) m -> ServerT (Header' mods sym a :> api) n Source #
(KnownSymbol sym, HasServer api context, HasContextEntry (MkContextWithErrorFormatter context) ErrorFormatters) => HasServer (Host sym :> api :: Type) context Source # |
Instance details Defined in Servant.Server.Internal Methods route :: Proxy (Host sym :> api) -> Context context -> Delayed env (Server (Host sym :> api)) -> Router env Source # hoistServerWithContext :: Proxy (Host sym :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Host sym :> api) m -> ServerT (Host sym :> api) n Source #
HasServer api context => HasServer (IsSecure :> api :: Type) context Source # |
Instance details Defined in Servant.Server.Internal Methods route :: Proxy (IsSecure :> api) -> Context context -> Delayed env (Server (IsSecure :> api)) -> Router env Source # hoistServerWithContext :: Proxy (IsSecure :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (IsSecure :> api) m -> ServerT (IsSecure :> api) n Source #

(KnownSymbol sym, HasServer api context) => HasServer (QueryFlag sym :> api :: Type) context Source #

If you use ``QueryFlag` "published"` in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of type `Bool`.

Example:

    type MyApi = "books" :> QueryFlag "published" :> Get '[JSON] [Book]

    server :: Server MyApi
    server = getBooks
      where getBooks :: Bool -> Handler [Book]
            getBooks onlyPublished = ...return all books, or only the ones that are already published, depending on the argument...

Instance details Defined in Servant.Server.Internal Methods route :: Proxy (QueryFlag sym :> api) -> Context context -> Delayed env (Server (QueryFlag sym :> api)) -> Router env Source # hoistServerWithContext :: Proxy (QueryFlag sym :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (QueryFlag sym :> api) m -> ServerT (QueryFlag sym :> api) n Source #

(KnownSymbol sym, FromHttpApiData a, HasServer api context, SBoolI (FoldRequired mods), SBoolI (FoldLenient mods), HasContextEntry (MkContextWithErrorFormatter context) ErrorFormatters) => HasServer (QueryParam' mods sym a :> api :: Type) context Source #

If you use ``QueryParam` "author" Text` in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of type ``Maybe` `Text``.

This lets servant worry about looking it up in the query string and turning it into a value of the type you specify, enclosed in `Maybe`, because it may not be there and servant would then hand you `Nothing`.

You can control how it'll be converted from `Text` to your type by simply providing an instance of `FromHttpApiData` for your type.

Example:

    type MyApi = "books" :> QueryParam "author" Text :> Get '[JSON] [Book]

    server :: Server MyApi
    server = getBooksBy
      where getBooksBy :: Maybe Text -> Handler [Book]
            getBooksBy Nothing       = ...return all books...
            getBooksBy (Just author) = ...return books by the given author...

Instance details

Defined in Servant.Server.Internal

Methods

route :: Proxy (QueryParam' mods sym a :> api) -> Context context -> Delayed env (Server (QueryParam' mods sym a :> api)) -> Router env Source #

hoistServerWithContext :: Proxy (QueryParam' mods sym a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (QueryParam' mods sym a :> api) m -> ServerT (QueryParam' mods sym a :> api) n Source #

(KnownSymbol sym, FromHttpApiData a, HasServer api context, HasContextEntry (MkContextWithErrorFormatter context) ErrorFormatters) => HasServer (QueryParams sym a :> api :: Type) context Source #

If you use ``QueryParams` "authors" Text` in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of type `[`Text`]`.

This lets servant worry about looking up 0 or more values in the query string associated to `authors` and turning each of them into a value of the type you specify.

You can control how the individual values are converted from `Text` to your type by simply providing an instance of `FromHttpApiData` for your type.

Example:

    type MyApi = "books" :> QueryParams "authors" Text :> Get '[JSON] [Book]

    server :: Server MyApi
    server = getBooksBy
      where getBooksBy :: [Text] -> Handler [Book]
            getBooksBy authors = ...return all books by these authors...

Instance details Defined in Servant.Server.Internal Methods route :: Proxy (QueryParams sym a :> api) -> Context context -> Delayed env (Server (QueryParams sym a :> api)) -> Router env Source # hoistServerWithContext :: Proxy (QueryParams sym a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (QueryParams sym a :> api) m -> ServerT (QueryParams sym a :> api) n Source #

(KnownSymbol sym, FromDeepQuery a, HasServer api context, HasContextEntry (MkContextWithErrorFormatter context) ErrorFormatters) => HasServer (DeepQuery sym a :> api :: Type) context Source #

If you use ``DeepQuery` "symbol" a` in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of type `a`.

This lets you extract an object from multiple parameters in the query string, with its fields enclosed in brackets: `/books?filter[author][name]=value`. When all the fields are known in advance, it can be done with ``QueryParam`` (it can still be tedious if you the object has many fields). When some fields are dynamic, it cannot be done with @`QueryParam`.

The way the object is constructed from the extracted fields can be controlled by providing an instance on ``FromDeepQuery``

Example:

    type MyApi = "books" :> DeepQuery "filter" BookQuery :> Get '[JSON] [Book]

    server :: Server MyApi
    server = getBooksBy
      where getBooksBy :: BookQuery -> Handler [Book]
            getBooksBy query = ...filter books based on the dynamic filters provided...

Instance details Defined in Servant.Server.Internal Methods route :: Proxy (DeepQuery sym a :> api) -> Context context -> Delayed env (Server (DeepQuery sym a :> api)) -> Router env Source # hoistServerWithContext :: Proxy (DeepQuery sym a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (DeepQuery sym a :> api) m -> ServerT (DeepQuery sym a :> api) n Source #

HasServer api context => HasServer (QueryString :> api :: Type) context Source #

If you use ``QueryString`` in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of type `Query` (`[(`ByteString`, `Maybe` `ByteString`)]`).

This lets you extract the whole query string. This is useful when the query string can contain parameters with dynamic names, that you can't access with ``QueryParam``.

Example:

    type MyApi = "books" :> QueryString :> Get '[JSON] [Book]

    server :: Server MyApi
    server = getBooksBy
      where getBooksBy :: Query -> Handler [Book]
            getBooksBy filters = ...filter books based on the dynamic filters provided...

Instance details Defined in Servant.Server.Internal Methods route :: Proxy (QueryString :> api) -> Context context -> Delayed env (Server (QueryString :> api)) -> Router env Source # hoistServerWithContext :: Proxy (QueryString :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (QueryString :> api) m -> ServerT (QueryString :> api) n Source #
HasServer api context => HasServer (RemoteHost :> api :: Type) context Source # |
Instance details Defined in Servant.Server.Internal Methods route :: Proxy (RemoteHost :> api) -> Context context -> Delayed env (Server (RemoteHost :> api)) -> Router env Source # hoistServerWithContext :: Proxy (RemoteHost :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (RemoteHost :> api) m -> ServerT (RemoteHost :> api) n Source #

(AllCTUnrender list a, HasServer api context, SBoolI (FoldLenient mods), HasContextEntry (MkContextWithErrorFormatter context) ErrorFormatters) => HasServer (ReqBody' mods list a :> api :: Type) context Source #

If you use `ReqBody` in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of the type specified by `ReqBody`. The `Content-Type` header is inspected, and the list provided is used to attempt deserialization. If the request does not have a `Content-Type` header, it is treated as `application/octet-stream` (as specified in RFC 7231 section 3.1.1.5). This lets servant worry about extracting it from the request and turning it into a value of the type you specify.

All it asks is for a `FromJSON` instance.

Example:

    type MyApi = "books" :> ReqBody '[JSON] Book :> Post '[JSON] Book

    server :: Server MyApi
    server = postBook
      where postBook :: Book -> Handler Book
            postBook book = ...insert into your db...

Instance details Defined in Servant.Server.Internal Methods route :: Proxy (ReqBody' mods list a :> api) -> Context context -> Delayed env (Server (ReqBody' mods list a :> api)) -> Router env Source # hoistServerWithContext :: Proxy (ReqBody' mods list a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (ReqBody' mods list a :> api) m -> ServerT (ReqBody' mods list a :> api) n Source #
(FramingUnrender framing, FromSourceIO chunk a, MimeUnrender ctype chunk, HasServer api context) => HasServer (StreamBody' mods framing ctype a :> api :: Type) context Source # |

Instance details

Defined in Servant.Server.Internal

Methods

route :: Proxy (StreamBody' mods framing ctype a :> api) -> Context context -> Delayed env (Server (StreamBody' mods framing ctype a :> api)) -> Router env Source #

hoistServerWithContext :: Proxy (StreamBody' mods framing ctype a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (StreamBody' mods framing ctype a :> api) m -> ServerT (StreamBody' mods framing ctype a :> api) n Source #

(HasServer api ctx, HasContextEntry ctx (Acquire a)) => HasServer (WithResource a :> api :: Type) ctx Source #

If you use `WithResource` in one of the endpoints for your API Servant will provide the handler for this endpoint an argument of the specified type. The lifespan of this resource will be automatically managed by Servant. This resource will be created before the handler starts and it will be destoyed after it ends. A new resource is created for each request to the endpoint.

Instance details Defined in Servant.Server.Internal Methods route :: Proxy (WithResource a :> api) -> Context ctx -> Delayed env (Server (WithResource a :> api)) -> Router env Source # hoistServerWithContext :: Proxy (WithResource a :> api) -> Proxy ctx -> (forall x. m x -> n x) -> ServerT (WithResource a :> api) m -> ServerT (WithResource a :> api) n Source #
HasServer api context => HasServer (Vault :> api :: Type) context Source # |
Instance details Defined in Servant.Server.Internal Methods route :: Proxy (Vault :> api) -> Context context -> Delayed env (Server (Vault :> api)) -> Router env Source # hoistServerWithContext :: Proxy (Vault :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Vault :> api) m -> ServerT (Vault :> api) n Source #
(TypeError (NoInstanceForSub (HasServer :: Type -> [Type] -> Constraint) ty) :: Constraint) => HasServer (ty :> sub :: Type) context Source # |
Instance details Defined in Servant.Server.Internal Methods route :: Proxy (ty :> sub) -> Context context -> Delayed env (Server (ty :> sub)) -> Router env Source # hoistServerWithContext :: Proxy (ty :> sub) -> Proxy context -> (forall x. m x -> n x) -> ServerT (ty :> sub) m -> ServerT (ty :> sub) n Source #
(ReflectMethod method, AllMime contentTypes, All (IsServerResourceWithStatus contentTypes) as, Unique (Statuses as)) => HasServer (UVerb method contentTypes as :: Type) context Source # |

Instance details

Defined in Servant.Server.UVerb

Methods

route :: Proxy (UVerb method contentTypes as) -> Context context -> Delayed env (Server (UVerb method contentTypes as)) -> Router env Source #

hoistServerWithContext :: Proxy (UVerb method contentTypes as) -> Proxy context -> (forall x. m x -> n x) -> ServerT (UVerb method contentTypes as) m -> ServerT (UVerb method contentTypes as) n Source #

(HasContextEntry context (NamedContext name subContext), HasServer subApi subContext) => HasServer (WithNamedContext name subContext subApi :: Type) context Source # |

Instance details

Defined in Servant.Server.Internal

Methods

route :: Proxy (WithNamedContext name subContext subApi) -> Context context -> Delayed env (Server (WithNamedContext name subContext subApi)) -> Router env Source #

hoistServerWithContext :: Proxy (WithNamedContext name subContext subApi) -> Proxy context -> (forall x. m x -> n x) -> ServerT (WithNamedContext name subContext subApi) m -> ServerT (WithNamedContext name subContext subApi) n Source #

(HasAcceptCheck cs, ResponseListRender cs as, AsUnion as r, ReflectMethod method) => HasServer (MultiVerb method cs as r :: Type) ctx Source # |
Instance details Defined in Servant.Server.Internal Methods route :: Proxy (MultiVerb method cs as r) -> Context ctx -> Delayed env (Server (MultiVerb method cs as r)) -> Router env Source # hoistServerWithContext :: Proxy (MultiVerb method cs as r) -> Proxy ctx -> (forall x. m x -> n x) -> ServerT (MultiVerb method cs as r) m -> ServerT (MultiVerb method cs as r) n Source #
(AllCTRender ctypes a, ReflectMethod method, KnownNat status, GetHeaders (Headers h a)) => HasServer (Verb method status ctypes (Headers h a) :: Type) context Source # |

Instance details

Defined in Servant.Server.Internal

Methods

route :: Proxy (Verb method status ctypes (Headers h a)) -> Context context -> Delayed env (Server (Verb method status ctypes (Headers h a))) -> Router env Source #

hoistServerWithContext :: Proxy (Verb method status ctypes (Headers h a)) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Verb method status ctypes (Headers h a)) m -> ServerT (Verb method status ctypes (Headers h a)) n Source #

(AllCTRender ctypes a, ReflectMethod method, KnownNat status) => HasServer (Verb method status ctypes a :: Type) context Source # |
Instance details Defined in Servant.Server.Internal Methods route :: Proxy (Verb method status ctypes a) -> Context context -> Delayed env (Server (Verb method status ctypes a)) -> Router env Source # hoistServerWithContext :: Proxy (Verb method status ctypes a) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Verb method status ctypes a) m -> ServerT (Verb method status ctypes a) n Source #
(MimeRender ctype chunk, ReflectMethod method, KnownNat status, FramingRender framing, ToSourceIO chunk a, GetHeaders (Headers h a)) => HasServer (Stream method status framing ctype (Headers h a) :: Type) context Source # |

Instance details

Defined in Servant.Server.Internal

Methods

route :: Proxy (Stream method status framing ctype (Headers h a)) -> Context context -> Delayed env (Server (Stream method status framing ctype (Headers h a))) -> Router env Source #

hoistServerWithContext :: Proxy (Stream method status framing ctype (Headers h a)) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Stream method status framing ctype (Headers h a)) m -> ServerT (Stream method status framing ctype (Headers h a)) n Source #

(MimeRender ctype chunk, ReflectMethod method, KnownNat status, FramingRender framing, ToSourceIO chunk a) => HasServer (Stream method status framing ctype a :: Type) context Source # |

Instance details

Defined in Servant.Server.Internal

Methods

route :: Proxy (Stream method status framing ctype a) -> Context context -> Delayed env (Server (Stream method status framing ctype a)) -> Router env Source #

hoistServerWithContext :: Proxy (Stream method status framing ctype a) -> Proxy context -> (forall x. m x -> n x) -> ServerT (Stream method status framing ctype a) m -> ServerT (Stream method status framing ctype a) n Source #

type Server (api :: k) = ServerT api Handler Source #

data EmptyServer Source #

Singleton type representing a server that serves an empty API.

#### Instances

Instances details

Bounded EmptyServer Source # |
Instance details Defined in Servant.Server.Internal Methods minBound :: EmptyServer Source # maxBound :: EmptyServer Source #
Enum EmptyServer Source # |

Instance details

Defined in Servant.Server.Internal

Methods

succ :: EmptyServer -> EmptyServer Source #

pred :: EmptyServer -> EmptyServer Source #

toEnum :: Int -> EmptyServer Source #

fromEnum :: EmptyServer -> Int Source #

enumFrom :: EmptyServer -> [EmptyServer] Source #

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

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

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

Show EmptyServer Source # |
Instance details Defined in Servant.Server.Internal Methods showsPrec :: Int -> EmptyServer -> ShowS Source # show :: EmptyServer -> String Source # showList :: [EmptyServer] -> ShowS Source #
Eq EmptyServer Source # |
Instance details Defined in Servant.Server.Internal Methods (==) :: EmptyServer -> EmptyServer -> Bool Source # (/=) :: EmptyServer -> EmptyServer -> Bool Source #

emptyServer :: forall (m :: Type -> Type). ServerT EmptyAPI m Source #

Server for `EmptyAPI`

newtype Handler a Source #

Constructors

Handler |

Fields

- runHandler' :: ExceptT ServerError IO a

#### Instances

Instances details

MonadIO Handler Source # |
Instance details Defined in Servant.Server.Internal.Handler Methods liftIO :: IO a -> Handler a Source #
MonadCatch Handler Source # |
Instance details Defined in Servant.Server.Internal.Handler Methods catch :: (HasCallStack, Exception e) => Handler a -> (e -> Handler a) -> Handler a Source #
MonadMask Handler Source # |
Instance details Defined in Servant.Server.Internal.Handler Methods mask :: HasCallStack => ((forall a. Handler a -> Handler a) -> Handler b) -> Handler b Source # uninterruptibleMask :: HasCallStack => ((forall a. Handler a -> Handler a) -> Handler b) -> Handler b Source # generalBracket :: HasCallStack => Handler a -> (a -> ExitCase b -> Handler c) -> (a -> Handler b) -> Handler (b, c) Source #
MonadThrow Handler Source # |
Instance details Defined in Servant.Server.Internal.Handler Methods throwM :: (HasCallStack, Exception e) => e -> Handler a Source #
Applicative Handler Source # |
Instance details Defined in Servant.Server.Internal.Handler Methods pure :: a -> Handler a Source # (<*>) :: Handler (a -> b) -> Handler a -> Handler b Source # liftA2 :: (a -> b -> c) -> Handler a -> Handler b -> Handler c Source # (*>) :: Handler a -> Handler b -> Handler b Source # (<*) :: Handler a -> Handler b -> Handler a Source #
Functor Handler Source # |
Instance details Defined in Servant.Server.Internal.Handler Methods fmap :: (a -> b) -> Handler a -> Handler b Source # (<$) :: a -> Handler b -> Handler a Source #
Monad Handler Source # |
Instance details Defined in Servant.Server.Internal.Handler Methods (>>=) :: Handler a -> (a -> Handler b) -> Handler b Source # (>>) :: Handler a -> Handler b -> Handler b Source # return :: a -> Handler a Source #
MonadFail Handler Source # |
Instance details Defined in Servant.Server.Internal.Handler Methods fail :: String -> Handler a Source #
MonadBaseControl IO Handler Source # |

Instance details

Defined in Servant.Server.Internal.Handler

Associated Types

type StM Handler a |
Instance details Defined in Servant.Server.Internal.Handler type StM Handler a = Either ServerError a

Methods

liftBaseWith :: (RunInBase Handler IO -> IO a) -> Handler a Source #

restoreM :: StM Handler a -> Handler a Source #

MonadError ServerError Handler Source # |
Instance details Defined in Servant.Server.Internal.Handler Methods throwError :: ServerError -> Handler a Source # catchError :: Handler a -> (ServerError -> Handler a) -> Handler a Source #
MonadBase IO Handler Source # |
Instance details Defined in Servant.Server.Internal.Handler Methods liftBase :: IO α -> Handler α Source #
Generic (Handler a) Source # |

Instance details

Defined in Servant.Server.Internal.Handler

Associated Types

type Rep (Handler a) |
Instance details Defined in Servant.Server.Internal.Handler type Rep (Handler a) = D1 ('MetaData "Handler" "Servant.Server.Internal.Handler" "servant-server-0.20.3.0-K3OEf3La2TA6Zg4wWiPZKx" 'True) (C1 ('MetaCons "Handler" 'PrefixI 'True) (S1 ('MetaSel ('Just "runHandler'") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ExceptT ServerError IO a))))

Methods

from :: Handler a -> Rep (Handler a) x Source #

to :: Rep (Handler a) x -> Handler a Source #

type StM Handler a Source # |
Instance details Defined in Servant.Server.Internal.Handler type StM Handler a = Either ServerError a
type Rep (Handler a) Source # |
Instance details Defined in Servant.Server.Internal.Handler type Rep (Handler a) = D1 ('MetaData "Handler" "Servant.Server.Internal.Handler" "servant-server-0.20.3.0-K3OEf3La2TA6Zg4wWiPZKx" 'True) (C1 ('MetaCons "Handler" 'PrefixI 'True) (S1 ('MetaSel ('Just "runHandler'") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ExceptT ServerError IO a))))

runHandler :: Handler a -> IO (Either ServerError a) Source #

pattern MkHandler :: IO (Either ServerError a) -> Handler a Source #

Pattern synonym that matches directly on the inner `IO` action.

To lift `IO` actions that don't carry a `ServerError`, use `liftIO` instead.

# Debugging the server layout

layout :: forall {k} (api :: k). HasServer api ('[] :: [Type]) => Proxy api -> Text Source #

The function `layout` produces a textual description of the internal router layout for debugging purposes. Note that the router layout is determined just by the API, not by the handlers.

Example:

For the following API

    type API =
           "a" :> "d" :> Get '[JSON] NoContent
      :<|> "b" :> Capture "x" Int :> Get '[JSON] Bool
      :<|> "c" :> Put '[JSON] Bool
      :<|> "a" :> "e" :> Get '[JSON] Int
      :<|> "b" :> Capture "x" Int :> Put '[JSON] Bool
      :<|> Raw

we get the following output:

    /
    ├─ a/
    │  ├─ d/
    │  │  └─•
    │  └─ e/
    │     └─•
    ├─ b/
    │  └─ <x::Int>/
    │     ├─•
    │     ┆
    │     └─•
    ├─ c/
    │  └─•
    ┆
    └─ <raw>

Explanation of symbols:

`├`
  Normal lines reflect static branching via a table.
`a/`
  Nodes reflect static path components.
`─•`
  Leaves reflect endpoints.
`<x::Int>/`
  This is a delayed capture of a single path component named `x`, of expected type `Int`.
`<raw>`
  This is a part of the API we do not know anything about.
`┆`
  Dashed lines suggest a dynamic choice between the part above and below. If there is a success for fatal failure in the first part, that one takes precedence. If both parts fail, the "better" error code will be returned.

layoutWithContext :: forall {k} (api :: k) (context :: [Type]). HasServer api context => Proxy api -> Context context -> Text Source #

Variant of `layout` that takes an additional `Context`.

# Enter / hoisting server

hoistServer :: forall {k} (api :: k) m n. HasServer api ('[] :: [Type]) => Proxy api -> (forall x. m x -> n x) -> ServerT api m -> ServerT api n Source #

Hoist server implementation.

Sometimes our cherished `Handler` monad isn't quite the type you'd like for your handlers. Maybe you want to thread some configuration in a `Reader` monad. Or have your types ensure that your handlers don't do any IO. Use `hoistServer` (a successor of now deprecated `enter`).

With `hoistServer`, you can provide a function, to convert any number of endpoints from one type constructor to another. For example

Note: `Server` `Raw` can also be entered. It will be retagged.

    >>> import Control.Monad.Reader
    >>> type ReaderAPI = "ep1" :> Get '[JSON] Int :<|> "ep2" :> Get '[JSON] String :<|> Raw :<|> EmptyAPI
    >>> let readerApi = Proxy :: Proxy ReaderAPI
    >>> let readerServer = return 1797 :<|> ask :<|> Tagged (error "raw server") :<|> emptyServer :: ServerT ReaderAPI (Reader String)
    >>> let nt x = return (runReader x "hi")
    >>> let mainServer = hoistServer readerApi nt readerServer :: Server ReaderAPI

## Functions based on mmorph

tweakResponse :: (RouteResult Response -> RouteResult Response) -> Router env -> Router env Source #

Apply a transformation to the response of a `Router`.

# Context

data Context (contextTypes :: [Type]) where Source #

`Context`s are used to pass values to combinators. (They are not meant to be used to pass parameters to your handlers, i.e. they should not replace any custom `ReaderT`-monad-stack that you're using with `hoistServer`.) If you don't use combinators that require any context entries, you can just use `serve` as always.

If you are using combinators that require a non-empty `Context` you have to use `serveWithContext` and pass it a `Context` that contains all the values your combinators need. A `Context` is essentially a heterogeneous list and accessing the elements is being done by type (see `getContextEntry`). The parameter of the type `Context` is a type-level list reflecting the types of the contained context entries. To create a `Context` with entries, use the operator `(`:.`)`:

    >>> :type True :. () :. EmptyContext
    True :. () :. EmptyContext :: Context '[Bool, ()]

Constructors

EmptyContext :: Context ('[] :: [Type]) |
(:.) :: forall x (xs :: [Type]). x -> Context xs -> Context (x ': xs) infixr 5 |

#### Instances

Instances details

(Show a, Show (Context as)) => Show (Context (a ': as)) Source # |
Instance details Defined in Servant.Server.Internal.Context Methods showsPrec :: Int -> Context (a ': as) -> ShowS Source # show :: Context (a ': as) -> String Source # showList :: [Context (a ': as)] -> ShowS Source #
Show (Context ('[] :: [Type])) Source # |
Instance details Defined in Servant.Server.Internal.Context Methods showsPrec :: Int -> Context ('[] :: [Type]) -> ShowS Source # show :: Context ('[] :: [Type]) -> String Source # showList :: [Context ('[] :: [Type])] -> ShowS Source #
(Eq a, Eq (Context as)) => Eq (Context (a ': as)) Source # |
Instance details Defined in Servant.Server.Internal.Context Methods (==) :: Context (a ': as) -> Context (a ': as) -> Bool Source # (/=) :: Context (a ': as) -> Context (a ': as) -> Bool Source #
Eq (Context ('[] :: [Type])) Source # |
Instance details Defined in Servant.Server.Internal.Context Methods (==) :: Context ('[] :: [Type]) -> Context ('[] :: [Type]) -> Bool Source # (/=) :: Context ('[] :: [Type]) -> Context ('[] :: [Type]) -> Bool Source #

class HasContextEntry (context :: [Type]) val where Source #

This class is used to access context entries in `Context`s. `getContextEntry` returns the first value where the type matches:

    >>> getContextEntry (True :. False :. EmptyContext) :: Bool
    True

If the `Context` does not contain an entry of the requested type, you'll get an error:

    >>> getContextEntry (True :. False :. EmptyContext) :: String
    ...
    ...No instance for ...HasContextEntry '[] [Char]...
    ...

Methods

getContextEntry :: Context context -> val Source #

#### Instances

Instances details

HasContextEntry xs val => HasContextEntry (notIt ': xs) val Source # |
Instance details Defined in Servant.Server.Internal.Context Methods getContextEntry :: Context (notIt ': xs) -> val Source #
HasContextEntry (val ': xs) val Source # |
Instance details Defined in Servant.Server.Internal.Context Methods getContextEntry :: Context (val ': xs) -> val Source #

type family (l1 :: [Type]) .++ (l2 :: [Type]) :: [Type] where ... Source #

Append two type-level lists.

Import it as

    import Servant.API.TypeLevel.List (type (.++))

Equations

('[] :: [Type]) .++ a = a |
(a ': as) .++ b = a ': (as .++ b) |

(.++) :: forall (l1 :: [Type]) (l2 :: [Type]). Context l1 -> Context l2 -> Context (l1 .++ l2) Source #

Append two contexts.

## NamedContext

newtype NamedContext (name :: Symbol) (subContext :: [Type]) Source #

Normally context entries are accessed by their types. In case you need to have multiple values of the same type in your `Context` and need to access them, we provide `NamedContext`. You can think of it as sub-namespaces for `Context`s.

Constructors

NamedContext (Context subContext) |

descendIntoNamedContext :: forall (context :: [Type]) (name :: Symbol) (subContext :: [Type]). HasContextEntry context (NamedContext name subContext) => Proxy name -> Context context -> Context subContext Source #

`descendIntoNamedContext` allows you to access `NamedContext`s. Usually you won't have to use it yourself but instead use a combinator like `WithNamedContext`.

This is how `descendIntoNamedContext` works:

    >>> :set -XFlexibleContexts
    >>> let subContext = True :. EmptyContext
    >>> :type subContext
    subContext :: Context '[Bool]
    >>> let parentContext = False :. (NamedContext subContext :: NamedContext "subContext" '[Bool]) :. EmptyContext
    >>> :type parentContext
    parentContext :: Context '[Bool, NamedContext "subContext" '[Bool]]
    >>> descendIntoNamedContext (Proxy :: Proxy "subContext") parentContext :: Context '[Bool]
    True :. EmptyContext

# Basic Authentication

newtype BasicAuthCheck usr Source #

Datatype wrapping a function used to check authentication.

Constructors

BasicAuthCheck |

Fields

- unBasicAuthCheck :: BasicAuthData -> IO (BasicAuthResult usr)

#### Instances

Instances details

Functor BasicAuthCheck Source # |
Instance details Defined in Servant.Server.Internal.BasicAuth Methods fmap :: (a -> b) -> BasicAuthCheck a -> BasicAuthCheck b Source # (<$) :: a -> BasicAuthCheck b -> BasicAuthCheck a Source #
Generic (BasicAuthCheck usr) Source # |

Instance details

Defined in Servant.Server.Internal.BasicAuth

Associated Types

type Rep (BasicAuthCheck usr) |

Instance details

Defined in Servant.Server.Internal.BasicAuth

type Rep (BasicAuthCheck usr) = D1 ('MetaData "BasicAuthCheck" "Servant.Server.Internal.BasicAuth" "servant-server-0.20.3.0-K3OEf3La2TA6Zg4wWiPZKx" 'True) (C1 ('MetaCons "BasicAuthCheck" 'PrefixI 'True) (S1 ('MetaSel ('Just "unBasicAuthCheck") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (BasicAuthData -> IO (BasicAuthResult usr)))))

Methods

from :: BasicAuthCheck usr -> Rep (BasicAuthCheck usr) x Source #

to :: Rep (BasicAuthCheck usr) x -> BasicAuthCheck usr Source #

type Rep (BasicAuthCheck usr) Source # |

Instance details

Defined in Servant.Server.Internal.BasicAuth

type Rep (BasicAuthCheck usr) = D1 ('MetaData "BasicAuthCheck" "Servant.Server.Internal.BasicAuth" "servant-server-0.20.3.0-K3OEf3La2TA6Zg4wWiPZKx" 'True) (C1 ('MetaCons "BasicAuthCheck" 'PrefixI 'True) (S1 ('MetaSel ('Just "unBasicAuthCheck") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (BasicAuthData -> IO (BasicAuthResult usr)))))

data BasicAuthResult usr Source #

servant-server's current implementation of basic authentication is not immune to certain kinds of timing attacks. Decoding payloads does not take a fixed amount of time.

The result of authentication/authorization

Constructors

Unauthorized |
BadPassword |
NoSuchUser |
Authorized usr |

#### Instances

Instances details

Functor BasicAuthResult Source # |
Instance details Defined in Servant.Server.Internal.BasicAuth Methods fmap :: (a -> b) -> BasicAuthResult a -> BasicAuthResult b Source # (<$) :: a -> BasicAuthResult b -> BasicAuthResult a Source #
Generic (BasicAuthResult usr) Source # |

Instance details

Defined in Servant.Server.Internal.BasicAuth

Associated Types

type Rep (BasicAuthResult usr) |

Instance details

Defined in Servant.Server.Internal.BasicAuth

type Rep (BasicAuthResult usr) = D1 ('MetaData "BasicAuthResult" "Servant.Server.Internal.BasicAuth" "servant-server-0.20.3.0-K3OEf3La2TA6Zg4wWiPZKx" 'False) ((C1 ('MetaCons "Unauthorized" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BadPassword" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "NoSuchUser" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Authorized" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 usr))))

Methods

from :: BasicAuthResult usr -> Rep (BasicAuthResult usr) x Source #

to :: Rep (BasicAuthResult usr) x -> BasicAuthResult usr Source #

Read usr => Read (BasicAuthResult usr) Source # |
Instance details Defined in Servant.Server.Internal.BasicAuth Methods readsPrec :: Int -> ReadS (BasicAuthResult usr) Source # readList :: ReadS [BasicAuthResult usr] Source # readPrec :: ReadPrec (BasicAuthResult usr) Source # readListPrec :: ReadPrec [BasicAuthResult usr] Source #
Show usr => Show (BasicAuthResult usr) Source # |
Instance details Defined in Servant.Server.Internal.BasicAuth Methods showsPrec :: Int -> BasicAuthResult usr -> ShowS Source # show :: BasicAuthResult usr -> String Source # showList :: [BasicAuthResult usr] -> ShowS Source #
Eq usr => Eq (BasicAuthResult usr) Source # |
Instance details Defined in Servant.Server.Internal.BasicAuth Methods (==) :: BasicAuthResult usr -> BasicAuthResult usr -> Bool Source # (/=) :: BasicAuthResult usr -> BasicAuthResult usr -> Bool Source #
type Rep (BasicAuthResult usr) Source # |

Instance details

Defined in Servant.Server.Internal.BasicAuth

type Rep (BasicAuthResult usr) = D1 ('MetaData "BasicAuthResult" "Servant.Server.Internal.BasicAuth" "servant-server-0.20.3.0-K3OEf3La2TA6Zg4wWiPZKx" 'False) ((C1 ('MetaCons "Unauthorized" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BadPassword" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "NoSuchUser" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Authorized" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 usr))))

# General Authentication

# Default error type

data ServerError Source #

Constructors

ServerError |

Fields

- errHTTPCode :: Int
- errReasonPhrase :: String
- errBody :: ByteString
- errHeaders :: [Header]

#### Instances

Instances details

Exception ServerError Source # |
Instance details Defined in Servant.Server.Internal.ServerError Methods toException :: ServerError -> SomeException Source # fromException :: SomeException -> Maybe ServerError Source # displayException :: ServerError -> String Source # backtraceDesired :: ServerError -> Bool Source #
Read ServerError Source # |
Instance details Defined in Servant.Server.Internal.ServerError Methods readsPrec :: Int -> ReadS ServerError Source # readList :: ReadS [ServerError] Source # readPrec :: ReadPrec ServerError Source # readListPrec :: ReadPrec [ServerError] Source #
Show ServerError Source # |
Instance details Defined in Servant.Server.Internal.ServerError Methods showsPrec :: Int -> ServerError -> ShowS Source # show :: ServerError -> String Source # showList :: [ServerError] -> ShowS Source #
Eq ServerError Source # |
Instance details Defined in Servant.Server.Internal.ServerError Methods (==) :: ServerError -> ServerError -> Bool Source # (/=) :: ServerError -> ServerError -> Bool Source #
MonadError ServerError Handler Source # |
Instance details Defined in Servant.Server.Internal.Handler Methods throwError :: ServerError -> Handler a Source # catchError :: Handler a -> (ServerError -> Handler a) -> Handler a Source #

## 3XX

err300 :: ServerError Source #

`err300` Multiple Choices

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err300 { errBody = "I can't choose." }

err301 :: ServerError Source #

`err301` Moved Permanently

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err301

err302 :: ServerError Source #

`err302` Found

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err302

err303 :: ServerError Source #

`err303` See Other

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err303

err304 :: ServerError Source #

`err304` Not Modified

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err304

err305 :: ServerError Source #

`err305` Use Proxy

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err305

err307 :: ServerError Source #

`err307` Temporary Redirect

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err307

## 4XX

err400 :: ServerError Source #

`err400` Bad Request

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err400 { errBody = "Your request makes no sense to me." }

err401 :: ServerError Source #

`err401` Unauthorized

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err401 { errBody = "Your credentials are invalid." }

err402 :: ServerError Source #

`err402` Payment Required

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err402 { errBody = "You have 0 credits. Please give me $$$." }

err403 :: ServerError Source #

`err403` Forbidden

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err403 { errBody = "Please login first." }

err404 :: ServerError Source #

`err404` Not Found

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err404 { errBody = "Are you lost?" }

err405 :: ServerError Source #

`err405` Method Not Allowed

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err405 { errBody = "Your account privileges does not allow for this.  Please pay $$$." }

err406 :: ServerError Source #

`err406` Not Acceptable

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err406

err407 :: ServerError Source #

`err407` Proxy Authentication Required

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err407

err409 :: ServerError Source #

`err409` Conflict

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err409 { errBody = "Transaction conflicts with 59879cb56c7c159231eeacdd503d755f7e835f74" }

err410 :: ServerError Source #

`err410` Gone

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err410 { errBody = "I know it was here at some point, but.. I blame bad luck." }

err411 :: ServerError Source #

`err411` Length Required

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err411

err412 :: ServerError Source #

`err412` Precondition Failed

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err412 { errBody = "Precondition fail: x < 42 && y > 57" }

err413 :: ServerError Source #

`err413` Request Entity Too Large

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err413 { errBody = "Request exceeded 64k." }

err414 :: ServerError Source #

`err414` Request-URI Too Large

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err414 { errBody = "Maximum length is 64." }

err415 :: ServerError Source #

`err415` Unsupported Media Type

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err415 { errBody = "Supported media types:  gif, png" }

err416 :: ServerError Source #

`err416` Request range not satisfiable

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err416 { errBody = "Valid range is [0, 424242]." }

err417 :: ServerError Source #

`err417` Expectation Failed

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err417 { errBody = "I found a quux in the request.  This isn't going to work." }

err418 :: ServerError Source #

`err418` Expectation Failed

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err418 { errBody = "Apologies, this is not a webserver but a teapot." }

err422 :: ServerError Source #

`err422` Unprocessable Entity

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err422 { errBody = "I understood your request, but can't process it." }

err429 :: ServerError Source #

`err429` Too Many Requests

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err429 { errBody = "You have sent too many requests in a short period of time." }

## 5XX

err500 :: ServerError Source #

`err500` Internal Server Error

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err500 { errBody = "Exception in module A.B.C:55.  Have a great day!" }

err501 :: ServerError Source #

`err501` Not Implemented

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err501 { errBody = "/v1/foo is not supported with quux in the request." }

err502 :: ServerError Source #

`err502` Bad Gateway

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err502 { errBody = "Tried gateway foo, bar, and baz.  None responded." }

err503 :: ServerError Source #

`err503` Service Unavailable

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err503 { errBody = "We're rewriting in PHP." }

err504 :: ServerError Source #

`err504` Gateway Time-out

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err504 { errBody = "Backend foobar did not respond in 5 seconds." }

err505 :: ServerError Source #

`err505` HTTP Version not supported

Example usage:

    failingHandler :: Handler ()
    failingHandler = throwError $ err505 { errBody = "I support HTTP/4.0 only." }

# Formatting of errors from combinators

You can configure how Servant will render errors that occur while parsing the request.

type ErrorFormatter = TypeRep -> Request -> String -> ServerError Source #

A custom formatter for errors produced by parsing combinators like `ReqBody` or `Capture`.

A `TypeRep` argument described the concrete combinator that raised the error, allowing formatter to customize the message for different combinators.

A full `Request` is also passed so that the formatter can react to `Accept` header, for example.

type NotFoundErrorFormatter = Request -> ServerError Source #

This formatter does not get neither `TypeRep` nor error message.

data ErrorFormatters Source #

A collection of error formatters for different situations.

If you need to override one of them, use `defaultErrorFormatters` with record update syntax.

bodyParserErrorFormatter :: ErrorFormatters -> ErrorFormatter Source #

Format error from parsing the request body.

urlParseErrorFormatter :: ErrorFormatters -> ErrorFormatter Source #

Format error from parsing url parts or query parameters.

headerParseErrorFormatter :: ErrorFormatters -> ErrorFormatter Source #

Format error from parsing request headers.

notFoundErrorFormatter :: ErrorFormatters -> NotFoundErrorFormatter Source #

Format error for not found URLs.

type DefaultErrorFormatters = '[ErrorFormatters] Source #

`Context` that contains default error formatters.

defaultErrorFormatters :: ErrorFormatters Source #

Default formatters will just return HTTP 400 status code with error message as response body.

getAcceptHeader :: Request -> AcceptHeader Source #

# Re-exports

type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived Source #

The WAI application.

Note that, since WAI 3.0, this type is structured in continuation passing style to allow for proper safe resource handling. This was handled in the past via other means (e.g., `ResourceT`). As a demonstration:

    app :: Application
    app req respond = bracket_
        (putStrLn "Allocating scarce resource")
        (putStrLn "Cleaning up")
        (respond $ responseLBS status200 [] "Hello World")

newtype Tagged (s :: k) b Source #

A ``Tagged` s b` value is a value `b` with an attached phantom type `s`. This can be used in place of the more traditional but less safe idiom of passing in an undefined value with the type, because unlike an `(s -> b)`, a ``Tagged` s b` can't try to use the argument `s` as a real value.

Moreover, you don't have to rely on the compiler to inline away the extra argument, because the newtype is "free"

`Tagged` has kind `k -> * -> *` if the compiler supports `PolyKinds`, therefore there is an extra `k` showing in the instance haddocks that may cause confusion.

Constructors

Tagged |

Fields

- unTagged :: b

#### Instances

Instances details

Generic1 (Tagged s :: Type -> Type) |

Instance details

Defined in Data.Tagged

Associated Types

type Rep1 (Tagged s :: Type -> Type) |
Instance details Defined in Data.Tagged type Rep1 (Tagged s :: Type -> Type) = D1 ('MetaData "Tagged" "Data.Tagged" "tagged-0.8.9-EraSdp0lx7uJnqESyrqLTP" 'True) (C1 ('MetaCons "Tagged" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTagged") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))

Methods

from1 :: Tagged s a -> Rep1 (Tagged s) a Source #

to1 :: Rep1 (Tagged s) a -> Tagged s a Source #

FoldableWithIndex () (Tagged a) |

Instance details

Defined in Data.Functor.WithIndex.Instances

Methods

ifoldMap :: Monoid m => (() -> a0 -> m) -> Tagged a a0 -> m

ifoldMap' :: Monoid m => (() -> a0 -> m) -> Tagged a a0 -> m

ifoldr :: (() -> a0 -> b -> b) -> b -> Tagged a a0 -> b

ifoldl :: (() -> b -> a0 -> b) -> b -> Tagged a a0 -> b

ifoldr' :: (() -> a0 -> b -> b) -> b -> Tagged a a0 -> b

ifoldl' :: (() -> b -> a0 -> b) -> b -> Tagged a a0 -> b

FunctorWithIndex () (Tagged a) |
Instance details Defined in Data.Functor.WithIndex.Instances Methods imap :: (() -> a0 -> b) -> Tagged a a0 -> Tagged a b
TraversableWithIndex () (Tagged a) |
Instance details Defined in Data.Functor.WithIndex.Instances Methods itraverse :: Applicative f => (() -> a0 -> f b) -> Tagged a a0 -> f (Tagged a b)
Bifoldable (Tagged :: Type -> Type -> Type) |
Instance details Defined in Data.Tagged Methods bifold :: Monoid m => Tagged m m -> m Source # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Tagged a b -> m Source # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Tagged a b -> c Source # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Tagged a b -> c Source #
Bifoldable1 (Tagged :: Type -> Type -> Type) |
Instance details Defined in Data.Tagged Methods bifold1 :: Semigroup m => Tagged m m -> m Source # bifoldMap1 :: Semigroup m => (a -> m) -> (b -> m) -> Tagged a b -> m Source #
Bifunctor (Tagged :: Type -> Type -> Type) |
Instance details Defined in Data.Tagged Methods bimap :: (a -> b) -> (c -> d) -> Tagged a c -> Tagged b d Source # first :: (a -> b) -> Tagged a c -> Tagged b c Source # second :: (b -> c) -> Tagged a b -> Tagged a c Source #
Bitraversable (Tagged :: Type -> Type -> Type) |
Instance details Defined in Data.Tagged Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Tagged a b -> f (Tagged c d) Source #
Eq2 (Tagged :: Type -> Type -> Type) |
Instance details Defined in Data.Tagged Methods liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> Tagged a c -> Tagged b d -> Bool Source #
Ord2 (Tagged :: Type -> Type -> Type) |
Instance details Defined in Data.Tagged Methods liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> Tagged a c -> Tagged b d -> Ordering Source #
Read2 (Tagged :: Type -> Type -> Type) |

Instance details

Defined in Data.Tagged

Methods

liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (Tagged a b) Source #

liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Tagged a b] Source #

liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (Tagged a b) Source #

liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [Tagged a b] Source #

Show2 (Tagged :: Type -> Type -> Type) |
Instance details Defined in Data.Tagged Methods liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> Tagged a b -> ShowS Source # liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [Tagged a b] -> ShowS Source #
Foldable1 (Tagged a) |

Instance details

Defined in Data.Tagged

Methods

fold1 :: Semigroup m => Tagged a m -> m Source #

foldMap1 :: Semigroup m => (a0 -> m) -> Tagged a a0 -> m Source #

foldMap1' :: Semigroup m => (a0 -> m) -> Tagged a a0 -> m Source #

toNonEmpty :: Tagged a a0 -> NonEmpty a0 Source #

maximum :: Ord a0 => Tagged a a0 -> a0 Source #

minimum :: Ord a0 => Tagged a a0 -> a0 Source #

head :: Tagged a a0 -> a0 Source #

last :: Tagged a a0 -> a0 Source #

foldrMap1 :: (a0 -> b) -> (a0 -> b -> b) -> Tagged a a0 -> b Source #

foldlMap1' :: (a0 -> b) -> (b -> a0 -> b) -> Tagged a a0 -> b Source #

foldlMap1 :: (a0 -> b) -> (b -> a0 -> b) -> Tagged a a0 -> b Source #

foldrMap1' :: (a0 -> b) -> (a0 -> b -> b) -> Tagged a a0 -> b Source #

Eq1 (Tagged s) |
Instance details Defined in Data.Tagged Methods liftEq :: (a -> b -> Bool) -> Tagged s a -> Tagged s b -> Bool Source #
Ord1 (Tagged s) |
Instance details Defined in Data.Tagged Methods liftCompare :: (a -> b -> Ordering) -> Tagged s a -> Tagged s b -> Ordering Source #
Read1 (Tagged s) |
Instance details Defined in Data.Tagged Methods liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Tagged s a) Source # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Tagged s a] Source # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Tagged s a) Source # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Tagged s a] Source #
Show1 (Tagged s) |
Instance details Defined in Data.Tagged Methods liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Tagged s a -> ShowS Source # liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Tagged s a] -> ShowS Source #
Applicative (Tagged s) |
Instance details Defined in Data.Tagged Methods pure :: a -> Tagged s a Source # (<*>) :: Tagged s (a -> b) -> Tagged s a -> Tagged s b Source # liftA2 :: (a -> b -> c) -> Tagged s a -> Tagged s b -> Tagged s c Source # (*>) :: Tagged s a -> Tagged s b -> Tagged s b Source # (<*) :: Tagged s a -> Tagged s b -> Tagged s a Source #
Functor (Tagged s) |
Instance details Defined in Data.Tagged Methods fmap :: (a -> b) -> Tagged s a -> Tagged s b Source # (<$) :: a -> Tagged s b -> Tagged s a Source #
Monad (Tagged s) |
Instance details Defined in Data.Tagged Methods (>>=) :: Tagged s a -> (a -> Tagged s b) -> Tagged s b Source # (>>) :: Tagged s a -> Tagged s b -> Tagged s b Source # return :: a -> Tagged s a Source #
Foldable (Tagged s) |

Instance details

Defined in Data.Tagged

Methods

fold :: Monoid m => Tagged s m -> m Source #

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

foldMap' :: Monoid m => (a -> m) -> Tagged s a -> m Source #

foldr :: (a -> b -> b) -> b -> Tagged s a -> b Source #

foldr' :: (a -> b -> b) -> b -> Tagged s a -> b Source #

foldl :: (b -> a -> b) -> b -> Tagged s a -> b Source #

foldl' :: (b -> a -> b) -> b -> Tagged s a -> b Source #

foldr1 :: (a -> a -> a) -> Tagged s a -> a Source #

foldl1 :: (a -> a -> a) -> Tagged s a -> a Source #

toList :: Tagged s a -> [a] Source #

null :: Tagged s a -> Bool Source #

length :: Tagged s a -> Int Source #

elem :: Eq a => a -> Tagged s a -> Bool Source #

maximum :: Ord a => Tagged s a -> a Source #

minimum :: Ord a => Tagged s a -> a Source #

sum :: Num a => Tagged s a -> a Source #

product :: Num a => Tagged s a -> a Source #

Traversable (Tagged s) |
Instance details Defined in Data.Tagged Methods traverse :: Applicative f => (a -> f b) -> Tagged s a -> f (Tagged s b) Source # sequenceA :: Applicative f => Tagged s (f a) -> f (Tagged s a) Source # mapM :: Monad m => (a -> m b) -> Tagged s a -> m (Tagged s b) Source # sequence :: Monad m => Tagged s (m a) -> m (Tagged s a) Source #
NFData b => NFData (Tagged s b) |
Instance details Defined in Data.Tagged Methods rnf :: Tagged s b -> () Source #
(Semigroup a, Monoid a) => Monoid (Tagged s a) |
Instance details Defined in Data.Tagged Methods mempty :: Tagged s a Source # mappend :: Tagged s a -> Tagged s a -> Tagged s a Source # mconcat :: [Tagged s a] -> Tagged s a Source #
Semigroup a => Semigroup (Tagged s a) |
Instance details Defined in Data.Tagged Methods (<>) :: Tagged s a -> Tagged s a -> Tagged s a Source # sconcat :: NonEmpty (Tagged s a) -> Tagged s a Source # stimes :: Integral b => b -> Tagged s a -> Tagged s a Source #
Bits a => Bits (Tagged s a) |

Instance details

Defined in Data.Tagged

Methods

(.&.) :: Tagged s a -> Tagged s a -> Tagged s a Source #

(.|.) :: Tagged s a -> Tagged s a -> Tagged s a Source #

xor :: Tagged s a -> Tagged s a -> Tagged s a Source #

complement :: Tagged s a -> Tagged s a Source #

shift :: Tagged s a -> Int -> Tagged s a Source #

rotate :: Tagged s a -> Int -> Tagged s a Source #

zeroBits :: Tagged s a Source #

bit :: Int -> Tagged s a Source #

setBit :: Tagged s a -> Int -> Tagged s a Source #

clearBit :: Tagged s a -> Int -> Tagged s a Source #

complementBit :: Tagged s a -> Int -> Tagged s a Source #

testBit :: Tagged s a -> Int -> Bool Source #

bitSizeMaybe :: Tagged s a -> Maybe Int Source #

bitSize :: Tagged s a -> Int Source #

isSigned :: Tagged s a -> Bool Source #

shiftL :: Tagged s a -> Int -> Tagged s a Source #

unsafeShiftL :: Tagged s a -> Int -> Tagged s a Source #

shiftR :: Tagged s a -> Int -> Tagged s a Source #

unsafeShiftR :: Tagged s a -> Int -> Tagged s a Source #

rotateL :: Tagged s a -> Int -> Tagged s a Source #

rotateR :: Tagged s a -> Int -> Tagged s a Source #

popCount :: Tagged s a -> Int Source #

FiniteBits a => FiniteBits (Tagged s a) |
Instance details Defined in Data.Tagged Methods finiteBitSize :: Tagged s a -> Int Source # countLeadingZeros :: Tagged s a -> Int Source # countTrailingZeros :: Tagged s a -> Int Source #
(Data s, Data b) => Data (Tagged s b) |

Instance details

Defined in Data.Tagged

Methods

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

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

toConstr :: Tagged s b -> Constr Source #

dataTypeOf :: Tagged s b -> DataType Source #

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

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

gmapT :: (forall b0. Data b0 => b0 -> b0) -> Tagged s b -> Tagged s b Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tagged s b -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tagged s b -> r Source #

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

gmapQi :: Int -> (forall d. Data d => d -> u) -> Tagged s b -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Tagged s b -> m (Tagged s b) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Tagged s b -> m (Tagged s b) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Tagged s b -> m (Tagged s b) Source #

IsString a => IsString (Tagged s a) |
Instance details Defined in Data.Tagged Methods fromString :: String -> Tagged s a Source #
Bounded b => Bounded (Tagged s b) |
Instance details Defined in Data.Tagged Methods minBound :: Tagged s b Source # maxBound :: Tagged s b Source #
Enum a => Enum (Tagged s a) |

Instance details

Defined in Data.Tagged

Methods

succ :: Tagged s a -> Tagged s a Source #

pred :: Tagged s a -> Tagged s a Source #

toEnum :: Int -> Tagged s a Source #

fromEnum :: Tagged s a -> Int Source #

enumFrom :: Tagged s a -> [Tagged s a] Source #

enumFromThen :: Tagged s a -> Tagged s a -> [Tagged s a] Source #

enumFromTo :: Tagged s a -> Tagged s a -> [Tagged s a] Source #

enumFromThenTo :: Tagged s a -> Tagged s a -> Tagged s a -> [Tagged s a] Source #

Floating a => Floating (Tagged s a) |

Instance details

Defined in Data.Tagged

Methods

pi :: Tagged s a Source #

exp :: Tagged s a -> Tagged s a Source #

log :: Tagged s a -> Tagged s a Source #

sqrt :: Tagged s a -> Tagged s a Source #

(**) :: Tagged s a -> Tagged s a -> Tagged s a Source #

logBase :: Tagged s a -> Tagged s a -> Tagged s a Source #

sin :: Tagged s a -> Tagged s a Source #

cos :: Tagged s a -> Tagged s a Source #

tan :: Tagged s a -> Tagged s a Source #

asin :: Tagged s a -> Tagged s a Source #

acos :: Tagged s a -> Tagged s a Source #

atan :: Tagged s a -> Tagged s a Source #

sinh :: Tagged s a -> Tagged s a Source #

cosh :: Tagged s a -> Tagged s a Source #

tanh :: Tagged s a -> Tagged s a Source #

asinh :: Tagged s a -> Tagged s a Source #

acosh :: Tagged s a -> Tagged s a Source #

atanh :: Tagged s a -> Tagged s a Source #

log1p :: Tagged s a -> Tagged s a Source #

expm1 :: Tagged s a -> Tagged s a Source #

log1pexp :: Tagged s a -> Tagged s a Source #

log1mexp :: Tagged s a -> Tagged s a Source #

RealFloat a => RealFloat (Tagged s a) |

Instance details

Defined in Data.Tagged

Methods

floatRadix :: Tagged s a -> Integer Source #

floatDigits :: Tagged s a -> Int Source #

floatRange :: Tagged s a -> (Int, Int) Source #

decodeFloat :: Tagged s a -> (Integer, Int) Source #

encodeFloat :: Integer -> Int -> Tagged s a Source #

exponent :: Tagged s a -> Int Source #

significand :: Tagged s a -> Tagged s a Source #

scaleFloat :: Int -> Tagged s a -> Tagged s a Source #

isNaN :: Tagged s a -> Bool Source #

isInfinite :: Tagged s a -> Bool Source #

isDenormalized :: Tagged s a -> Bool Source #

isNegativeZero :: Tagged s a -> Bool Source #

isIEEE :: Tagged s a -> Bool Source #

atan2 :: Tagged s a -> Tagged s a -> Tagged s a Source #

Storable a => Storable (Tagged s a) |

Instance details

Defined in Data.Tagged

Methods

sizeOf :: Tagged s a -> Int Source #

alignment :: Tagged s a -> Int Source #

peekElemOff :: Ptr (Tagged s a) -> Int -> IO (Tagged s a) Source #

pokeElemOff :: Ptr (Tagged s a) -> Int -> Tagged s a -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO (Tagged s a) Source #

pokeByteOff :: Ptr b -> Int -> Tagged s a -> IO () Source #

peek :: Ptr (Tagged s a) -> IO (Tagged s a) Source #

poke :: Ptr (Tagged s a) -> Tagged s a -> IO () Source #

Generic (Tagged s b) |

Instance details

Defined in Data.Tagged

Associated Types

type Rep (Tagged s b) |
Instance details Defined in Data.Tagged type Rep (Tagged s b) = D1 ('MetaData "Tagged" "Data.Tagged" "tagged-0.8.9-EraSdp0lx7uJnqESyrqLTP" 'True) (C1 ('MetaCons "Tagged" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTagged") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 b)))

Methods

from :: Tagged s b -> Rep (Tagged s b) x Source #

to :: Rep (Tagged s b) x -> Tagged s b Source #

Ix b => Ix (Tagged s b) |

Instance details

Defined in Data.Tagged

Methods

range :: (Tagged s b, Tagged s b) -> [Tagged s b] Source #

index :: (Tagged s b, Tagged s b) -> Tagged s b -> Int Source #

unsafeIndex :: (Tagged s b, Tagged s b) -> Tagged s b -> Int Source #

inRange :: (Tagged s b, Tagged s b) -> Tagged s b -> Bool Source #

rangeSize :: (Tagged s b, Tagged s b) -> Int Source #

unsafeRangeSize :: (Tagged s b, Tagged s b) -> Int Source #

Num a => Num (Tagged s a) |
Instance details Defined in Data.Tagged Methods (+) :: Tagged s a -> Tagged s a -> Tagged s a Source # (-) :: Tagged s a -> Tagged s a -> Tagged s a Source # (*) :: Tagged s a -> Tagged s a -> Tagged s a Source # negate :: Tagged s a -> Tagged s a Source # abs :: Tagged s a -> Tagged s a Source # signum :: Tagged s a -> Tagged s a Source # fromInteger :: Integer -> Tagged s a Source #
Read b => Read (Tagged s b) |
Instance details Defined in Data.Tagged Methods readsPrec :: Int -> ReadS (Tagged s b) Source # readList :: ReadS [Tagged s b] Source # readPrec :: ReadPrec (Tagged s b) Source # readListPrec :: ReadPrec [Tagged s b] Source #
Fractional a => Fractional (Tagged s a) |
Instance details Defined in Data.Tagged Methods (/) :: Tagged s a -> Tagged s a -> Tagged s a Source # recip :: Tagged s a -> Tagged s a Source # fromRational :: Rational -> Tagged s a Source #
Integral a => Integral (Tagged s a) |

Instance details

Defined in Data.Tagged

Methods

quot :: Tagged s a -> Tagged s a -> Tagged s a Source #

rem :: Tagged s a -> Tagged s a -> Tagged s a Source #

div :: Tagged s a -> Tagged s a -> Tagged s a Source #

mod :: Tagged s a -> Tagged s a -> Tagged s a Source #

quotRem :: Tagged s a -> Tagged s a -> (Tagged s a, Tagged s a) Source #

divMod :: Tagged s a -> Tagged s a -> (Tagged s a, Tagged s a) Source #

toInteger :: Tagged s a -> Integer Source #

Real a => Real (Tagged s a) |
Instance details Defined in Data.Tagged Methods toRational :: Tagged s a -> Rational Source #
RealFrac a => RealFrac (Tagged s a) |
Instance details Defined in Data.Tagged Methods properFraction :: Integral b => Tagged s a -> (b, Tagged s a) Source # truncate :: Integral b => Tagged s a -> b Source # round :: Integral b => Tagged s a -> b Source # ceiling :: Integral b => Tagged s a -> b Source # floor :: Integral b => Tagged s a -> b Source #
Show b => Show (Tagged s b) |
Instance details Defined in Data.Tagged Methods showsPrec :: Int -> Tagged s b -> ShowS Source # show :: Tagged s b -> String Source # showList :: [Tagged s b] -> ShowS Source #
Eq b => Eq (Tagged s b) |
Instance details Defined in Data.Tagged Methods (==) :: Tagged s b -> Tagged s b -> Bool Source # (/=) :: Tagged s b -> Tagged s b -> Bool Source #
Ord b => Ord (Tagged s b) |

Instance details

Defined in Data.Tagged

Methods

compare :: Tagged s b -> Tagged s b -> Ordering Source #

(<) :: Tagged s b -> Tagged s b -> Bool Source #

(<=) :: Tagged s b -> Tagged s b -> Bool Source #

(>) :: Tagged s b -> Tagged s b -> Bool Source #

(>=) :: Tagged s b -> Tagged s b -> Bool Source #

max :: Tagged s b -> Tagged s b -> Tagged s b Source #

min :: Tagged s b -> Tagged s b -> Tagged s b Source #

FromFormKey a => FromFormKey (Tagged b a) |
Instance details Defined in Web.Internal.FormUrlEncoded Methods parseFormKey :: Text -> Either Text (Tagged b a) Source #
ToFormKey a => ToFormKey (Tagged b a) |
Instance details Defined in Web.Internal.FormUrlEncoded Methods toFormKey :: Tagged b a -> Text 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 #
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 #
type Rep1 (Tagged s :: Type -> Type) |
Instance details Defined in Data.Tagged type Rep1 (Tagged s :: Type -> Type) = D1 ('MetaData "Tagged" "Data.Tagged" "tagged-0.8.9-EraSdp0lx7uJnqESyrqLTP" 'True) (C1 ('MetaCons "Tagged" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTagged") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
type Rep (Tagged s b) |
Instance details Defined in Data.Tagged type Rep (Tagged s b) = D1 ('MetaData "Tagged" "Data.Tagged" "tagged-0.8.9-EraSdp0lx7uJnqESyrqLTP" 'True) (C1 ('MetaCons "Tagged" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTagged") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 b)))

module Servant.Server.UVerb