servant-server-0.11: 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
  - Basic functions and datatypes
  - `Nat` utilities
  - Functions based on mmorph
- Context
  - NamedContext
- Basic Authentication
- General Authentication
- Default error type
  - 3XX
  - 4XX
  - 5XX
- Re-exports

Description

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

Synopsis

- serve :: HasServer api '[] => Proxy api -> Server api -> Application
- serveWithContext :: HasServer api context => Proxy api -> Context context -> Server api -> Application
- toApplication :: RoutingApplication -> Application
- class HasServer api context where
  - type ServerT api (m :: * -> *) :: *
- type Server api = ServerT api Handler
- data EmptyServer
- emptyServer :: ServerT EmptyAPI m
- newtype Handler a = Handler {
  - runHandler' :: ExceptT ServantErr IO a
  }
- runHandler :: Handler a -> IO (Either ServantErr a)
- layout :: HasServer api '[] => Proxy api -> Text
- layoutWithContext :: HasServer api context => Proxy api -> Context context -> Text
- enter :: Enter typ m n ret => (:~>) * m n -> typ -> ret
- newtype (k :~> f) g :: forall k. (k -> *) -> (k -> *) -> * = NT {
  - ($$) :: (~>) k f g
  }
- liftNat :: (MonadTrans t, Monad m) => (:~>) * m (t m)
- runReaderTNat :: r -> (:~>) * (ReaderT * r m) m
- evalStateTLNat :: Monad m => s -> (:~>) * (StateT s m) m
- evalStateTSNat :: Monad m => s -> (:~>) * (StateT s m) m
- logWriterTLNat :: MonadIO m => (w -> IO ()) -> (:~>) * (WriterT w m) m
- logWriterTSNat :: MonadIO m => (w -> IO ()) -> (:~>) * (WriterT w m) m
- hoistNat :: (MFunctor * t, Monad m) => (:~>) * m n -> (:~>) * (t m) (t n)
- embedNat :: (MMonad t, Monad n) => (:~>) * m (t n) -> (:~>) * (t m) (t n)
- squashNat :: (Monad m, MMonad t) => (:~>) * (t (t m)) (t m)
- generalizeNat :: Applicative m => (:~>) * Identity m
- tweakResponse :: (RouteResult Response -> RouteResult Response) -> Router env -> Router env
- data Context contextTypes where
  - EmptyContext :: Context '[]
  - (:.) :: x -> Context xs -> Context (x ': xs)
- class HasContextEntry context val where
- data NamedContext name subContext = NamedContext (Context subContext)
- descendIntoNamedContext :: forall context name subContext. HasContextEntry context (NamedContext name subContext) => Proxy (name :: Symbol) -> Context context -> Context subContext
- newtype BasicAuthCheck usr = BasicAuthCheck {
  - unBasicAuthCheck :: BasicAuthData -> IO (BasicAuthResult usr)
  }
- data BasicAuthResult usr
  - = Unauthorized
  - | BadPassword
  - | NoSuchUser
  - | Authorized usr
- data ServantErr = ServantErr {
  - errHTTPCode :: Int
  - errReasonPhrase :: String
  - errBody :: ByteString
  - errHeaders :: [Header]
  }
- err300 :: ServantErr
- err301 :: ServantErr
- err302 :: ServantErr
- err303 :: ServantErr
- err304 :: ServantErr
- err305 :: ServantErr
- err307 :: ServantErr
- err400 :: ServantErr
- err401 :: ServantErr
- err402 :: ServantErr
- err403 :: ServantErr
- err404 :: ServantErr
- err405 :: ServantErr
- err406 :: ServantErr
- err407 :: ServantErr
- err409 :: ServantErr
- err410 :: ServantErr
- err411 :: ServantErr
- err412 :: ServantErr
- err413 :: ServantErr
- err414 :: ServantErr
- err415 :: ServantErr
- err416 :: ServantErr
- err417 :: ServantErr
- err418 :: ServantErr
- err422 :: ServantErr
- err500 :: ServantErr
- err501 :: ServantErr
- err502 :: ServantErr
- err503 :: ServantErr
- err504 :: ServantErr
- err505 :: ServantErr
- type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived
- newtype Tagged k s b :: forall k. k -> * -> * = Tagged {
  - unTagged :: b
  }

# Run a wai application from an API

serve :: HasServer api '[] => Proxy api -> Server api -> Application #

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

Example:

    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 = ...

    myApi :: Proxy MyApi
    myApi = Proxy

    app :: Application
    app = serve myApi server

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

serveWithContext :: HasServer api context => Proxy api -> Context context -> Server api -> Application #

# Construct a wai Application from an API

toApplication :: RoutingApplication -> Application #

# Handlers for all standard combinators

class HasServer api context where #

Minimal complete definition

route

Associated Types

type ServerT api (m :: * -> *) :: * #

Methods

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

Instances

HasServer * EmptyAPI context # | The server for an `EmptyAPI` is `emptyAPIServer`.
    type MyApi = "nothing" :> EmptyApi

    server :: Server MyApi
    server = emptyAPIServer
Associated Types type ServerT EmptyAPI (context :: EmptyAPI) (m :: * -> *) :: * # Methods route :: Proxy EmptyAPI context -> Context context -> Delayed env (Server EmptyAPI context) -> Router env #
HasServer * Raw context # | 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"
Associated Types type ServerT Raw (context :: Raw) (m :: * -> *) :: * # Methods route :: Proxy Raw context -> Context context -> Delayed env (Server Raw context) -> Router env #
(HasServer * a context, HasServer * b context) => HasServer * ((:<|>) a b) context # | 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 = ...
Associated Types type ServerT ((:<|>) a b) (context :: (:<|>) a b) (m :: * -> *) :: * # Methods route :: Proxy (a :<|> b) context -> Context context -> Delayed env (Server (a :<|> b) context) -> Router env #
(HasContextEntry context (NamedContext name subContext), HasServer * subApi subContext) => HasServer * (WithNamedContext name subContext subApi) context # |
Associated Types type ServerT (WithNamedContext name subContext subApi) (context :: WithNamedContext name subContext subApi) (m :: * -> *) :: * # Methods route :: Proxy (WithNamedContext name subContext subApi) context -> Context context -> Delayed env (Server (WithNamedContext name subContext subApi) context) -> Router env #
(KnownSymbol realm, HasServer k api context, HasContextEntry context (BasicAuthCheck usr)) => HasServer * ((:>) k * (BasicAuth realm usr) api) context # | Basic Authentication
Associated Types type ServerT ((:>) k * (BasicAuth realm usr) api) (context :: (:>) k * (BasicAuth realm usr) api) (m :: * -> *) :: * # Methods route :: Proxy ((k :> *) (BasicAuth realm usr) api) context -> Context context -> Delayed env (Server ((k :> *) (BasicAuth realm usr) api) context) -> Router env #
HasServer k api context => HasServer * ((:>) k * HttpVersion api) context # |
Associated Types type ServerT ((:>) k * HttpVersion api) (context :: (:>) k * HttpVersion api) (m :: * -> *) :: * # Methods route :: Proxy ((k :> *) HttpVersion api) context -> Context context -> Delayed env (Server ((k :> *) HttpVersion api) context) -> Router env #
HasServer k api context => HasServer * ((:>) k * Vault api) context # |
Associated Types type ServerT ((:>) k * Vault api) (context :: (:>) k * Vault api) (m :: * -> *) :: * # Methods route :: Proxy ((k :> *) Vault api) context -> Context context -> Delayed env (Server ((k :> *) Vault api) context) -> Router env #
HasServer k api context => HasServer * ((:>) k * IsSecure api) context # |
Associated Types type ServerT ((:>) k * IsSecure api) (context :: (:>) k * IsSecure api) (m :: * -> *) :: * # Methods route :: Proxy ((k :> *) IsSecure api) context -> Context context -> Delayed env (Server ((k :> *) IsSecure api) context) -> Router env #
HasServer k api context => HasServer * ((:>) k * RemoteHost api) context # |
Associated Types type ServerT ((:>) k * RemoteHost api) (context :: (:>) k * RemoteHost api) (m :: * -> *) :: * # Methods route :: Proxy ((k :> *) RemoteHost api) context -> Context context -> Delayed env (Server ((k :> *) RemoteHost api) context) -> Router env #
(KnownSymbol path, HasServer k api context) => HasServer * ((:>) k Symbol path api) context # | Make sure the incoming request starts with `"/path"`, strip it and pass the rest of the request path to `api`.
Associated Types type ServerT ((:>) k Symbol path api) (context :: (:>) k Symbol path api) (m :: * -> *) :: * # Methods route :: Proxy ((k :> Symbol) path api) context -> Context context -> Delayed env (Server ((k :> Symbol) path api) context) -> Router env #
(AllCTUnrender list a, HasServer k api context) => HasServer * ((:>) k * (ReqBody * list a) api) context # | 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 RFC7231. 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...
Associated Types type ServerT ((:>) k * (ReqBody * list a) api) (context :: (:>) k * (ReqBody * list a) api) (m :: * -> *) :: * # Methods route :: Proxy ((k :> *) (ReqBody * list a) api) context -> Context context -> Delayed env (Server ((k :> *) (ReqBody * list a) api) context) -> Router env #
(KnownSymbol sym, HasServer k api context) => HasServer * ((:>) k * (QueryFlag sym) api) context # | 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...
Associated Types type ServerT ((:>) k * (QueryFlag sym) api) (context :: (:>) k * (QueryFlag sym) api) (m :: * -> *) :: * # Methods route :: Proxy ((k :> *) (QueryFlag sym) api) context -> Context context -> Delayed env (Server ((k :> *) (QueryFlag sym) api) context) -> Router env #
(KnownSymbol sym, FromHttpApiData a, HasServer k api context) => HasServer * ((:>) k * (QueryParams * sym a) api) context # | 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...
Associated Types type ServerT ((:>) k * (QueryParams * sym a) api) (context :: (:>) k * (QueryParams * sym a) api) (m :: * -> *) :: * # Methods route :: Proxy ((k :> *) (QueryParams * sym a) api) context -> Context context -> Delayed env (Server ((k :> *) (QueryParams * sym a) api) context) -> Router env #
(KnownSymbol sym, FromHttpApiData a, HasServer k api context) => HasServer * ((:>) k * (QueryParam * sym a) api) context # | 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...
Associated Types type ServerT ((:>) k * (QueryParam * sym a) api) (context :: (:>) k * (QueryParam * sym a) api) (m :: * -> *) :: * # Methods route :: Proxy ((k :> *) (QueryParam * sym a) api) context -> Context context -> Delayed env (Server ((k :> *) (QueryParam * sym a) api) context) -> Router env #
(KnownSymbol sym, FromHttpApiData a, HasServer k api context) => HasServer * ((:>) k * (Header sym a) api) context # | 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
Associated Types type ServerT ((:>) k * (Header sym a) api) (context :: (:>) k * (Header sym a) api) (m :: * -> *) :: * # Methods route :: Proxy ((k :> *) (Header sym a) api) context -> Context context -> Delayed env (Server ((k :> *) (Header sym a) api) context) -> Router env #
(KnownSymbol capture, FromHttpApiData a, HasServer k sublayout context) => HasServer * ((:>) k * (CaptureAll * capture a) sublayout) context # | 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 = ...
Associated Types type ServerT ((:>) k * (CaptureAll * capture a) sublayout) (context :: (:>) k * (CaptureAll * capture a) sublayout) (m :: * -> *) :: * # Methods route :: Proxy ((k :> *) (CaptureAll * capture a) sublayout) context -> Context context -> Delayed env (Server ((k :> *) (CaptureAll * capture a) sublayout) context) -> Router env #
(KnownSymbol capture, FromHttpApiData a, HasServer k api context) => HasServer * ((:>) k * (Capture * capture a) api) context # | 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 = ...
Associated Types type ServerT ((:>) k * (Capture * capture a) api) (context :: (:>) k * (Capture * capture a) api) (m :: * -> *) :: * # Methods route :: Proxy ((k :> *) (Capture * capture a) api) context -> Context context -> Delayed env (Server ((k :> *) (Capture * capture a) api) context) -> Router env #
(AllCTRender ctypes a, ReflectMethod k1 method, KnownNat status, GetHeaders (Headers h a)) => HasServer * (Verb * k1 method status ctypes (Headers h a)) context # |
Associated Types type ServerT (Verb * k1 method status ctypes (Headers h a)) (context :: Verb * k1 method status ctypes (Headers h a)) (m :: * -> *) :: * # Methods route :: Proxy (Verb * k1 method status ctypes (Headers h a)) context -> Context context -> Delayed env (Server (Verb * k1 method status ctypes (Headers h a)) context) -> Router env #
(AllCTRender ctypes a, ReflectMethod k1 method, KnownNat status) => HasServer * (Verb * k1 method status ctypes a) context # |
Associated Types type ServerT (Verb * k1 method status ctypes a) (context :: Verb * k1 method status ctypes a) (m :: * -> *) :: * # Methods route :: Proxy (Verb * k1 method status ctypes a) context -> Context context -> Delayed env (Server (Verb * k1 method status ctypes a) context) -> Router env #

type Server api = ServerT api Handler #

data EmptyServer #

Singleton type representing a server that serves an empty API.

Instances

Bounded EmptyServer # |
Methods minBound :: EmptyServer # maxBound :: EmptyServer #
Enum EmptyServer # |
Methods succ :: EmptyServer -> EmptyServer # pred :: EmptyServer -> EmptyServer # toEnum :: Int -> EmptyServer # fromEnum :: EmptyServer -> Int # enumFrom :: EmptyServer -> [EmptyServer] # enumFromThen :: EmptyServer -> EmptyServer -> [EmptyServer] # enumFromTo :: EmptyServer -> EmptyServer -> [EmptyServer] # enumFromThenTo :: EmptyServer -> EmptyServer -> EmptyServer -> [EmptyServer] #
Eq EmptyServer # |
Methods (==) :: EmptyServer -> EmptyServer -> Bool # (/=) :: EmptyServer -> EmptyServer -> Bool #
Show EmptyServer # |
Methods showsPrec :: Int -> EmptyServer -> ShowS # show :: EmptyServer -> String # showList :: [EmptyServer] -> ShowS #

emptyServer :: ServerT EmptyAPI m #

Server for `EmptyAPI`

newtype Handler a #

Constructors

Handler |
Fields runHandler' :: ExceptT ServantErr IO a

Instances

Monad Handler # |
Methods (>>=) :: Handler a -> (a -> Handler b) -> Handler b # (>>) :: Handler a -> Handler b -> Handler b # return :: a -> Handler a # fail :: String -> Handler a #
Functor Handler # |
Methods fmap :: (a -> b) -> Handler a -> Handler b # (<$) :: a -> Handler b -> Handler a #
Applicative Handler # |
Methods pure :: a -> Handler a # (<*>) :: Handler (a -> b) -> Handler a -> Handler b # (*>) :: Handler a -> Handler b -> Handler b # (<*) :: Handler a -> Handler b -> Handler a #
MonadIO Handler # |
Methods liftIO :: IO a -> Handler a #
MonadThrow Handler # |
Methods throwM :: Exception e => e -> Handler a #
MonadCatch Handler # |
Methods catch :: Exception e => Handler a -> (e -> Handler a) -> Handler a #
MonadBase IO Handler # |
Methods liftBase :: IO α -> Handler α #
MonadBaseControl IO Handler # |
Associated Types type StM (Handler :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase Handler IO -> IO a) -> Handler a # restoreM :: StM Handler a -> Handler a #
MonadError ServantErr Handler # |
Methods throwError :: ServantErr -> Handler a # catchError :: Handler a -> (ServantErr -> Handler a) -> Handler a #
Generic (Handler a) # |
Associated Types type Rep (Handler a) :: * -> * # Methods from :: Handler a -> Rep (Handler a) x # to :: Rep (Handler a) x -> Handler a #
type StM Handler a # |
type StM Handler a = Either ServantErr a
type Rep (Handler a) # |
type Rep (Handler a) = D1 (MetaData "Handler" "Servant.Server.Internal.Handler" "servant-server-0.11-IADlUM83Uj7GUOFTlU9US9" True) (C1 (MetaCons "Handler" PrefixI True) (S1 (MetaSel (Just Symbol "runHandler'") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (ExceptT ServantErr IO a))))

runHandler :: Handler a -> IO (Either ServantErr a) #

# Debugging the server layout

layout :: HasServer api '[] => Proxy api -> Text #

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/
    │  └─ <capture>/
    │     ├─•
    │     ┆
    │     └─•
    ├─ c/
    │  └─•
    ┆
    └─ <raw>

Explanation of symbols:

`├`
  Normal lines reflect static branching via a table.
`a/`
  Nodes reflect static path components.
`─•`
  Leaves reflect endpoints.
`<capture>/`
  This is a delayed capture of a path component.
`<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 :: HasServer api context => Proxy api -> Context context -> Text #

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

# Enter

Sometimes our cherished `ExceptT` 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. Enter `enter`.

With `enter`, you can provide a function, wrapped in the `(:~>)` / `NT` newtype, 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
    >>> import qualified Control.Category as C
    >>> type ReaderAPI = "ep1" :> Get '[JSON] Int :<|> "ep2" :> Get '[JSON] String :<|> Raw :<|> EmptyAPI
    >>> let readerServer = return 1797 :<|> ask :<|> Tagged (error "raw server") :<|> emptyServer :: ServerT ReaderAPI (Reader String)
    >>> let nt = generalizeNat C.. (runReaderTNat "hi") :: Reader String :~> Handler
    >>> let mainServer = enter nt readerServer :: Server ReaderAPI

## Basic functions and datatypes

enter :: Enter typ m n ret => (:~>) * m n -> typ -> ret #

Map the leafs of an API type.

newtype (k :~> f) g :: forall k. (k -> *) -> (k -> *) -> * infixr 0 #

A natural transformation suitable for storing in a container.

Constructors

NT |
Fields ($$) :: (~>) k f g

Instances

Transformation k f g ((:~>) k f g) |
Methods (#) :: t -> forall a. g a -> (k :~> f) g a #
Category (k -> *) ((:~>) k) |
Methods id :: cat a a # (.) :: cat b c -> cat a b -> cat a c #
(~) (k -> *) f g => Semigroup ((:~>) k f g) |
Methods (<>) :: (k :~> f) g -> (k :~> f) g -> (k :~> f) g # sconcat :: NonEmpty ((k :~> f) g) -> (k :~> f) g # stimes :: Integral b => b -> (k :~> f) g -> (k :~> f) g #
(~) (k -> *) f g => Monoid ((:~>) k f g) |
Methods mempty :: (k :~> f) g # mappend :: (k :~> f) g -> (k :~> f) g -> (k :~> f) g # mconcat :: [(k :~> f) g] -> (k :~> f) g #

## `Nat` utilities

liftNat :: (MonadTrans t, Monad m) => (:~>) * m (t m) #

Like `lift`.

runReaderTNat :: r -> (:~>) * (ReaderT * r m) m #

evalStateTLNat :: Monad m => s -> (:~>) * (StateT s m) m #

evalStateTSNat :: Monad m => s -> (:~>) * (StateT s m) m #

logWriterTLNat :: MonadIO m => (w -> IO ()) -> (:~>) * (WriterT w m) m #

Like `logWriterTSNat`, but for lazy `WriterT`.

logWriterTSNat :: MonadIO m => (w -> IO ()) -> (:~>) * (WriterT w m) m #

Log the contents of `WriterT` with the function provided as the first argument, and return the value of the `WriterT` computation

## Functions based on mmorph

hoistNat :: (MFunctor * t, Monad m) => (:~>) * m n -> (:~>) * (t m) (t n) #

Like `mmorph`'s `hoist`.

embedNat :: (MMonad t, Monad n) => (:~>) * m (t n) -> (:~>) * (t m) (t n) #

Like `mmorph`'s `embed`.

squashNat :: (Monad m, MMonad t) => (:~>) * (t (t m)) (t m) #

Like `mmorph`'s `squash`.

generalizeNat :: Applicative m => (:~>) * Identity m #

Like `mmorph`'s `generalize`.

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

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

# Context

data Context contextTypes where #

`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 `Enter`.) 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 heterogenous 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 '[] |
(:.) :: x -> Context xs -> Context (x ': xs) infixr 5 |

Instances

(Eq a, Eq (Context as)) => Eq (Context ((:) * a as)) # |
Methods (==) :: Context ((* ': a) as) -> Context ((* ': a) as) -> Bool # (/=) :: Context ((* ': a) as) -> Context ((* ': a) as) -> Bool #
Eq (Context ([] *)) # |
Methods (==) :: Context [*] -> Context [*] -> Bool # (/=) :: Context [*] -> Context [*] -> Bool #
(Show a, Show (Context as)) => Show (Context ((:) * a as)) # |
Methods showsPrec :: Int -> Context ((* ': a) as) -> ShowS # show :: Context ((* ': a) as) -> String # showList :: [Context ((* ': a) as)] -> ShowS #
Show (Context ([] *)) # |
Methods showsPrec :: Int -> Context [*] -> ShowS # show :: Context [*] -> String # showList :: [Context [*]] -> ShowS #

class HasContextEntry context val where #

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])
    ...

Minimal complete definition

getContextEntry

Methods

getContextEntry :: Context context -> val #

Instances

HasContextEntry ((:) * val xs) val # |
Methods getContextEntry :: Context ((* ': val) xs) -> val #
HasContextEntry xs val => HasContextEntry ((:) * notIt xs) val # |
Methods getContextEntry :: Context ((* ': notIt) xs) -> val #

## NamedContext

data NamedContext name subContext #

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 name subContext. HasContextEntry context (NamedContext name subContext) => Proxy (name :: Symbol) -> Context context -> Context subContext #

`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 #

Datatype wrapping a function used to check authentication.

Constructors

BasicAuthCheck |
Fields unBasicAuthCheck :: BasicAuthData -> IO (BasicAuthResult usr)

Instances

Functor BasicAuthCheck # |
Methods fmap :: (a -> b) -> BasicAuthCheck a -> BasicAuthCheck b # (<$) :: a -> BasicAuthCheck b -> BasicAuthCheck a #
Generic (BasicAuthCheck usr) # |
Associated Types type Rep (BasicAuthCheck usr) :: * -> * # Methods from :: BasicAuthCheck usr -> Rep (BasicAuthCheck usr) x # to :: Rep (BasicAuthCheck usr) x -> BasicAuthCheck usr #
type Rep (BasicAuthCheck usr) # |
type Rep (BasicAuthCheck usr) = D1 (MetaData "BasicAuthCheck" "Servant.Server.Internal.BasicAuth" "servant-server-0.11-IADlUM83Uj7GUOFTlU9US9" True) (C1 (MetaCons "BasicAuthCheck" PrefixI True) (S1 (MetaSel (Just Symbol "unBasicAuthCheck") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (BasicAuthData -> IO (BasicAuthResult usr)))))

data BasicAuthResult usr #

servant-server's current implementation of basic authentication is not immune to certian 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

Functor BasicAuthResult # |
Methods fmap :: (a -> b) -> BasicAuthResult a -> BasicAuthResult b # (<$) :: a -> BasicAuthResult b -> BasicAuthResult a #
Eq usr => Eq (BasicAuthResult usr) # |
Methods (==) :: BasicAuthResult usr -> BasicAuthResult usr -> Bool # (/=) :: BasicAuthResult usr -> BasicAuthResult usr -> Bool #
Read usr => Read (BasicAuthResult usr) # |
Methods readsPrec :: Int -> ReadS (BasicAuthResult usr) # readList :: ReadS [BasicAuthResult usr] # readPrec :: ReadPrec (BasicAuthResult usr) # readListPrec :: ReadPrec [BasicAuthResult usr] #
Show usr => Show (BasicAuthResult usr) # |
Methods showsPrec :: Int -> BasicAuthResult usr -> ShowS # show :: BasicAuthResult usr -> String # showList :: [BasicAuthResult usr] -> ShowS #
Generic (BasicAuthResult usr) # |
Associated Types type Rep (BasicAuthResult usr) :: * -> * # Methods from :: BasicAuthResult usr -> Rep (BasicAuthResult usr) x # to :: Rep (BasicAuthResult usr) x -> BasicAuthResult usr #
type Rep (BasicAuthResult usr) # |
type Rep (BasicAuthResult usr) = D1 (MetaData "BasicAuthResult" "Servant.Server.Internal.BasicAuth" "servant-server-0.11-IADlUM83Uj7GUOFTlU9US9" False) ((:+:) ((:+:) (C1 (MetaCons "Unauthorized" PrefixI False) U1) (C1 (MetaCons "BadPassword" PrefixI False) U1)) ((:+:) (C1 (MetaCons "NoSuchUser" PrefixI False) U1) (C1 (MetaCons "Authorized" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 usr)))))

# General Authentication

# Default error type

data ServantErr #

Constructors

ServantErr |
Fields errHTTPCode :: Int errReasonPhrase :: String errBody :: ByteString errHeaders :: [Header]

Instances

Eq ServantErr # |
Methods (==) :: ServantErr -> ServantErr -> Bool # (/=) :: ServantErr -> ServantErr -> Bool #
Read ServantErr # |
Methods readsPrec :: Int -> ReadS ServantErr # readList :: ReadS [ServantErr] # readPrec :: ReadPrec ServantErr # readListPrec :: ReadPrec [ServantErr] #
Show ServantErr # |
Methods showsPrec :: Int -> ServantErr -> ShowS # show :: ServantErr -> String # showList :: [ServantErr] -> ShowS #
Exception ServantErr # |
Methods toException :: ServantErr -> SomeException # fromException :: SomeException -> Maybe ServantErr # displayException :: ServantErr -> String #
MonadError ServantErr Handler # |
Methods throwError :: ServantErr -> Handler a # catchError :: Handler a -> (ServantErr -> Handler a) -> Handler a #

## 3XX

err300 :: ServantErr #

`err300` Multiple Choices

Example:

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

err301 :: ServantErr #

`err301` Moved Permanently

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err301

err302 :: ServantErr #

`err302` Found

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err302

err303 :: ServantErr #

`err303` See Other

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err303

err304 :: ServantErr #

`err304` Not Modified

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err304

err305 :: ServantErr #

`err305` Use Proxy

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err305

err307 :: ServantErr #

`err307` Temporary Redirect

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err307

## 4XX

err400 :: ServantErr #

`err400` Bad Request

Example:

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

err401 :: ServantErr #

`err401` Unauthorized

Example:

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

err402 :: ServantErr #

`err402` Payment Required

Example:

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

err403 :: ServantErr #

`err403` Forbidden

Example:

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

err404 :: ServantErr #

`err404` Not Found

Example:

    failingHandler :: Handler ()
    failingHandler = throwError $ err404 { errBody = "(╯°□°）╯︵ ┻━┻)." }

err405 :: ServantErr #

`err405` Method Not Allowed

Example:

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

err406 :: ServantErr #

`err406` Not Acceptable

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err406

err407 :: ServantErr #

`err407` Proxy Authentication Required

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err407

err409 :: ServantErr #

`err409` Conflict

Example:

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

err410 :: ServantErr #

`err410` Gone

Example:

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

err411 :: ServantErr #

`err411` Length Required

Example:

    failingHandler :: Handler ()
    failingHandler = throwError err411

err412 :: ServantErr #

`err412` Precondition Failed

Example:

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

err413 :: ServantErr #

`err413` Request Entity Too Large

Example:

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

err414 :: ServantErr #

`err414` Request-URI Too Large

Example:

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

err415 :: ServantErr #

`err415` Unsupported Media Type

Example:

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

err416 :: ServantErr #

`err416` Request range not satisfiable

Example:

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

err417 :: ServantErr #

`err417` Expectation Failed

Example:

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

err418 :: ServantErr #

`err418` Expectation Failed

Example:

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

err422 :: ServantErr #

`err422` Unprocessable Entity

Example:

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

## 5XX

err500 :: ServantErr #

`err500` Internal Server Error

Example:

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

err501 :: ServantErr #

`err501` Not Implemented

Example:

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

err502 :: ServantErr #

`err502` Bad Gateway

Example:

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

err503 :: ServantErr #

`err503` Service Unavailable

Example:

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

err504 :: ServantErr #

`err504` Gateway Time-out

Example:

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

err505 :: ServantErr #

`err505` HTTP Version not supported

Example usage:

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

# Re-exports

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

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 k s b :: forall k. k -> * -> * #

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

Eq2 (Tagged *) |
Methods liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> Tagged * a c -> Tagged * b d -> Bool #
Ord2 (Tagged *) |
Methods liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> Tagged * a c -> Tagged * b d -> Ordering #
Read2 (Tagged *) |
Methods liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (Tagged * a b) # liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Tagged * a b] #
Show2 (Tagged *) |
Methods liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> Tagged * a b -> ShowS # liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [Tagged * a b] -> ShowS #
Bifunctor (Tagged *) |
Methods bimap :: (a -> b) -> (c -> d) -> Tagged * a c -> Tagged * b d # first :: (a -> b) -> Tagged * a c -> Tagged * b c # second :: (b -> c) -> Tagged * a b -> Tagged * a c #
Monad (Tagged k s) |
Methods (>>=) :: Tagged k s a -> (a -> Tagged k s b) -> Tagged k s b # (>>) :: Tagged k s a -> Tagged k s b -> Tagged k s b # return :: a -> Tagged k s a # fail :: String -> Tagged k s a #
Functor (Tagged k s) |
Methods fmap :: (a -> b) -> Tagged k s a -> Tagged k s b # (<$) :: a -> Tagged k s b -> Tagged k s a #
Applicative (Tagged k s) |
Methods pure :: a -> Tagged k s a # (<*>) :: Tagged k s (a -> b) -> Tagged k s a -> Tagged k s b # (*>) :: Tagged k s a -> Tagged k s b -> Tagged k s b # (<*) :: Tagged k s a -> Tagged k s b -> Tagged k s a #
Foldable (Tagged k s) |
Methods fold :: Monoid m => Tagged k s m -> m # foldMap :: Monoid m => (a -> m) -> Tagged k s a -> m # foldr :: (a -> b -> b) -> b -> Tagged k s a -> b # foldr' :: (a -> b -> b) -> b -> Tagged k s a -> b # foldl :: (b -> a -> b) -> b -> Tagged k s a -> b # foldl' :: (b -> a -> b) -> b -> Tagged k s a -> b # foldr1 :: (a -> a -> a) -> Tagged k s a -> a # foldl1 :: (a -> a -> a) -> Tagged k s a -> a # toList :: Tagged k s a -> [a] # null :: Tagged k s a -> Bool # length :: Tagged k s a -> Int # elem :: Eq a => a -> Tagged k s a -> Bool # maximum :: Ord a => Tagged k s a -> a # minimum :: Ord a => Tagged k s a -> a # sum :: Num a => Tagged k s a -> a # product :: Num a => Tagged k s a -> a #
Traversable (Tagged k s) |
Methods traverse :: Applicative f => (a -> f b) -> Tagged k s a -> f (Tagged k s b) # sequenceA :: Applicative f => Tagged k s (f a) -> f (Tagged k s a) # mapM :: Monad m => (a -> m b) -> Tagged k s a -> m (Tagged k s b) # sequence :: Monad m => Tagged k s (m a) -> m (Tagged k s a) #
Generic1 (Tagged k s) |
Associated Types type Rep1 (Tagged k s :: * -> *) :: * -> * # Methods from1 :: Tagged k s a -> Rep1 (Tagged k s) a # to1 :: Rep1 (Tagged k s) a -> Tagged k s a #
Eq1 (Tagged k s) |
Methods liftEq :: (a -> b -> Bool) -> Tagged k s a -> Tagged k s b -> Bool #
Ord1 (Tagged k s) |
Methods liftCompare :: (a -> b -> Ordering) -> Tagged k s a -> Tagged k s b -> Ordering #
Read1 (Tagged k s) |
Methods liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Tagged k s a) # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Tagged k s a] #
Show1 (Tagged k s) |
Methods liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Tagged k s a -> ShowS # liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Tagged k s a] -> ShowS #
Bounded b => Bounded (Tagged k s b) |
Methods minBound :: Tagged k s b # maxBound :: Tagged k s b #
Enum a => Enum (Tagged k s a) |
Methods succ :: Tagged k s a -> Tagged k s a # pred :: Tagged k s a -> Tagged k s a # toEnum :: Int -> Tagged k s a # fromEnum :: Tagged k s a -> Int # enumFrom :: Tagged k s a -> [Tagged k s a] # enumFromThen :: Tagged k s a -> Tagged k s a -> [Tagged k s a] # enumFromTo :: Tagged k s a -> Tagged k s a -> [Tagged k s a] # enumFromThenTo :: Tagged k s a -> Tagged k s a -> Tagged k s a -> [Tagged k s a] #
Eq b => Eq (Tagged k s b) |
Methods (==) :: Tagged k s b -> Tagged k s b -> Bool # (/=) :: Tagged k s b -> Tagged k s b -> Bool #
Floating a => Floating (Tagged k s a) |
Methods pi :: Tagged k s a # exp :: Tagged k s a -> Tagged k s a # log :: Tagged k s a -> Tagged k s a # sqrt :: Tagged k s a -> Tagged k s a # (**) :: Tagged k s a -> Tagged k s a -> Tagged k s a # logBase :: Tagged k s a -> Tagged k s a -> Tagged k s a # sin :: Tagged k s a -> Tagged k s a # cos :: Tagged k s a -> Tagged k s a # tan :: Tagged k s a -> Tagged k s a # asin :: Tagged k s a -> Tagged k s a # acos :: Tagged k s a -> Tagged k s a # atan :: Tagged k s a -> Tagged k s a # sinh :: Tagged k s a -> Tagged k s a # cosh :: Tagged k s a -> Tagged k s a # tanh :: Tagged k s a -> Tagged k s a # asinh :: Tagged k s a -> Tagged k s a # acosh :: Tagged k s a -> Tagged k s a # atanh :: Tagged k s a -> Tagged k s a # log1p :: Tagged k s a -> Tagged k s a # expm1 :: Tagged k s a -> Tagged k s a # log1pexp :: Tagged k s a -> Tagged k s a # log1mexp :: Tagged k s a -> Tagged k s a #
Fractional a => Fractional (Tagged k s a) |
Methods (/) :: Tagged k s a -> Tagged k s a -> Tagged k s a # recip :: Tagged k s a -> Tagged k s a # fromRational :: Rational -> Tagged k s a #
Integral a => Integral (Tagged k s a) |
Methods quot :: Tagged k s a -> Tagged k s a -> Tagged k s a # rem :: Tagged k s a -> Tagged k s a -> Tagged k s a # div :: Tagged k s a -> Tagged k s a -> Tagged k s a # mod :: Tagged k s a -> Tagged k s a -> Tagged k s a # quotRem :: Tagged k s a -> Tagged k s a -> (Tagged k s a, Tagged k s a) # divMod :: Tagged k s a -> Tagged k s a -> (Tagged k s a, Tagged k s a) # toInteger :: Tagged k s a -> Integer #
(Data s, Data b) => Data (Tagged * s b) |
Methods gfoldl :: (forall d a. Data d => c (d -> a) -> d -> c a) -> (forall g. g -> c g) -> Tagged * s b -> c (Tagged * s b) # gunfold :: (forall a r. Data a => c (a -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Tagged * s b) # toConstr :: Tagged * s b -> Constr # dataTypeOf :: Tagged * s b -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (Tagged * s b)) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Tagged * s b)) # gmapT :: (forall a. Data a => a -> a) -> Tagged * s b -> Tagged * s b # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tagged * s b -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tagged * s b -> r # gmapQ :: (forall d. Data d => d -> u) -> Tagged * s b -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Tagged * s b -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Tagged * s b -> m (Tagged * s b) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Tagged * s b -> m (Tagged * s b) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Tagged * s b -> m (Tagged * s b) #
Num a => Num (Tagged k s a) |
Methods (+) :: Tagged k s a -> Tagged k s a -> Tagged k s a # (-) :: Tagged k s a -> Tagged k s a -> Tagged k s a # (*) :: Tagged k s a -> Tagged k s a -> Tagged k s a # negate :: Tagged k s a -> Tagged k s a # abs :: Tagged k s a -> Tagged k s a # signum :: Tagged k s a -> Tagged k s a # fromInteger :: Integer -> Tagged k s a #
Ord b => Ord (Tagged k s b) |
Methods compare :: Tagged k s b -> Tagged k s b -> Ordering # (<) :: Tagged k s b -> Tagged k s b -> Bool # (<=) :: Tagged k s b -> Tagged k s b -> Bool # (>) :: Tagged k s b -> Tagged k s b -> Bool # (>=) :: Tagged k s b -> Tagged k s b -> Bool # max :: Tagged k s b -> Tagged k s b -> Tagged k s b # min :: Tagged k s b -> Tagged k s b -> Tagged k s b #
Read b => Read (Tagged k s b) |
Methods readsPrec :: Int -> ReadS (Tagged k s b) # readList :: ReadS [Tagged k s b] # readPrec :: ReadPrec (Tagged k s b) # readListPrec :: ReadPrec [Tagged k s b] #
Real a => Real (Tagged k s a) |
Methods toRational :: Tagged k s a -> Rational #
RealFloat a => RealFloat (Tagged k s a) |
Methods floatRadix :: Tagged k s a -> Integer # floatDigits :: Tagged k s a -> Int # floatRange :: Tagged k s a -> (Int, Int) # decodeFloat :: Tagged k s a -> (Integer, Int) # encodeFloat :: Integer -> Int -> Tagged k s a # exponent :: Tagged k s a -> Int # significand :: Tagged k s a -> Tagged k s a # scaleFloat :: Int -> Tagged k s a -> Tagged k s a # isNaN :: Tagged k s a -> Bool # isInfinite :: Tagged k s a -> Bool # isDenormalized :: Tagged k s a -> Bool # isNegativeZero :: Tagged k s a -> Bool # isIEEE :: Tagged k s a -> Bool # atan2 :: Tagged k s a -> Tagged k s a -> Tagged k s a #
RealFrac a => RealFrac (Tagged k s a) |
Methods properFraction :: Integral b => Tagged k s a -> (b, Tagged k s a) # truncate :: Integral b => Tagged k s a -> b # round :: Integral b => Tagged k s a -> b # ceiling :: Integral b => Tagged k s a -> b # floor :: Integral b => Tagged k s a -> b #
Show b => Show (Tagged k s b) |
Methods showsPrec :: Int -> Tagged k s b -> ShowS # show :: Tagged k s b -> String # showList :: [Tagged k s b] -> ShowS #
Ix b => Ix (Tagged k s b) |
Methods range :: (Tagged k s b, Tagged k s b) -> [Tagged k s b] # index :: (Tagged k s b, Tagged k s b) -> Tagged k s b -> Int # unsafeIndex :: (Tagged k s b, Tagged k s b) -> Tagged k s b -> Int inRange :: (Tagged k s b, Tagged k s b) -> Tagged k s b -> Bool # rangeSize :: (Tagged k s b, Tagged k s b) -> Int # unsafeRangeSize :: (Tagged k s b, Tagged k s b) -> Int
IsString a => IsString (Tagged k s a) |
Methods fromString :: String -> Tagged k s a #
Generic (Tagged k s b) |
Associated Types type Rep (Tagged k s b) :: * -> * # Methods from :: Tagged k s b -> Rep (Tagged k s b) x # to :: Rep (Tagged k s b) x -> Tagged k s b #
Semigroup a => Semigroup (Tagged k s a) |
Methods (<>) :: Tagged k s a -> Tagged k s a -> Tagged k s a # sconcat :: NonEmpty (Tagged k s a) -> Tagged k s a # stimes :: Integral b => b -> Tagged k s a -> Tagged k s a #
(Semigroup a, Monoid a) => Monoid (Tagged k s a) |
Methods mempty :: Tagged k s a # mappend :: Tagged k s a -> Tagged k s a -> Tagged k s a # mconcat :: [Tagged k s a] -> Tagged k s a #
Storable a => Storable (Tagged k s a) |
Methods sizeOf :: Tagged k s a -> Int # alignment :: Tagged k s a -> Int # peekElemOff :: Ptr (Tagged k s a) -> Int -> IO (Tagged k s a) # pokeElemOff :: Ptr (Tagged k s a) -> Int -> Tagged k s a -> IO () # peekByteOff :: Ptr b -> Int -> IO (Tagged k s a) # pokeByteOff :: Ptr b -> Int -> Tagged k s a -> IO () # peek :: Ptr (Tagged k s a) -> IO (Tagged k s a) # poke :: Ptr (Tagged k s a) -> Tagged k s a -> IO () #
Bits a => Bits (Tagged k s a) |
Methods (.&.) :: Tagged k s a -> Tagged k s a -> Tagged k s a # (.|.) :: Tagged k s a -> Tagged k s a -> Tagged k s a # xor :: Tagged k s a -> Tagged k s a -> Tagged k s a # complement :: Tagged k s a -> Tagged k s a # shift :: Tagged k s a -> Int -> Tagged k s a # rotate :: Tagged k s a -> Int -> Tagged k s a # zeroBits :: Tagged k s a # bit :: Int -> Tagged k s a # setBit :: Tagged k s a -> Int -> Tagged k s a # clearBit :: Tagged k s a -> Int -> Tagged k s a # complementBit :: Tagged k s a -> Int -> Tagged k s a # testBit :: Tagged k s a -> Int -> Bool # bitSizeMaybe :: Tagged k s a -> Maybe Int # bitSize :: Tagged k s a -> Int # isSigned :: Tagged k s a -> Bool # shiftL :: Tagged k s a -> Int -> Tagged k s a # unsafeShiftL :: Tagged k s a -> Int -> Tagged k s a # shiftR :: Tagged k s a -> Int -> Tagged k s a # unsafeShiftR :: Tagged k s a -> Int -> Tagged k s a # rotateL :: Tagged k s a -> Int -> Tagged k s a # rotateR :: Tagged k s a -> Int -> Tagged k s a # popCount :: Tagged k s a -> Int #
FiniteBits a => FiniteBits (Tagged k s a) |
Methods finiteBitSize :: Tagged k s a -> Int # countLeadingZeros :: Tagged k s a -> Int # countTrailingZeros :: Tagged k s a -> Int #
NFData b => NFData (Tagged k s b) |
Methods rnf :: Tagged k s b -> () #
((~) * (Entered m n (Tagged (* -> *) m a)) (Tagged (* -> *) n a), (~) * (Entered n m (Tagged (* -> *) n a)) (Tagged (* -> *) m a)) => Enter (Tagged (* -> *) m a) m n (Tagged (* -> *) n a) |
Methods enter :: (* :~> m) n -> Tagged (* -> *) m a -> Tagged (* -> *) n a #
type Rep1 (Tagged k s) |
type Rep1 (Tagged k s) = D1 (MetaData "Tagged" "Data.Tagged" "tagged-0.8.5-DG0qxw3gXxx4NfDcDx4Iai" True) (C1 (MetaCons "Tagged" PrefixI True) (S1 (MetaSel (Just Symbol "unTagged") NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1))
type Rep (Tagged k s b) |
type Rep (Tagged k s b) = D1 (MetaData "Tagged" "Data.Tagged" "tagged-0.8.5-DG0qxw3gXxx4NfDcDx4Iai" True) (C1 (MetaCons "Tagged" PrefixI True) (S1 (MetaSel (Just Symbol "unTagged") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 b)))