magicbane-0.4.0: A web framework that integrates Servant, RIO, EKG, fast-logger, wai-cli…

Safe HaskellNone
LanguageHaskell2010

Magicbane.App

Description

Extends Servant with context, based on RIO. The context should be a tuple of all your moudles and configs and stuff, so that the Data.Has module would let you access these items by type.

Synopsis

Documentation

asProxyTypeOf :: a -> proxy a -> a #

asProxyTypeOf is a type-restricted version of const. It is usually used as an infix operator, and its typing forces its first argument (which is usually overloaded) to have the same type as the tag of the second.

>>> import Data.Word
>>> :type asProxyTypeOf 123 (Proxy :: Proxy Word8)
asProxyTypeOf 123 (Proxy :: Proxy Word8) :: Word8

Note the lower-case proxy in the definition. This allows any type constructor with just one argument to be passed to the function, for example we could also write

>>> import Data.Word
>>> :type asProxyTypeOf 123 (Just (undefined :: Word8))
asProxyTypeOf 123 (Just (undefined :: Word8)) :: Word8

data Proxy (t :: k) :: forall k. k -> * #

Proxy is a type that holds no data, but has a phantom parameter of arbitrary type (or even kind). Its use is to provide type information, even though there is no value available of that type (or it may be too costly to create one).

Historically, Proxy :: Proxy a is a safer alternative to the 'undefined :: a' idiom.

>>> Proxy :: Proxy (Void, Int -> Int)
Proxy

Proxy can even hold types of higher kinds,

>>> Proxy :: Proxy Either
Proxy
>>> Proxy :: Proxy Functor
Proxy
>>> Proxy :: Proxy complicatedStructure
Proxy

Constructors

Proxy 
Instances
Generic1 (Proxy :: k -> *) 
Instance details

Defined in GHC.Generics

Associated Types

type Rep1 Proxy :: k -> * #

Methods

from1 :: Proxy a -> Rep1 Proxy a #

to1 :: Rep1 Proxy a -> Proxy a #

Monad (Proxy :: * -> *)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

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

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

return :: a -> Proxy a #

fail :: String -> Proxy a #

Functor (Proxy :: * -> *)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

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

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

Applicative (Proxy :: * -> *)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

pure :: a -> Proxy a #

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

liftA2 :: (a -> b -> c) -> Proxy a -> Proxy b -> Proxy c #

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

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

Foldable (Proxy :: * -> *)

Since: base-4.7.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Proxy m -> m #

foldMap :: Monoid m => (a -> m) -> Proxy a -> m #

foldr :: (a -> b -> b) -> b -> Proxy a -> b #

foldr' :: (a -> b -> b) -> b -> Proxy a -> b #

foldl :: (b -> a -> b) -> b -> Proxy a -> b #

foldl' :: (b -> a -> b) -> b -> Proxy a -> b #

foldr1 :: (a -> a -> a) -> Proxy a -> a #

foldl1 :: (a -> a -> a) -> Proxy a -> a #

toList :: Proxy a -> [a] #

null :: Proxy a -> Bool #

length :: Proxy a -> Int #

elem :: Eq a => a -> Proxy a -> Bool #

maximum :: Ord a => Proxy a -> a #

minimum :: Ord a => Proxy a -> a #

sum :: Num a => Proxy a -> a #

product :: Num a => Proxy a -> a #

Traversable (Proxy :: * -> *)

Since: base-4.7.0.0

Instance details

Defined in Data.Traversable

Methods

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

sequenceA :: Applicative f => Proxy (f a) -> f (Proxy a) #

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

sequence :: Monad m => Proxy (m a) -> m (Proxy a) #

ToJSON1 (Proxy :: * -> *) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> Proxy a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Proxy a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Proxy a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Proxy a] -> Encoding #

FromJSON1 (Proxy :: * -> *) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Proxy a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Proxy a] #

Alternative (Proxy :: * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Proxy

Methods

empty :: Proxy a #

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

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

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

MonadPlus (Proxy :: * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Proxy

Methods

mzero :: Proxy a #

mplus :: Proxy a -> Proxy a -> Proxy a #

Eq1 (Proxy :: * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftEq :: (a -> b -> Bool) -> Proxy a -> Proxy b -> Bool #

Ord1 (Proxy :: * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftCompare :: (a -> b -> Ordering) -> Proxy a -> Proxy b -> Ordering #

Read1 (Proxy :: * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Proxy a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Proxy a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Proxy a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Proxy a] #

Show1 (Proxy :: * -> *)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Proxy a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Proxy a] -> ShowS #

NFData1 (Proxy :: * -> *)

Since: deepseq-1.4.3.0

Instance details

Defined in Control.DeepSeq

Methods

liftRnf :: (a -> ()) -> Proxy a -> () #

Hashable1 (Proxy :: * -> *) 
Instance details

Defined in Data.Hashable.Class

Methods

liftHashWithSalt :: (Int -> a -> Int) -> Int -> Proxy a -> Int #

Bounded (Proxy t) 
Instance details

Defined in Data.Proxy

Methods

minBound :: Proxy t #

maxBound :: Proxy t #

Enum (Proxy s)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

succ :: Proxy s -> Proxy s #

pred :: Proxy s -> Proxy s #

toEnum :: Int -> Proxy s #

fromEnum :: Proxy s -> Int #

enumFrom :: Proxy s -> [Proxy s] #

enumFromThen :: Proxy s -> Proxy s -> [Proxy s] #

enumFromTo :: Proxy s -> Proxy s -> [Proxy s] #

enumFromThenTo :: Proxy s -> Proxy s -> Proxy s -> [Proxy s] #

Eq (Proxy s)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

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

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

Data t => Data (Proxy t)

Since: base-4.7.0.0

Instance details

Defined in Data.Data

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Proxy t -> c (Proxy t) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Proxy t) #

toConstr :: Proxy t -> Constr #

dataTypeOf :: Proxy t -> DataType #

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

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

gmapT :: (forall b. Data b => b -> b) -> Proxy t -> Proxy t #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Proxy t -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Proxy t -> r #

gmapQ :: (forall d. Data d => d -> u) -> Proxy t -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Proxy t -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Proxy t -> m (Proxy t) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Proxy t -> m (Proxy t) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Proxy t -> m (Proxy t) #

Ord (Proxy s)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

compare :: Proxy s -> Proxy s -> Ordering #

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

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

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

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

max :: Proxy s -> Proxy s -> Proxy s #

min :: Proxy s -> Proxy s -> Proxy s #

Read (Proxy t)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Show (Proxy s)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

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

show :: Proxy s -> String #

showList :: [Proxy s] -> ShowS #

Ix (Proxy s)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

range :: (Proxy s, Proxy s) -> [Proxy s] #

index :: (Proxy s, Proxy s) -> Proxy s -> Int #

unsafeIndex :: (Proxy s, Proxy s) -> Proxy s -> Int

inRange :: (Proxy s, Proxy s) -> Proxy s -> Bool #

rangeSize :: (Proxy s, Proxy s) -> Int #

unsafeRangeSize :: (Proxy s, Proxy s) -> Int

Generic (Proxy t) 
Instance details

Defined in GHC.Generics

Associated Types

type Rep (Proxy t) :: * -> * #

Methods

from :: Proxy t -> Rep (Proxy t) x #

to :: Rep (Proxy t) x -> Proxy t #

Semigroup (Proxy s)

Since: base-4.9.0.0

Instance details

Defined in Data.Proxy

Methods

(<>) :: Proxy s -> Proxy s -> Proxy s #

sconcat :: NonEmpty (Proxy s) -> Proxy s #

stimes :: Integral b => b -> Proxy s -> Proxy s #

Monoid (Proxy s)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

Methods

mempty :: Proxy s #

mappend :: Proxy s -> Proxy s -> Proxy s #

mconcat :: [Proxy s] -> Proxy s #

Hashable (Proxy a) 
Instance details

Defined in Data.Hashable.Class

Methods

hashWithSalt :: Int -> Proxy a -> Int #

hash :: Proxy a -> Int #

ToJSON (Proxy a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

FromJSON (Proxy a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

NFData (Proxy a)

Since: deepseq-1.4.0.0

Instance details

Defined in Control.DeepSeq

Methods

rnf :: Proxy a -> () #

type Rep1 (Proxy :: k -> *) 
Instance details

Defined in GHC.Generics

type Rep1 (Proxy :: k -> *) = D1 (MetaData "Proxy" "Data.Proxy" "base" False) (C1 (MetaCons "Proxy" PrefixI False) (U1 :: k -> *))
type Rep (Proxy t) 
Instance details

Defined in GHC.Generics

type Rep (Proxy t) = D1 (MetaData "Proxy" "Data.Proxy" "base" False) (C1 (MetaCons "Proxy" PrefixI False) (U1 :: * -> *))

data KProxy t #

A concrete, promotable proxy type, for use at the kind level There are no instances for this because it is intended at the kind level only

Constructors

KProxy 

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

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

Equations

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

class ToHttpApiData a where #

Convert value to HTTP API data.

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

Minimal complete definition

toUrlPiece | toQueryParam

Methods

toUrlPiece :: a -> Text #

Convert to URL path piece.

toEncodedUrlPiece :: a -> Builder #

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

toHeader :: a -> ByteString #

Convert to HTTP header value.

toQueryParam :: a -> Text #

Convert to query param value.

Instances
ToHttpApiData Bool 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Char 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Double 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Float 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Int 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Int8 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Int16 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Int32 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Int64 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Integer 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Natural 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Ordering 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Word 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Word8 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Word16 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Word32 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Word64 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData ()
>>> toUrlPiece ()
"_"
Instance details

Defined in Web.Internal.HttpApiData

Methods

toUrlPiece :: () -> Text #

toEncodedUrlPiece :: () -> Builder #

toHeader :: () -> ByteString #

toQueryParam :: () -> Text #

ToHttpApiData String 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

ToHttpApiData Text 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData UTCTime
>>> toUrlPiece $ UTCTime (fromGregorian 2015 10 03) 864.5
"2015-10-03T00:14:24.5Z"
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Text 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Void 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData All 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Any 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Day
>>> toUrlPiece (fromGregorian 2015 10 03)
"2015-10-03"
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData NominalDiffTime 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData TimeOfDay
>>> toUrlPiece $ TimeOfDay 14 55 23.1
"14:55:23.1"
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

ToHttpApiData ZonedTime
>>> toUrlPiece $ ZonedTime (LocalTime (fromGregorian 2015 10 03) (TimeOfDay 14 55 51.001)) utc
"2015-10-03T14:55:51.001+0000"
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData Link 
Instance details

Defined in Servant.Links

ToHttpApiData UUID 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData a => ToHttpApiData (Maybe a)
>>> toUrlPiece (Just "Hello")
"just Hello"
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData a => ToHttpApiData (First a) 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData a => ToHttpApiData (Last a) 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData a => ToHttpApiData (Dual a) 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData a => ToHttpApiData (Sum a) 
Instance details

Defined in Web.Internal.HttpApiData

ToHttpApiData a => ToHttpApiData (Product a) 
Instance details

Defined in Web.Internal.HttpApiData

(ToHttpApiData a, ToHttpApiData b) => ToHttpApiData (Either a b)
>>> toUrlPiece (Left "err" :: Either String Int)
"left err"
>>> toUrlPiece (Right 3 :: Either String Int)
"right 3"
Instance details

Defined in Web.Internal.HttpApiData

class FromHttpApiData a where #

Parse value from HTTP API data.

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

Minimal complete definition

parseUrlPiece | parseQueryParam

Methods

parseUrlPiece :: Text -> Either Text a #

Parse URL path piece.

parseHeader :: ByteString -> Either Text a #

Parse HTTP header value.

parseQueryParam :: Text -> Either Text a #

Parse query param value.

Instances
FromHttpApiData Bool 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Char 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Double 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Float 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Int 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Int8 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Int16 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Int32 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Int64 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Integer 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Natural 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Ordering 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Word 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Word8 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Word16 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Word32 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Word64 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

FromHttpApiData String 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

FromHttpApiData Text 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

FromHttpApiData Text 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Void

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

Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData All 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData Any 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

FromHttpApiData NominalDiffTime 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

FromHttpApiData UUID 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (First a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (Last a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (Dual a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (Sum a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (Product a) 
Instance details

Defined in Web.Internal.HttpApiData

FromHttpApiData a => FromHttpApiData (LenientData a) 
Instance details

Defined in Web.Internal.HttpApiData

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

Defined in Web.Internal.HttpApiData

data URI #

Represents a general universal resource identifier using its component parts.

For example, for the URI

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

the components are:

Constructors

URI 

Fields

Instances
Eq URI 
Instance details

Defined in Network.URI

Methods

(==) :: URI -> URI -> Bool #

(/=) :: URI -> URI -> Bool #

Data URI 
Instance details

Defined in Network.URI

Methods

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

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

toConstr :: URI -> Constr #

dataTypeOf :: URI -> DataType #

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

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

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

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

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

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

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

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

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

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

Ord URI 
Instance details

Defined in Network.URI

Methods

compare :: URI -> URI -> Ordering #

(<) :: URI -> URI -> Bool #

(<=) :: URI -> URI -> Bool #

(>) :: URI -> URI -> Bool #

(>=) :: URI -> URI -> Bool #

max :: URI -> URI -> URI #

min :: URI -> URI -> URI #

Show URI 
Instance details

Defined in Network.URI

Methods

showsPrec :: Int -> URI -> ShowS #

show :: URI -> String #

showList :: [URI] -> ShowS #

Generic URI 
Instance details

Defined in Network.URI

Associated Types

type Rep URI :: * -> * #

Methods

from :: URI -> Rep URI x #

to :: Rep URI x -> URI #

NFData URI 
Instance details

Defined in Network.URI

Methods

rnf :: URI -> () #

type Rep URI 
Instance details

Defined in Network.URI

data HttpVersion #

HTTP Version.

Note that the Show instance is intended merely for debugging.

Constructors

HttpVersion 

Fields

Instances
Eq HttpVersion 
Instance details

Defined in Network.HTTP.Types.Version

Ord HttpVersion 
Instance details

Defined in Network.HTTP.Types.Version

Show HttpVersion 
Instance details

Defined in Network.HTTP.Types.Version

HasLink sub => HasLink (HttpVersion :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (HttpVersion :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (HttpVersion :> sub) -> Link -> MkLink (HttpVersion :> sub) a #

HasServer api context => HasServer (HttpVersion :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

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

Methods

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

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

type MkLink (HttpVersion :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (HttpVersion :> sub :: *) a = MkLink sub a
type ServerT (HttpVersion :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (HttpVersion :> api :: *) m = HttpVersion -> ServerT api m

data StdMethod #

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

Constructors

GET 
POST 
HEAD 
PUT 
DELETE 
TRACE 
CONNECT 
OPTIONS 
PATCH 
Instances
Bounded StdMethod 
Instance details

Defined in Network.HTTP.Types.Method

Enum StdMethod 
Instance details

Defined in Network.HTTP.Types.Method

Eq StdMethod 
Instance details

Defined in Network.HTTP.Types.Method

Ord StdMethod 
Instance details

Defined in Network.HTTP.Types.Method

Read StdMethod 
Instance details

Defined in Network.HTTP.Types.Method

Show StdMethod 
Instance details

Defined in Network.HTTP.Types.Method

Ix StdMethod 
Instance details

Defined in Network.HTTP.Types.Method

ReflectMethod PATCH 
Instance details

Defined in Servant.API.Verbs

ReflectMethod OPTIONS 
Instance details

Defined in Servant.API.Verbs

ReflectMethod CONNECT 
Instance details

Defined in Servant.API.Verbs

ReflectMethod TRACE 
Instance details

Defined in Servant.API.Verbs

ReflectMethod DELETE 
Instance details

Defined in Servant.API.Verbs

ReflectMethod PUT 
Instance details

Defined in Servant.API.Verbs

ReflectMethod HEAD 
Instance details

Defined in Servant.API.Verbs

ReflectMethod POST 
Instance details

Defined in Servant.API.Verbs

ReflectMethod GET 
Instance details

Defined in Servant.API.Verbs

throwError :: MonadError e m => e -> m a #

Is used within a monadic computation to begin exception processing.

allFieldLinks' :: (HasLink (ToServantApi routes), GenericServant routes (AsLink a), ToServant routes (AsLink a) ~ MkLink (ToServantApi routes) a) => (Link -> a) -> routes (AsLink a) #

More general version of allFieldLinks.

Since: servant-0.14.1

allFieldLinks :: (HasLink (ToServantApi routes), GenericServant routes (AsLink Link), ToServant routes (AsLink Link) ~ MkLink (ToServantApi routes) Link) => routes (AsLink Link) #

Get all links as a record.

Since: servant-0.14.1

fieldLink' :: (IsElem endpoint (ToServantApi routes), HasLink endpoint, GenericServant routes AsApi) => (Link -> a) -> (routes AsApi -> endpoint) -> MkLink endpoint a #

More general version of fieldLink

Since: servant-0.14.1

fieldLink :: (IsElem endpoint (ToServantApi routes), HasLink endpoint, GenericServant routes AsApi) => (routes AsApi -> endpoint) -> MkLink endpoint Link #

Given an API record field, create a link for that route. Only the field's type is used.

data Record route = Record
    { _get :: route :- Capture "id" Int :> Get '[JSON] String
    , _put :: route :- ReqBody '[JSON] Int :> Put '[JSON] Bool
    }
  deriving (Generic)

getLink :: Int -> Link
getLink = fieldLink _get

Since: servant-0.14.1

allLinks' :: HasLink api => (Link -> a) -> Proxy api -> MkLink api a #

More general allLinks. See safeLink'.

allLinks :: HasLink api => Proxy api -> MkLink api Link #

Create all links in an API.

Note that the api type must be restricted to the endpoints that have valid links to them.

>>> type API = "foo" :> Capture "name" Text :> Get '[JSON] Text :<|> "bar" :> Capture "name" Int :> Get '[JSON] Double
>>> let fooLink :<|> barLink = allLinks (Proxy :: Proxy API)
>>> :t fooLink
fooLink :: Text -> Link
>>> :t barLink
barLink :: Int -> Link

Note: nested APIs don't work well with this approach

>>> :kind! MkLink (Capture "nest" Char :> (Capture "x" Int :> Get '[JSON] Int :<|> Capture "y" Double :> Get '[JSON] Double)) Link
MkLink (Capture "nest" Char :> (Capture "x" Int :> Get '[JSON] Int :<|> Capture "y" Double :> Get '[JSON] Double)) Link :: *
= Char -> (Int -> Link) :<|> (Double -> Link)

safeLink' #

Arguments

:: (IsElem endpoint api, HasLink endpoint) 
=> (Link -> a) 
-> Proxy api

The whole API that this endpoint is a part of

-> Proxy endpoint

The API endpoint you would like to point to

-> MkLink endpoint a 

More general safeLink.

safeLink #

Arguments

:: (IsElem endpoint api, HasLink endpoint) 
=> Proxy api

The whole API that this endpoint is a part of

-> Proxy endpoint

The API endpoint you would like to point to

-> MkLink endpoint Link 

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

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

linkURI' :: LinkArrayElementStyle -> Link -> URI #

Configurable linkURI.

>>> type API = "sum" :> QueryParams "x" Int :> Get '[JSON] Int
>>> linkURI' LinkArrayElementBracket $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API) [1, 2, 3]
sum?x[]=1&x[]=2&x[]=3
>>> linkURI' LinkArrayElementPlain $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API) [1, 2, 3]
sum?x=1&x=2&x=3

linkURI :: Link -> URI #

Transform Link into URI.

>>> type API = "something" :> Get '[JSON] Int
>>> linkURI $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API)
something
>>> type API = "sum" :> QueryParams "x" Int :> Get '[JSON] Int
>>> linkURI $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API) [1, 2, 3]
sum?x[]=1&x[]=2&x[]=3
>>> type API = "foo/bar" :> Get '[JSON] Int
>>> linkURI $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API)
foo%2Fbar
>>> type SomeRoute = "abc" :> Capture "email" String :> Put '[JSON] ()
>>> let someRoute = Proxy :: Proxy SomeRoute
>>> safeLink someRoute someRoute "test@example.com"
Link {_segments = ["abc","test%40example.com"], _queryParams = []}
>>> linkURI $ safeLink someRoute someRoute "test@example.com"
abc/test%40example.com

data Link #

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

data Param #

Query parameter.

Instances
Show Param 
Instance details

Defined in Servant.Links

Methods

showsPrec :: Int -> Param -> ShowS #

show :: Param -> String #

showList :: [Param] -> ShowS #

data LinkArrayElementStyle #

How to encode array query elements.

Constructors

LinkArrayElementBracket
foo[]=1&foo[]=2
LinkArrayElementPlain
foo=1&foo=2
Instances
Bounded LinkArrayElementStyle 
Instance details

Defined in Servant.Links

Enum LinkArrayElementStyle 
Instance details

Defined in Servant.Links

Eq LinkArrayElementStyle 
Instance details

Defined in Servant.Links

Ord LinkArrayElementStyle 
Instance details

Defined in Servant.Links

Show LinkArrayElementStyle 
Instance details

Defined in Servant.Links

data AsLink a #

A type that specifies that an API record contains a set of links.

Since: servant-0.14.1

class HasLink (endpoint :: k) where #

Construct a toLink for an endpoint.

Minimal complete definition

toLink

Associated Types

type MkLink (endpoint :: k) a :: * #

Methods

toLink #

Arguments

:: (Link -> a) 
-> Proxy endpoint

The API endpoint you would like to point to

-> Link 
-> MkLink endpoint a 

data WithNamedContext (name :: Symbol) (subContext :: [*]) subApi #

WithNamedContext names a specific tagged context to use for the combinators in the API. (See also in servant-server, Servant.Server.Context.) For example:

type UseNamedContextAPI = WithNamedContext "myContext" '[String] (
    ReqBody '[JSON] Int :> Get '[JSON] Int)

Both the ReqBody and Get combinators will use the WithNamedContext with type tag "myContext" as their context.

Contexts are only relevant for servant-server.

For more information, see the tutorial.

Instances
HasLink sub => HasLink (WithNamedContext name context sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (WithNamedContext name context sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (WithNamedContext name context sub) -> Link -> MkLink (WithNamedContext name context sub) a #

(HasContextEntry context (NamedContext name subContext), HasServer subApi subContext) => HasServer (WithNamedContext name subContext subApi :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (WithNamedContext name subContext subApi) m :: * #

Methods

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

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 #

type MkLink (WithNamedContext name context sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (WithNamedContext name context sub :: *) a = MkLink sub a
type ServerT (WithNamedContext name subContext subApi :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (WithNamedContext name subContext subApi :: *) m = ServerT subApi m

type family Endpoints api :: [*] where ... #

Flatten API into a list of endpoints.

>>> Refl :: Endpoints SampleAPI :~: '["hello" :> Verb 'GET 200 '[JSON] Int, "bye" :> (Capture "name" String :> Verb 'POST 200 '[JSON, PlainText] Bool)]
Refl

Equations

Endpoints (a :<|> b) = AppendList (Endpoints a) (Endpoints b) 
Endpoints (e :> a) = MapSub e (Endpoints a) 
Endpoints a = a ': ([] :: [*]) 

type family IsElem' a s :: Constraint #

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

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

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

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

type family IsElem endpoint api :: Constraint where ... #

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

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

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

>>> ok (Proxy :: Proxy (IsElem (Get '[JSON] Int) (Header "h" Bool :> Get '[JSON] Int)))
OK
>>> ok (Proxy :: Proxy (IsElem (Get '[JSON] Int) (ReqBody '[JSON] Bool :> Get '[JSON] Int)))
OK
  • N.B.:* IsElem a b can be seen as capturing the notion of whether the URL represented by a would match the URL represented by b, *not* whether a request represented by a matches the endpoints serving b (for the latter, use IsIn).

Equations

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

type family IsSubAPI sub api :: Constraint where ... #

Check whether sub is a sub-API of api.

>>> ok (Proxy :: Proxy (IsSubAPI SampleAPI (SampleAPI :<|> Get '[JSON] Int)))
OK
>>> ok (Proxy :: Proxy (IsSubAPI (SampleAPI :<|> Get '[JSON] Int) SampleAPI))
...
... Could not deduce...
...

This uses IsElem for checking; thus the note there applies here.

Equations

IsSubAPI sub api = AllIsElem (Endpoints sub) api 

type family AllIsElem (xs :: [*]) api :: Constraint where ... #

Check that every element of xs is an endpoint of api (using IsElem).

Equations

AllIsElem ([] :: [*]) api = () 
AllIsElem (x ': xs) api = (IsElem x api, AllIsElem xs api) 

type family IsIn endpoint api :: Constraint where ... #

Closed type family, check if endpoint is exactly within api.

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

Unlike IsElem, this requires an *exact* match.

>>> ok (Proxy :: Proxy (IsIn (Get '[JSON] Int) (Header "h" Bool :> Get '[JSON] Int)))
...
... Could not deduce...
...

Equations

IsIn e (sa :<|> sb) = Or (IsIn e sa) (IsIn e sb) 
IsIn (e :> sa) (e :> sb) = IsIn sa sb 
IsIn e e = () 

type family IsStrictSubAPI sub api :: Constraint where ... #

Check whether sub is a sub API of api.

Like IsSubAPI, but uses IsIn rather than IsElem.

Equations

IsStrictSubAPI sub api = AllIsIn (Endpoints sub) api 

type family AllIsIn (xs :: [*]) api :: Constraint where ... #

Check that every element of xs is an endpoint of api (using IsIn).

ok (Proxy :: Proxy (AllIsIn (Endpoints SampleAPI) SampleAPI)) OK

Equations

AllIsIn ([] :: [*]) api = () 
AllIsIn (x ': xs) api = (IsIn x api, AllIsIn xs api) 

type family MapSub (e :: k) (xs :: [*]) :: [*] where ... #

Apply (e :>) to every API in xs.

Equations

MapSub (e :: k) ([] :: [*]) = ([] :: [*]) 
MapSub (e :: k) (x ': xs) = (e :> x) ': MapSub e xs 

type family AppendList (xs :: [a]) (ys :: [a]) :: [a] where ... #

Append two type-level lists.

Equations

AppendList ([] :: [a]) (ys :: [a]) = ys 
AppendList (x ': xs :: [a]) (ys :: [a]) = x ': AppendList xs ys 

type family IsSubList (a :: [t]) (b :: [t]) :: Constraint where ... #

Equations

IsSubList ([] :: [t]) (b :: [t]) = () 
IsSubList (x ': xs :: [t]) (y :: [t]) = And (Elem x y) (IsSubList xs y) 

type Elem (e :: t) (es :: [t]) = ElemGo e es es #

Check that a value is an element of a list:

>>> ok (Proxy :: Proxy (Elem Bool '[Int, Bool]))
OK
>>> ok (Proxy :: Proxy (Elem String '[Int, Bool]))
...
... [Char]...'[Int, Bool...
...

type family ElemGo (e :: t) (es :: [t]) (orig :: t1) :: Constraint where ... #

Equations

ElemGo (x :: a) (x ': xs :: [a]) (orig :: t) = () 
ElemGo (y :: t1) (x ': xs :: [t1]) (orig :: t2) = ElemGo y xs orig 
ElemGo (x :: t2) ([] :: [t2]) (orig :: t1) = (TypeError ((ShowType x :<>: Text " expected in list ") :<>: ShowType orig) :: Constraint) 

type family Or a b :: Constraint where ... #

If either a or b produce an empty constraint, produce an empty constraint.

Equations

Or () b = () 
Or a () = () 

data Verb (method :: k1) (statusCode :: Nat) (contentTypes :: [*]) a :: forall k1. k1 -> Nat -> [*] -> * -> * #

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

>>> type Post204 contentTypes a = Verb 'POST 204 contentTypes a
Instances
HasLink (Verb m s ct a :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Verb m s ct a) a :: * #

Methods

toLink :: (Link -> a0) -> Proxy (Verb m s ct a) -> Link -> MkLink (Verb m s ct a) a0 #

(AllCTRender ctypes a, ReflectMethod method, KnownNat status) => HasServer (Verb method status ctypes a :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Verb method status ctypes a) m :: * #

Methods

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

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 #

(AllCTRender ctypes a, ReflectMethod method, KnownNat status, GetHeaders (Headers h a)) => HasServer (Verb method status ctypes (Headers h a) :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Verb method status ctypes (Headers h a)) m :: * #

Methods

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

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 #

Generic (Verb method statusCode contentTypes a) 
Instance details

Defined in Servant.API.Verbs

Associated Types

type Rep (Verb method statusCode contentTypes a) :: * -> * #

Methods

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

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

type MkLink (Verb m s ct a :: *) r 
Instance details

Defined in Servant.Links

type MkLink (Verb m s ct a :: *) r = r
type ServerT (Verb method status ctypes (Headers h a) :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Verb method status ctypes (Headers h a) :: *) m = m (Headers h a)
type ServerT (Verb method status ctypes a :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Verb method status ctypes a :: *) m = m a
type Rep (Verb method statusCode contentTypes a) 
Instance details

Defined in Servant.API.Verbs

type Rep (Verb method statusCode contentTypes a) = D1 (MetaData "Verb" "Servant.API.Verbs" "servant-0.14.1-Kxp99gef9WABsGE0PQ92ss" False) (V1 :: * -> *)

type Get = Verb GET 200 #

GET with 200 status code.

type Post = Verb POST 200 #

POST with 200 status code.

type Put = Verb PUT 200 #

PUT with 200 status code.

type Delete = Verb DELETE 200 #

DELETE with 200 status code.

type Patch = Verb PATCH 200 #

PATCH with 200 status code.

type PostCreated = Verb POST 201 #

POST with 201 status code.

type GetAccepted = Verb GET 202 #

GET with 202 status code.

type PostAccepted = Verb POST 202 #

POST with 202 status code.

type DeleteAccepted = Verb DELETE 202 #

DELETE with 202 status code.

type PatchAccepted = Verb PATCH 202 #

PATCH with 202 status code.

type PutAccepted = Verb PUT 202 #

PUT with 202 status code.

type GetNonAuthoritative = Verb GET 203 #

GET with 203 status code.

type PostNonAuthoritative = Verb POST 203 #

POST with 203 status code.

type DeleteNonAuthoritative = Verb DELETE 203 #

DELETE with 203 status code.

type PatchNonAuthoritative = Verb PATCH 203 #

PATCH with 203 status code.

type PutNonAuthoritative = Verb PUT 203 #

PUT with 203 status code.

type GetNoContent = Verb GET 204 #

GET with 204 status code.

type PostNoContent = Verb POST 204 #

POST with 204 status code.

type DeleteNoContent = Verb DELETE 204 #

DELETE with 204 status code.

type PatchNoContent = Verb PATCH 204 #

PATCH with 204 status code.

type PutNoContent = Verb PUT 204 #

PUT with 204 status code.

type GetResetContent = Verb GET 205 #

GET with 205 status code.

type PostResetContent = Verb POST 205 #

POST with 205 status code.

type GetPartialContent = Verb GET 206 #

GET with 206 status code.

class ReflectMethod (a :: k) where #

Minimal complete definition

reflectMethod

Methods

reflectMethod :: Proxy a -> Method #

Instances
ReflectMethod PATCH 
Instance details

Defined in Servant.API.Verbs

ReflectMethod OPTIONS 
Instance details

Defined in Servant.API.Verbs

ReflectMethod CONNECT 
Instance details

Defined in Servant.API.Verbs

ReflectMethod TRACE 
Instance details

Defined in Servant.API.Verbs

ReflectMethod DELETE 
Instance details

Defined in Servant.API.Verbs

ReflectMethod PUT 
Instance details

Defined in Servant.API.Verbs

ReflectMethod HEAD 
Instance details

Defined in Servant.API.Verbs

ReflectMethod POST 
Instance details

Defined in Servant.API.Verbs

ReflectMethod GET 
Instance details

Defined in Servant.API.Verbs

data (path :: k) :> a :: forall k. k -> * -> * infixr 4 #

The contained API (second argument) can be found under ("/" ++ path) (path being the first argument).

Example:

>>> -- GET /hello/world
>>> -- returning a JSON encoded World value
>>> type MyApi = "hello" :> "world" :> Get '[JSON] World
Instances
HasLink sub => HasLink (HttpVersion :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (HttpVersion :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (HttpVersion :> sub) -> Link -> MkLink (HttpVersion :> sub) a #

HasLink sub => HasLink (ReqBody' mods ct a :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (ReqBody' mods ct a :> sub) a :: * #

Methods

toLink :: (Link -> a0) -> Proxy (ReqBody' mods ct a :> sub) -> Link -> MkLink (ReqBody' mods ct a :> sub) a0 #

HasLink sub => HasLink (RemoteHost :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (RemoteHost :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (RemoteHost :> sub) -> Link -> MkLink (RemoteHost :> sub) a #

(KnownSymbol sym, ToHttpApiData v, HasLink sub, SBoolI (FoldRequired mods)) => HasLink (QueryParam' mods sym v :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (QueryParam' mods sym v :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (QueryParam' mods sym v :> sub) -> Link -> MkLink (QueryParam' mods sym v :> sub) a #

(KnownSymbol sym, ToHttpApiData v, HasLink sub) => HasLink (QueryParams sym v :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (QueryParams sym v :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (QueryParams sym v :> sub) -> Link -> MkLink (QueryParams sym v :> sub) a #

(KnownSymbol sym, HasLink sub) => HasLink (QueryFlag sym :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (QueryFlag sym :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (QueryFlag sym :> sub) -> Link -> MkLink (QueryFlag sym :> sub) a #

HasLink sub => HasLink (Header' mods sym a :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Header' mods sym a :> sub) a :: * #

Methods

toLink :: (Link -> a0) -> Proxy (Header' mods sym a :> sub) -> Link -> MkLink (Header' mods sym a :> sub) a0 #

HasLink sub => HasLink (IsSecure :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (IsSecure :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (IsSecure :> sub) -> Link -> MkLink (IsSecure :> sub) a #

HasLink sub => HasLink (AuthProtect tag :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (AuthProtect tag :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (AuthProtect tag :> sub) -> Link -> MkLink (AuthProtect tag :> sub) a #

HasLink sub => HasLink (Summary s :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Summary s :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (Summary s :> sub) -> Link -> MkLink (Summary s :> sub) a #

HasLink sub => HasLink (Description s :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Description s :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (Description s :> sub) -> Link -> MkLink (Description s :> sub) a #

(ToHttpApiData v, HasLink sub) => HasLink (Capture' mods sym v :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Capture' mods sym v :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (Capture' mods sym v :> sub) -> Link -> MkLink (Capture' mods sym v :> sub) a #

(ToHttpApiData v, HasLink sub) => HasLink (CaptureAll sym v :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (CaptureAll sym v :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (CaptureAll sym v :> sub) -> Link -> MkLink (CaptureAll sym v :> sub) a #

HasLink sub => HasLink (BasicAuth realm a :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (BasicAuth realm a :> sub) a :: * #

Methods

toLink :: (Link -> a0) -> Proxy (BasicAuth realm a :> sub) -> Link -> MkLink (BasicAuth realm a :> sub) a0 #

HasLink sub => HasLink (Vault :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Vault :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (Vault :> sub) -> Link -> MkLink (Vault :> sub) a #

(KnownSymbol sym, HasLink sub) => HasLink (sym :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (sym :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (sym :> sub) -> Link -> MkLink (sym :> sub) a #

(TypeError (HasServerArrowKindError arr) :: Constraint) => HasServer (arr :> api :: *) context

This instance catches mistakes when there are non-saturated type applications on LHS of :>.

>>> serve (Proxy :: Proxy (Capture "foo" :> Get '[JSON] Int)) (error "...")
...
...Expected something of kind Symbol or *, got: k -> l on the LHS of ':>'.
...Maybe you haven't applied enough arguments to
...Capture' '[] "foo"
...
>>> undefined :: Server (Capture "foo" :> Get '[JSON] Int)
...
...Expected something of kind Symbol or *, got: k -> l on the LHS of ':>'.
...Maybe you haven't applied enough arguments to
...Capture' '[] "foo"
...
Instance details

Defined in Servant.Server.Internal

Associated Types

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

Methods

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

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

HasServer api context => HasServer (HttpVersion :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

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

Methods

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

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

(AllCTUnrender list a, HasServer api context, SBoolI (FoldLenient mods)) => HasServer (ReqBody' mods 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...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (ReqBody' mods list a :> api) m :: * #

Methods

route :: Proxy (ReqBody' mods list a :> api) -> Context context -> Delayed env (Server (ReqBody' mods list a :> api)) -> Router env #

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 #

HasServer api context => HasServer (RemoteHost :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

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

Methods

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

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

(KnownSymbol sym, FromHttpApiData a, HasServer api context, SBoolI (FoldRequired mods), SBoolI (FoldLenient mods)) => HasServer (QueryParam' mods 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...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (QueryParam' mods sym a :> api) m :: * #

Methods

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

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 #

(KnownSymbol sym, FromHttpApiData a, HasServer api context) => HasServer (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...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (QueryParams sym a :> api) m :: * #

Methods

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

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 #

(KnownSymbol sym, HasServer api context) => HasServer (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...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (QueryFlag sym :> api) m :: * #

Methods

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

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

(KnownSymbol sym, FromHttpApiData a, HasServer api context, SBoolI (FoldRequired mods), SBoolI (FoldLenient mods)) => HasServer (Header' mods 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
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Header' mods sym a :> api) m :: * #

Methods

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

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 #

HasServer api context => HasServer (IsSecure :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

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

Methods

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

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

HasServer api ctx => HasServer (Summary desc :> api :: *) ctx

Ignore Summary in server handlers.

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Summary desc :> api) m :: * #

Methods

route :: Proxy (Summary desc :> api) -> Context ctx -> Delayed env (Server (Summary desc :> api)) -> Router env #

hoistServerWithContext :: Proxy (Summary desc :> api) -> Proxy ctx -> (forall x. m x -> n x) -> ServerT (Summary desc :> api) m -> ServerT (Summary desc :> api) n #

HasServer api ctx => HasServer (Description desc :> api :: *) ctx

Ignore Description in server handlers.

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Description desc :> api) m :: * #

Methods

route :: Proxy (Description desc :> api) -> Context ctx -> Delayed env (Server (Description desc :> api)) -> Router env #

hoistServerWithContext :: Proxy (Description desc :> api) -> Proxy ctx -> (forall x. m x -> n x) -> ServerT (Description desc :> api) m -> ServerT (Description desc :> api) n #

(KnownSymbol capture, FromHttpApiData a, HasServer api context) => HasServer (Capture' mods 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 = ...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Capture' mods capture a :> api) m :: * #

Methods

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

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 #

(KnownSymbol capture, FromHttpApiData a, HasServer api context) => HasServer (CaptureAll capture a :> api :: *) 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 = ...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (CaptureAll capture a :> api) m :: * #

Methods

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

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 #

(KnownSymbol realm, HasServer api context, HasContextEntry context (BasicAuthCheck usr)) => HasServer (BasicAuth realm usr :> api :: *) context

Basic Authentication

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (BasicAuth realm usr :> api) m :: * #

Methods

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

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 #

HasServer api context => HasServer (Vault :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

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

Methods

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

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

(KnownSymbol path, HasServer api context) => HasServer (path :> api :: *) context

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

Associated Types

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

Methods

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

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

type MkLink (HttpVersion :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (HttpVersion :> sub :: *) a = MkLink sub a
type MkLink (ReqBody' mods ct a :> sub :: *) r 
Instance details

Defined in Servant.Links

type MkLink (ReqBody' mods ct a :> sub :: *) r = MkLink sub r
type MkLink (RemoteHost :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (RemoteHost :> sub :: *) a = MkLink sub a
type MkLink (QueryParam' mods sym v :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (QueryParam' mods sym v :> sub :: *) a = If (FoldRequired mods) v (Maybe v) -> MkLink sub a
type MkLink (QueryParams sym v :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (QueryParams sym v :> sub :: *) a = [v] -> MkLink sub a
type MkLink (QueryFlag sym :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (QueryFlag sym :> sub :: *) a = Bool -> MkLink sub a
type MkLink (Header' mods sym a :> sub :: *) r 
Instance details

Defined in Servant.Links

type MkLink (Header' mods sym a :> sub :: *) r = MkLink sub r
type MkLink (IsSecure :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (IsSecure :> sub :: *) a = MkLink sub a
type MkLink (AuthProtect tag :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (AuthProtect tag :> sub :: *) a = MkLink sub a
type MkLink (Summary s :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (Summary s :> sub :: *) a = MkLink sub a
type MkLink (Description s :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (Description s :> sub :: *) a = MkLink sub a
type MkLink (Capture' mods sym v :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (Capture' mods sym v :> sub :: *) a = v -> MkLink sub a
type MkLink (CaptureAll sym v :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (CaptureAll sym v :> sub :: *) a = [v] -> MkLink sub a
type MkLink (BasicAuth realm a :> sub :: *) r 
Instance details

Defined in Servant.Links

type MkLink (BasicAuth realm a :> sub :: *) r = MkLink sub r
type MkLink (Vault :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (Vault :> sub :: *) a = MkLink sub a
type MkLink (sym :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (sym :> sub :: *) a = MkLink sub a
type ServerT (arr :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (arr :> api :: *) m = (TypeError (HasServerArrowKindError arr) :: *)
type ServerT (HttpVersion :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (HttpVersion :> api :: *) m = HttpVersion -> ServerT api m
type ServerT (ReqBody' mods list a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (ReqBody' mods list a :> api :: *) m = If (FoldLenient mods) (Either String a) a -> ServerT api m
type ServerT (RemoteHost :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (RemoteHost :> api :: *) m = SockAddr -> ServerT api m
type ServerT (QueryParam' mods sym a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (QueryParam' mods sym a :> api :: *) m = RequestArgument mods a -> ServerT api m
type ServerT (QueryParams sym a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (QueryParams sym a :> api :: *) m = [a] -> ServerT api m
type ServerT (QueryFlag sym :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (QueryFlag sym :> api :: *) m = Bool -> ServerT api m
type ServerT (Header' mods sym a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Header' mods sym a :> api :: *) m = RequestArgument mods a -> ServerT api m
type ServerT (IsSecure :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (IsSecure :> api :: *) m = IsSecure -> ServerT api m
type ServerT (Summary desc :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Summary desc :> api :: *) m = ServerT api m
type ServerT (Description desc :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Description desc :> api :: *) m = ServerT api m
type ServerT (Capture' mods capture a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Capture' mods capture a :> api :: *) m = a -> ServerT api m
type ServerT (CaptureAll capture a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (CaptureAll capture a :> api :: *) m = [a] -> ServerT api m
type ServerT (BasicAuth realm usr :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (BasicAuth realm usr :> api :: *) m = usr -> ServerT api m
type ServerT (Vault :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Vault :> api :: *) m = Vault -> ServerT api m
type ServerT (path :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (path :> api :: *) m = ServerT api m

data Stream (method :: k1) (status :: Nat) framing contentType a :: forall k1. k1 -> Nat -> * -> * -> * -> * #

A Stream endpoint for a given method emits a stream of encoded values at a given Content-Type, delimited by a framing strategy. Stream endpoints always return response code 200 on success. Type synonyms are provided for standard methods.

Instances
HasLink (Stream m status fr ct a :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Stream m status fr ct a) a :: * #

Methods

toLink :: (Link -> a0) -> Proxy (Stream m status fr ct a) -> Link -> MkLink (Stream m status fr ct a) a0 #

(MimeRender ctype a, ReflectMethod method, KnownNat status, FramingRender framing ctype, ToStreamGenerator b a) => HasServer (Stream method status framing ctype b :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Stream method status framing ctype b) m :: * #

Methods

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

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

(MimeRender ctype a, ReflectMethod method, KnownNat status, FramingRender framing ctype, ToStreamGenerator b a, GetHeaders (Headers h b)) => HasServer (Stream method status framing ctype (Headers h b) :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Stream method status framing ctype (Headers h b)) m :: * #

Methods

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

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

Generic (Stream method status framing contentType a) 
Instance details

Defined in Servant.API.Stream

Associated Types

type Rep (Stream method status framing contentType a) :: * -> * #

Methods

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

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

type MkLink (Stream m status fr ct a :: *) r 
Instance details

Defined in Servant.Links

type MkLink (Stream m status fr ct a :: *) r = r
type ServerT (Stream method status framing ctype (Headers h b) :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Stream method status framing ctype (Headers h b) :: *) m = m (Headers h b)
type ServerT (Stream method status framing ctype b :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Stream method status framing ctype b :: *) m = m b
type Rep (Stream method status framing contentType a) 
Instance details

Defined in Servant.API.Stream

type Rep (Stream method status framing contentType a) = D1 (MetaData "Stream" "Servant.API.Stream" "servant-0.14.1-Kxp99gef9WABsGE0PQ92ss" False) (V1 :: * -> *)

type StreamGet = Stream GET 200 #

type StreamPost = Stream POST 200 #

newtype StreamGenerator a #

Stream endpoints may be implemented as producing a StreamGenerator -- a function that itself takes two emit functions -- the first to be used on the first value the stream emits, and the second to be used on all subsequent values (to allow interspersed framing strategies such as comma separation).

Constructors

StreamGenerator 

Fields

Instances
ToStreamGenerator (StreamGenerator a) a 
Instance details

Defined in Servant.API.Stream

class ToStreamGenerator a b | a -> b where #

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

Minimal complete definition

toStreamGenerator

Instances
ToStreamGenerator (StreamGenerator a) a 
Instance details

Defined in Servant.API.Stream

newtype ResultStream a #

Clients reading from streaming endpoints can be implemented as producing a ResultStream that captures the setup, takedown, and incremental logic for a read, being an IO continuation that takes a producer of Just either values or errors that terminates with a Nothing.

Constructors

ResultStream (forall b. (IO (Maybe (Either String a)) -> IO b) -> IO b) 
Instances
BuildFromStream a (ResultStream a) 
Instance details

Defined in Servant.API.Stream

class BuildFromStream a b where #

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

Minimal complete definition

buildFromStream

Methods

buildFromStream :: ResultStream a -> b #

Instances
BuildFromStream a (ResultStream a) 
Instance details

Defined in Servant.API.Stream

class FramingRender (strategy :: k) (a :: k1) where #

The FramingRender class provides the logic for emitting a framing strategy. The strategy emits a header, followed by boundary-delimited data, and finally a termination character. For many strategies, some of these will just be empty bytestrings.

Minimal complete definition

header, boundary, trailer

Methods

header :: Proxy strategy -> Proxy a -> ByteString #

boundary :: Proxy strategy -> Proxy a -> BoundaryStrategy #

trailer :: Proxy strategy -> Proxy a -> ByteString #

data BoundaryStrategy #

The bracketing strategy generates things to precede and follow the content, as with netstrings. The intersperse strategy inserts seperators between things, as with newline framing. Finally, the general strategy performs an arbitrary rewrite on the content, to allow escaping rules and such.

data ByteStringParser a #

A type of parser that can never fail, and has different parsing strategies (incremental, or EOF) depending if more input can be sent. The incremental parser should return Nothing if it would like to be sent a longer ByteString. If it returns a value, it also returns the remainder following that value.

class FramingUnrender (strategy :: k) (a :: k1) where #

The FramingUnrender class provides the logic for parsing a framing strategy. The outer ByteStringParser strips the header from a stream of bytes, and yields a parser that can handle the remainder, stepwise. Each frame may be a ByteString, or a String indicating the error state for that frame. Such states are per-frame, so that protocols that can resume after errors are able to do so. Eventually this returns an empty ByteString to indicate termination.

Minimal complete definition

unrenderFrames

data NoFraming #

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

data NewlineFraming #

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

noHeader :: AddHeader h v orig new => orig -> new #

Deliberately do not add a header to a value.

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

addHeader :: AddHeader h v orig new => v -> orig -> new #

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

  1. A simple value is wrapped in "Headers '[hdr]":
>>> let example1 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;
>>> getHeaders example1
[("someheader","5")]
  1. A value that already has a header has its new header *prepended* to the existing list:
>>> let example1 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;
>>> let example2 = addHeader True example1 :: Headers '[Header "1st" Bool, Header "someheader" Int] String
>>> getHeaders example2
[("1st","true"),("someheader","5")]

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

data Headers (ls :: [*]) a #

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

Constructors

Headers 

Fields

Instances
(KnownSymbol h, ToHttpApiData v) => AddHeader h v (Headers (fst ': rest) a) (Headers (Header h v ': (fst ': rest)) a) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

addOptionalHeader :: ResponseHeader h v -> Headers (fst ': rest) a -> Headers (Header h v ': (fst ': rest)) a

Functor (Headers ls) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

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

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

(AllCTRender ctypes a, ReflectMethod method, KnownNat status, GetHeaders (Headers h a)) => HasServer (Verb method status ctypes (Headers h a) :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Verb method status ctypes (Headers h a)) m :: * #

Methods

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

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 #

(MimeRender ctype a, ReflectMethod method, KnownNat status, FramingRender framing ctype, ToStreamGenerator b a, GetHeaders (Headers h b)) => HasServer (Stream method status framing ctype (Headers h b) :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Stream method status framing ctype (Headers h b)) m :: * #

Methods

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

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

GetHeaders' hs => GetHeaders (Headers hs a) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeaders :: Headers hs a -> [Header] #

type ServerT (Verb method status ctypes (Headers h a) :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Verb method status ctypes (Headers h a) :: *) m = m (Headers h a)
type ServerT (Stream method status framing ctype (Headers h b) :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Stream method status framing ctype (Headers h b) :: *) m = m (Headers h b)

data ResponseHeader (sym :: Symbol) a #

Instances
Functor (ResponseHeader sym) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

fmap :: (a -> b) -> ResponseHeader sym a -> ResponseHeader sym b #

(<$) :: a -> ResponseHeader sym b -> ResponseHeader sym a #

Eq a => Eq (ResponseHeader sym a) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

(==) :: ResponseHeader sym a -> ResponseHeader sym a -> Bool #

(/=) :: ResponseHeader sym a -> ResponseHeader sym a -> Bool #

Show a => Show (ResponseHeader sym a) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

showsPrec :: Int -> ResponseHeader sym a -> ShowS #

show :: ResponseHeader sym a -> String #

showList :: [ResponseHeader sym a] -> ShowS #

data HList (a :: [*]) where #

Constructors

HNil :: HList ([] :: [*]) 
HCons :: HList (Header h x ': xs) 
Instances
GetHeadersFromHList hs => GetHeaders (HList hs) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeaders :: HList hs -> [Header] #

class BuildHeadersTo (hs :: [*]) where #

Minimal complete definition

buildHeadersTo

Methods

buildHeadersTo :: [Header] -> HList hs #

Note: if there are multiple occurences of a header in the argument, the values are interspersed with commas before deserialization (see RFC2616 Sec 4.2)

Instances
BuildHeadersTo ([] :: [*]) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

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

(FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h) => BuildHeadersTo (Header h v ': xs) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

buildHeadersTo :: [Header0] -> HList (Header h v ': xs) #

class GetHeaders ls where #

Minimal complete definition

getHeaders

Methods

getHeaders :: ls -> [Header] #

Instances
GetHeadersFromHList hs => GetHeaders (HList hs) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeaders :: HList hs -> [Header] #

GetHeaders' hs => GetHeaders (Headers hs a) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeaders :: Headers hs a -> [Header] #

class AddHeader (h :: Symbol) v orig new | h v orig -> new, new -> h, new -> v, new -> orig #

Minimal complete definition

addOptionalHeader

Instances
(KnownSymbol h, ToHttpApiData v, new ~ Headers (Header h v ': ([] :: [*])) a) => AddHeader h v a new 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

addOptionalHeader :: ResponseHeader h v -> a -> new

(KnownSymbol h, ToHttpApiData v) => AddHeader h v (Headers (fst ': rest) a) (Headers (Header h v ': (fst ': rest)) a) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

addOptionalHeader :: ResponseHeader h v -> Headers (fst ': rest) a -> Headers (Header h v ': (fst ': rest)) a

type ReqBody = ReqBody' (Required ': (Strict ': ([] :: [*]))) #

Extract the request body as a value of type a.

Example:

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

data ReqBody' (mods :: [*]) (contentTypes :: [*]) a #

Note: ReqBody' is always Required.

Instances
HasLink sub => HasLink (ReqBody' mods ct a :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (ReqBody' mods ct a :> sub) a :: * #

Methods

toLink :: (Link -> a0) -> Proxy (ReqBody' mods ct a :> sub) -> Link -> MkLink (ReqBody' mods ct a :> sub) a0 #

(AllCTUnrender list a, HasServer api context, SBoolI (FoldLenient mods)) => HasServer (ReqBody' mods 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...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (ReqBody' mods list a :> api) m :: * #

Methods

route :: Proxy (ReqBody' mods list a :> api) -> Context context -> Delayed env (Server (ReqBody' mods list a :> api)) -> Router env #

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 #

type MkLink (ReqBody' mods ct a :> sub :: *) r 
Instance details

Defined in Servant.Links

type MkLink (ReqBody' mods ct a :> sub :: *) r = MkLink sub r
type ServerT (ReqBody' mods list a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (ReqBody' mods list a :> api :: *) m = If (FoldLenient mods) (Either String a) a -> ServerT api m

data RemoteHost #

Provides access to the host or IP address from which the HTTP request was sent.

Instances
HasLink sub => HasLink (RemoteHost :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (RemoteHost :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (RemoteHost :> sub) -> Link -> MkLink (RemoteHost :> sub) a #

HasServer api context => HasServer (RemoteHost :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

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

Methods

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

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

type MkLink (RemoteHost :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (RemoteHost :> sub :: *) a = MkLink sub a
type ServerT (RemoteHost :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (RemoteHost :> api :: *) m = SockAddr -> ServerT api m

data Raw #

Endpoint for plugging in your own Wai Applications.

The given Application will get the request as received by the server, potentially with a modified (stripped) pathInfo if the Application is being routed with :>.

In addition to just letting you plug in your existing WAI Applications, this can also be used with serveDirectory to serve static files stored in a particular directory on your filesystem

Instances
HasLink Raw 
Instance details

Defined in Servant.Links

Associated Types

type MkLink Raw a :: * #

Methods

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

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"
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT Raw m :: * #

Methods

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

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

type MkLink Raw a 
Instance details

Defined in Servant.Links

type MkLink Raw a = a
type ServerT Raw m 
Instance details

Defined in Servant.Server.Internal

type QueryParam = QueryParam' (Optional ': (Strict ': ([] :: [*]))) #

Lookup the value associated to the sym query string parameter and try to extract it as a value of type a.

Example:

>>> -- /books?author=<author name>
>>> type MyApi = "books" :> QueryParam "author" Text :> Get '[JSON] [Book]

data QueryParam' (mods :: [*]) (sym :: Symbol) a #

QueryParam which can be Required, Lenient, or modified otherwise.

Instances
(KnownSymbol sym, ToHttpApiData v, HasLink sub, SBoolI (FoldRequired mods)) => HasLink (QueryParam' mods sym v :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (QueryParam' mods sym v :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (QueryParam' mods sym v :> sub) -> Link -> MkLink (QueryParam' mods sym v :> sub) a #

(KnownSymbol sym, FromHttpApiData a, HasServer api context, SBoolI (FoldRequired mods), SBoolI (FoldLenient mods)) => HasServer (QueryParam' mods 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...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (QueryParam' mods sym a :> api) m :: * #

Methods

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

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 #

type MkLink (QueryParam' mods sym v :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (QueryParam' mods sym v :> sub :: *) a = If (FoldRequired mods) v (Maybe v) -> MkLink sub a
type ServerT (QueryParam' mods sym a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (QueryParam' mods sym a :> api :: *) m = RequestArgument mods a -> ServerT api m

data QueryParams (sym :: Symbol) a #

Lookup the values associated to the sym query string parameter and try to extract it as a value of type [a]. This is typically meant to support query string parameters of the form param[]=val1&param[]=val2 and so on. Note that servant doesn't actually require the []s and will fetch the values just fine with param=val1&param=val2, too.

Example:

>>> -- /books?authors[]=<author1>&authors[]=<author2>&...
>>> type MyApi = "books" :> QueryParams "authors" Text :> Get '[JSON] [Book]
Instances
(KnownSymbol sym, ToHttpApiData v, HasLink sub) => HasLink (QueryParams sym v :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (QueryParams sym v :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (QueryParams sym v :> sub) -> Link -> MkLink (QueryParams sym v :> sub) a #

(KnownSymbol sym, FromHttpApiData a, HasServer api context) => HasServer (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...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (QueryParams sym a :> api) m :: * #

Methods

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

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 #

type MkLink (QueryParams sym v :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (QueryParams sym v :> sub :: *) a = [v] -> MkLink sub a
type ServerT (QueryParams sym a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (QueryParams sym a :> api :: *) m = [a] -> ServerT api m

data QueryFlag (sym :: Symbol) #

Lookup a potentially value-less query string parameter with boolean semantics. If the param sym is there without any value, or if it's there with value "true" or "1", it's interpreted as True. Otherwise, it's interpreted as False.

Example:

>>> -- /books?published
>>> type MyApi = "books" :> QueryFlag "published" :> Get '[JSON] [Book]
Instances
(KnownSymbol sym, HasLink sub) => HasLink (QueryFlag sym :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (QueryFlag sym :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (QueryFlag sym :> sub) -> Link -> MkLink (QueryFlag sym :> sub) a #

(KnownSymbol sym, HasServer api context) => HasServer (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...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (QueryFlag sym :> api) m :: * #

Methods

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

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

type MkLink (QueryFlag sym :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (QueryFlag sym :> sub :: *) a = Bool -> MkLink sub a
type ServerT (QueryFlag sym :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (QueryFlag sym :> api :: *) m = Bool -> ServerT api m

type Header = (Header' (Optional ': (Strict ': ([] :: [*]))) :: Symbol -> k -> *) #

Extract the given header's value as a value of type a. I.e. header sent by client, parsed by server.

Example:

>>> newtype Referer = Referer Text deriving (Eq, Show)
>>> 
>>> -- GET /view-my-referer
>>> type MyApi = "view-my-referer" :> Header "from" Referer :> Get '[JSON] Referer

data Header' (mods :: [*]) (sym :: Symbol) (a :: k) :: forall k. [*] -> Symbol -> k -> * #

Instances
(KnownSymbol h, ToHttpApiData v) => AddHeader h v (Headers (fst ': rest) a) (Headers (Header h v ': (fst ': rest)) a) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

addOptionalHeader :: ResponseHeader h v -> Headers (fst ': rest) a -> Headers (Header h v ': (fst ': rest)) a

HasLink sub => HasLink (Header' mods sym a :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Header' mods sym a :> sub) a :: * #

Methods

toLink :: (Link -> a0) -> Proxy (Header' mods sym a :> sub) -> Link -> MkLink (Header' mods sym a :> sub) a0 #

(KnownSymbol sym, FromHttpApiData a, HasServer api context, SBoolI (FoldRequired mods), SBoolI (FoldLenient mods)) => HasServer (Header' mods 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
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Header' mods sym a :> api) m :: * #

Methods

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

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 #

(KnownSymbol h, ToHttpApiData x, GetHeadersFromHList xs) => GetHeadersFromHList (Header h x ': xs) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeadersFromHList :: HList (Header h x ': xs) -> [Header0]

(KnownSymbol h, GetHeadersFromHList rest, ToHttpApiData v) => GetHeaders' (Header h v ': rest) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeaders' :: Headers (Header h v ': rest) a -> [Header0]

(FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h) => BuildHeadersTo (Header h v ': xs) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

buildHeadersTo :: [Header0] -> HList (Header h v ': xs) #

type MkLink (Header' mods sym a :> sub :: *) r 
Instance details

Defined in Servant.Links

type MkLink (Header' mods sym a :> sub :: *) r = MkLink sub r
type ServerT (Header' mods sym a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Header' mods sym a :> api :: *) m = RequestArgument mods a -> ServerT api m

data Required #

Required argument. Not wrapped.

data Optional #

Optional argument. Wrapped in Maybe.

Instances
(KnownSymbol h, ToHttpApiData v) => AddHeader h v (Headers (fst ': rest) a) (Headers (Header h v ': (fst ': rest)) a) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

addOptionalHeader :: ResponseHeader h v -> Headers (fst ': rest) a -> Headers (Header h v ': (fst ': rest)) a

(KnownSymbol h, ToHttpApiData x, GetHeadersFromHList xs) => GetHeadersFromHList (Header h x ': xs) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeadersFromHList :: HList (Header h x ': xs) -> [Header0]

(KnownSymbol h, GetHeadersFromHList rest, ToHttpApiData v) => GetHeaders' (Header h v ': rest) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeaders' :: Headers (Header h v ': rest) a -> [Header0]

(FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h) => BuildHeadersTo (Header h v ': xs) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

buildHeadersTo :: [Header0] -> HList (Header h v ': xs) #

data Lenient #

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

data Strict #

Strictly parsed argument. Not wrapped.

Instances
(KnownSymbol h, ToHttpApiData v) => AddHeader h v (Headers (fst ': rest) a) (Headers (Header h v ': (fst ': rest)) a) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

addOptionalHeader :: ResponseHeader h v -> Headers (fst ': rest) a -> Headers (Header h v ': (fst ': rest)) a

(KnownSymbol h, ToHttpApiData x, GetHeadersFromHList xs) => GetHeadersFromHList (Header h x ': xs) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeadersFromHList :: HList (Header h x ': xs) -> [Header0]

(KnownSymbol h, GetHeadersFromHList rest, ToHttpApiData v) => GetHeaders' (Header h v ': rest) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

getHeaders' :: Headers (Header h v ': rest) a -> [Header0]

(FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h) => BuildHeadersTo (Header h v ': xs) 
Instance details

Defined in Servant.API.ResponseHeaders

Methods

buildHeadersTo :: [Header0] -> HList (Header h v ': xs) #

data IsSecure #

Was this request made over an SSL connection?

Note that this value will not tell you if the client originally made this request over SSL, but rather whether the current connection is SSL. The distinction lies with reverse proxies. In many cases, the client will connect to a load balancer over SSL, but connect to the WAI handler without SSL. In such a case, the handlers would get NotSecure, but from a user perspective, there is a secure connection.

Constructors

Secure

the connection to the server is secure (HTTPS)

NotSecure

the connection to the server is not secure (HTTP)

Instances
Eq IsSecure 
Instance details

Defined in Servant.API.IsSecure

Ord IsSecure 
Instance details

Defined in Servant.API.IsSecure

Read IsSecure 
Instance details

Defined in Servant.API.IsSecure

Show IsSecure 
Instance details

Defined in Servant.API.IsSecure

Generic IsSecure 
Instance details

Defined in Servant.API.IsSecure

Associated Types

type Rep IsSecure :: * -> * #

Methods

from :: IsSecure -> Rep IsSecure x #

to :: Rep IsSecure x -> IsSecure #

HasLink sub => HasLink (IsSecure :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (IsSecure :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (IsSecure :> sub) -> Link -> MkLink (IsSecure :> sub) a #

HasServer api context => HasServer (IsSecure :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

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

Methods

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

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

type Rep IsSecure 
Instance details

Defined in Servant.API.IsSecure

type Rep IsSecure = D1 (MetaData "IsSecure" "Servant.API.IsSecure" "servant-0.14.1-Kxp99gef9WABsGE0PQ92ss" False) (C1 (MetaCons "Secure" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "NotSecure" PrefixI False) (U1 :: * -> *))
type MkLink (IsSecure :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (IsSecure :> sub :: *) a = MkLink sub a
type ServerT (IsSecure :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (IsSecure :> api :: *) m = IsSecure -> ServerT api m

data AuthProtect (tag :: k) :: forall k. k -> * #

A generalized Authentication combinator. Use this if you have a non-standard authentication technique.

NOTE: THIS API IS EXPERIMENTAL AND SUBJECT TO CHANGE.

Instances
HasLink sub => HasLink (AuthProtect tag :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (AuthProtect tag :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (AuthProtect tag :> sub) -> Link -> MkLink (AuthProtect tag :> sub) a #

type MkLink (AuthProtect tag :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (AuthProtect tag :> sub :: *) a = MkLink sub a

data EmptyAPI #

An empty API: one which serves nothing. Morally speaking, this should be the unit of :<|>. Implementors of interpretations of API types should treat EmptyAPI as close to the unit as possible.

Constructors

EmptyAPI 
Instances
Bounded EmptyAPI 
Instance details

Defined in Servant.API.Empty

Enum EmptyAPI 
Instance details

Defined in Servant.API.Empty

Eq EmptyAPI 
Instance details

Defined in Servant.API.Empty

Show EmptyAPI 
Instance details

Defined in Servant.API.Empty

HasLink EmptyAPI 
Instance details

Defined in Servant.Links

Associated Types

type MkLink EmptyAPI a :: * #

Methods

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

HasServer EmptyAPI context

The server for an EmptyAPI is emptyAPIServer.

type MyApi = "nothing" :> EmptyApi

server :: Server MyApi
server = emptyAPIServer
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT EmptyAPI m :: * #

Methods

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

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

type MkLink EmptyAPI a 
Instance details

Defined in Servant.Links

type ServerT EmptyAPI m 
Instance details

Defined in Servant.Server.Internal

data Summary (sym :: Symbol) #

Add a short summary for (part of) API.

Example:

>>> type MyApi = Summary "Get book by ISBN." :> "books" :> Capture "isbn" Text :> Get '[JSON] Book
Instances
HasLink sub => HasLink (Summary s :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Summary s :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (Summary s :> sub) -> Link -> MkLink (Summary s :> sub) a #

HasServer api ctx => HasServer (Summary desc :> api :: *) ctx

Ignore Summary in server handlers.

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Summary desc :> api) m :: * #

Methods

route :: Proxy (Summary desc :> api) -> Context ctx -> Delayed env (Server (Summary desc :> api)) -> Router env #

hoistServerWithContext :: Proxy (Summary desc :> api) -> Proxy ctx -> (forall x. m x -> n x) -> ServerT (Summary desc :> api) m -> ServerT (Summary desc :> api) n #

type MkLink (Summary s :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (Summary s :> sub :: *) a = MkLink sub a
type ServerT (Summary desc :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Summary desc :> api :: *) m = ServerT api m

data Description (sym :: Symbol) #

Add more verbose description for (part of) API.

Example:

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

Defined in Servant.Links

Associated Types

type MkLink (Description s :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (Description s :> sub) -> Link -> MkLink (Description s :> sub) a #

HasServer api ctx => HasServer (Description desc :> api :: *) ctx

Ignore Description in server handlers.

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Description desc :> api) m :: * #

Methods

route :: Proxy (Description desc :> api) -> Context ctx -> Delayed env (Server (Description desc :> api)) -> Router env #

hoistServerWithContext :: Proxy (Description desc :> api) -> Proxy ctx -> (forall x. m x -> n x) -> ServerT (Description desc :> api) m -> ServerT (Description desc :> api) n #

type MkLink (Description s :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (Description s :> sub :: *) a = MkLink sub a
type ServerT (Description desc :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Description desc :> api :: *) m = ServerT api m

data JSON #

Instances
Accept JSON
application/json
Instance details

Defined in Servant.API.ContentTypes

ToJSON a => MimeRender JSON a

encode

Instance details

Defined in Servant.API.ContentTypes

Methods

mimeRender :: Proxy JSON -> a -> ByteString #

FromJSON a => MimeUnrender JSON a

eitherDecode

Instance details

Defined in Servant.API.ContentTypes

data PlainText #

Instances
Accept PlainText
text/plain;charset=utf-8
Instance details

Defined in Servant.API.ContentTypes

MimeRender PlainText String
BC.pack
Instance details

Defined in Servant.API.ContentTypes

MimeRender PlainText Text
fromStrict . TextS.encodeUtf8
Instance details

Defined in Servant.API.ContentTypes

MimeRender PlainText Text

encodeUtf8

Instance details

Defined in Servant.API.ContentTypes

MimeUnrender PlainText String
Right . BC.unpack
Instance details

Defined in Servant.API.ContentTypes

MimeUnrender PlainText Text
left show . TextS.decodeUtf8' . toStrict
Instance details

Defined in Servant.API.ContentTypes

MimeUnrender PlainText Text
left show . TextL.decodeUtf8'
Instance details

Defined in Servant.API.ContentTypes

data FormUrlEncoded #

Instances
Accept FormUrlEncoded
application/x-www-form-urlencoded
Instance details

Defined in Servant.API.ContentTypes

ToForm a => MimeRender FormUrlEncoded a

urlEncodeAsForm Note that the mimeUnrender p (mimeRender p x) == Right x law only holds if every element of x is non-null (i.e., not ("", ""))

Instance details

Defined in Servant.API.ContentTypes

FromForm a => MimeUnrender FormUrlEncoded a

urlDecodeAsForm Note that the mimeUnrender p (mimeRender p x) == Right x law only holds if every element of x is non-null (i.e., not ("", ""))

Instance details

Defined in Servant.API.ContentTypes

class Accept (ctype :: k) where #

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

Example:

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

Minimal complete definition

contentType | contentTypes

Instances
Accept JSON
application/json
Instance details

Defined in Servant.API.ContentTypes

Accept PlainText
text/plain;charset=utf-8
Instance details

Defined in Servant.API.ContentTypes

Accept FormUrlEncoded
application/x-www-form-urlencoded
Instance details

Defined in Servant.API.ContentTypes

Accept OctetStream
application/octet-stream
Instance details

Defined in Servant.API.ContentTypes

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

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

Example:

data MyContentType

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

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

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

Minimal complete definition

mimeRender

Methods

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

Instances
ToJSON a => MimeRender JSON a

encode

Instance details

Defined in Servant.API.ContentTypes

Methods

mimeRender :: Proxy JSON -> a -> ByteString #

MimeRender PlainText String
BC.pack
Instance details

Defined in Servant.API.ContentTypes

MimeRender PlainText Text
fromStrict . TextS.encodeUtf8
Instance details

Defined in Servant.API.ContentTypes

MimeRender PlainText Text

encodeUtf8

Instance details

Defined in Servant.API.ContentTypes

ToForm a => MimeRender FormUrlEncoded a

urlEncodeAsForm Note that the mimeUnrender p (mimeRender p x) == Right x law only holds if every element of x is non-null (i.e., not ("", ""))

Instance details

Defined in Servant.API.ContentTypes

MimeRender OctetStream ByteString

fromStrict

Instance details

Defined in Servant.API.ContentTypes

MimeRender OctetStream ByteString
id
Instance details

Defined in Servant.API.ContentTypes

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

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

>>> import Network.HTTP.Media hiding (Accept)
>>> import qualified Data.ByteString.Lazy.Char8 as BSC
>>> data MyContentType = MyContentType String
>>> :{
instance Accept MyContentType where
   contentType _ = "example" // "prs.me.mine" /: ("charset", "utf-8")
:}
>>> :{
instance Read a => MimeUnrender MyContentType a where
   mimeUnrender _ bs = case BSC.take 12 bs of
     "MyContentType" -> return . read . BSC.unpack $ BSC.drop 12 bs
     _ -> Left "didn't start with the magic incantation"
:}
>>> type MyAPI = "path" :> ReqBody '[MyContentType] Int :> Get '[JSON] Int

Minimal complete definition

mimeUnrender | mimeUnrenderWithType

Methods

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

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

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

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

Instances
FromJSON a => MimeUnrender JSON a

eitherDecode

Instance details

Defined in Servant.API.ContentTypes

MimeUnrender PlainText String
Right . BC.unpack
Instance details

Defined in Servant.API.ContentTypes

MimeUnrender PlainText Text
left show . TextS.decodeUtf8' . toStrict
Instance details

Defined in Servant.API.ContentTypes

MimeUnrender PlainText Text
left show . TextL.decodeUtf8'
Instance details

Defined in Servant.API.ContentTypes

FromForm a => MimeUnrender FormUrlEncoded a

urlDecodeAsForm Note that the mimeUnrender p (mimeRender p x) == Right x law only holds if every element of x is non-null (i.e., not ("", ""))

Instance details

Defined in Servant.API.ContentTypes

MimeUnrender OctetStream ByteString
Right . toStrict
Instance details

Defined in Servant.API.ContentTypes

MimeUnrender OctetStream ByteString
Right . id
Instance details

Defined in Servant.API.ContentTypes

data NoContent #

A type for responses without content-body.

Constructors

NoContent 
Instances
Eq NoContent 
Instance details

Defined in Servant.API.ContentTypes

Read NoContent 
Instance details

Defined in Servant.API.ContentTypes

Show NoContent 
Instance details

Defined in Servant.API.ContentTypes

Generic NoContent 
Instance details

Defined in Servant.API.ContentTypes

Associated Types

type Rep NoContent :: * -> * #

Accept ctyp => AllMimeRender (ctyp ': ([] :: [*])) NoContent 
Instance details

Defined in Servant.API.ContentTypes

Methods

allMimeRender :: Proxy (ctyp ': []) -> NoContent -> [(MediaType, ByteString)] #

AllMime (ctyp ': (ctyp' ': ctyps)) => AllMimeRender (ctyp ': (ctyp' ': ctyps)) NoContent 
Instance details

Defined in Servant.API.ContentTypes

Methods

allMimeRender :: Proxy (ctyp ': (ctyp' ': ctyps)) -> NoContent -> [(MediaType, ByteString)] #

type Rep NoContent 
Instance details

Defined in Servant.API.ContentTypes

type Rep NoContent = D1 (MetaData "NoContent" "Servant.API.ContentTypes" "servant-0.14.1-Kxp99gef9WABsGE0PQ92ss" False) (C1 (MetaCons "NoContent" PrefixI False) (U1 :: * -> *))

type Capture = Capture' ([] :: [*]) #

Capture a value from the request path under a certain type a.

Example:

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

data Capture' (mods :: [*]) (sym :: Symbol) a #

Capture which can be modified. For example with Description.

Instances
(ToHttpApiData v, HasLink sub) => HasLink (Capture' mods sym v :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (Capture' mods sym v :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (Capture' mods sym v :> sub) -> Link -> MkLink (Capture' mods sym v :> sub) a #

(KnownSymbol capture, FromHttpApiData a, HasServer api context) => HasServer (Capture' mods 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 = ...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Capture' mods capture a :> api) m :: * #

Methods

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

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 #

type MkLink (Capture' mods sym v :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (Capture' mods sym v :> sub :: *) a = v -> MkLink sub a
type ServerT (Capture' mods capture a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (Capture' mods capture a :> api :: *) m = a -> ServerT api m

data CaptureAll (sym :: Symbol) a #

Capture all remaining values from the request path under a certain type a.

Example:

>>> -- GET /src/*
>>> type MyAPI = "src" :> CaptureAll "segments" Text :> Get '[JSON] SourceFile
Instances
(ToHttpApiData v, HasLink sub) => HasLink (CaptureAll sym v :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (CaptureAll sym v :> sub) a :: * #

Methods

toLink :: (Link -> a) -> Proxy (CaptureAll sym v :> sub) -> Link -> MkLink (CaptureAll sym v :> sub) a #

(KnownSymbol capture, FromHttpApiData a, HasServer api context) => HasServer (CaptureAll capture a :> api :: *) 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 = ...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (CaptureAll capture a :> api) m :: * #

Methods

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

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 #

type MkLink (CaptureAll sym v :> sub :: *) a 
Instance details

Defined in Servant.Links

type MkLink (CaptureAll sym v :> sub :: *) a = [v] -> MkLink sub a
type ServerT (CaptureAll capture a :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (CaptureAll capture a :> api :: *) m = [a] -> ServerT api m

data BasicAuth (realm :: Symbol) userData #

Combinator for Basic Access Authentication.

  • IMPORTANT*: Only use Basic Auth over HTTPS! Credentials are not hashed or encrypted. Note also that because the same credentials are sent on every request, Basic Auth is not as secure as some alternatives. Further, the implementation in servant-server does not protect against some types of timing attacks.

In Basic Auth, username and password are base64-encoded and transmitted via the Authorization header. Handshakes are not required, making it relatively efficient.

Instances
HasLink sub => HasLink (BasicAuth realm a :> sub :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (BasicAuth realm a :> sub) a :: * #

Methods

toLink :: (Link -> a0) -> Proxy (BasicAuth realm a :> sub) -> Link -> MkLink (BasicAuth realm a :> sub) a0 #

(KnownSymbol realm, HasServer api context, HasContextEntry context (BasicAuthCheck usr)) => HasServer (BasicAuth realm usr :> api :: *) context

Basic Authentication

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (BasicAuth realm usr :> api) m :: * #

Methods

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

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 #

type MkLink (BasicAuth realm a :> sub :: *) r 
Instance details

Defined in Servant.Links

type MkLink (BasicAuth realm a :> sub :: *) r = MkLink sub r
type ServerT (BasicAuth realm usr :> api :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (BasicAuth realm usr :> api :: *) m = usr -> ServerT api m

data BasicAuthData #

A simple datatype to hold data required to decorate a request

data a :<|> b infixr 3 #

Union of two APIs, first takes precedence in case of overlap.

Example:

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

Constructors

a :<|> b infixr 3 
Instances
Functor ((:<|>) a) 
Instance details

Defined in Servant.API.Alternative

Methods

fmap :: (a0 -> b) -> (a :<|> a0) -> a :<|> b #

(<$) :: a0 -> (a :<|> b) -> a :<|> a0 #

Foldable ((:<|>) a) 
Instance details

Defined in Servant.API.Alternative

Methods

fold :: Monoid m => (a :<|> m) -> m #

foldMap :: Monoid m => (a0 -> m) -> (a :<|> a0) -> m #

foldr :: (a0 -> b -> b) -> b -> (a :<|> a0) -> b #

foldr' :: (a0 -> b -> b) -> b -> (a :<|> a0) -> b #

foldl :: (b -> a0 -> b) -> b -> (a :<|> a0) -> b #

foldl' :: (b -> a0 -> b) -> b -> (a :<|> a0) -> b #

foldr1 :: (a0 -> a0 -> a0) -> (a :<|> a0) -> a0 #

foldl1 :: (a0 -> a0 -> a0) -> (a :<|> a0) -> a0 #

toList :: (a :<|> a0) -> [a0] #

null :: (a :<|> a0) -> Bool #

length :: (a :<|> a0) -> Int #

elem :: Eq a0 => a0 -> (a :<|> a0) -> Bool #

maximum :: Ord a0 => (a :<|> a0) -> a0 #

minimum :: Ord a0 => (a :<|> a0) -> a0 #

sum :: Num a0 => (a :<|> a0) -> a0 #

product :: Num a0 => (a :<|> a0) -> a0 #

Traversable ((:<|>) a) 
Instance details

Defined in Servant.API.Alternative

Methods

traverse :: Applicative f => (a0 -> f b) -> (a :<|> a0) -> f (a :<|> b) #

sequenceA :: Applicative f => (a :<|> f a0) -> f (a :<|> a0) #

mapM :: Monad m => (a0 -> m b) -> (a :<|> a0) -> m (a :<|> b) #

sequence :: Monad m => (a :<|> m a0) -> m (a :<|> a0) #

(HasLink a, HasLink b) => HasLink (a :<|> b :: *) 
Instance details

Defined in Servant.Links

Associated Types

type MkLink (a :<|> b) a :: * #

Methods

toLink :: (Link -> a0) -> Proxy (a :<|> b) -> Link -> MkLink (a :<|> b) a0 #

(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 = ...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (a :<|> b) m :: * #

Methods

route :: Proxy (a :<|> b) -> Context context -> Delayed env (Server (a :<|> b)) -> Router env #

hoistServerWithContext :: Proxy (a :<|> b) -> Proxy context -> (forall x. m x -> n x) -> ServerT (a :<|> b) m -> ServerT (a :<|> b) n #

(Bounded a, Bounded b) => Bounded (a :<|> b) 
Instance details

Defined in Servant.API.Alternative

Methods

minBound :: a :<|> b #

maxBound :: a :<|> b #

(Eq a, Eq b) => Eq (a :<|> b) 
Instance details

Defined in Servant.API.Alternative

Methods

(==) :: (a :<|> b) -> (a :<|> b) -> Bool #

(/=) :: (a :<|> b) -> (a :<|> b) -> Bool #

(Show a, Show b) => Show (a :<|> b) 
Instance details

Defined in Servant.API.Alternative

Methods

showsPrec :: Int -> (a :<|> b) -> ShowS #

show :: (a :<|> b) -> String #

showList :: [a :<|> b] -> ShowS #

(Semigroup a, Semigroup b) => Semigroup (a :<|> b) 
Instance details

Defined in Servant.API.Alternative

Methods

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

sconcat :: NonEmpty (a :<|> b) -> a :<|> b #

stimes :: Integral b0 => b0 -> (a :<|> b) -> a :<|> b #

(Monoid a, Monoid b) => Monoid (a :<|> b) 
Instance details

Defined in Servant.API.Alternative

Methods

mempty :: a :<|> b #

mappend :: (a :<|> b) -> (a :<|> b) -> a :<|> b #

mconcat :: [a :<|> b] -> a :<|> b #

type MkLink (a :<|> b :: *) r 
Instance details

Defined in Servant.Links

type MkLink (a :<|> b :: *) r = MkLink a r :<|> MkLink b r
type ServerT (a :<|> b :: *) m 
Instance details

Defined in Servant.Server.Internal

type ServerT (a :<|> b :: *) m = ServerT a m :<|> ServerT b m

type Vault = Vault RealWorld #

A persistent store for values of arbitrary types.

This variant is the simplest and creates keys in the IO monad. See the module Data.Vault.ST if you want to use it with the ST monad instead.

class SBoolI (b :: Bool) where #

Minimal complete definition

sbool

Methods

sbool :: SBool b #

Instances
SBoolI False 
Instance details

Defined in Data.Singletons.Bool

Methods

sbool :: SBool False #

SBoolI True 
Instance details

Defined in Data.Singletons.Bool

Methods

sbool :: SBool True #

data SBool (b :: Bool) where #

Constructors

STrue :: SBool True 
SFalse :: SBool False 

serveDirectory :: FilePath -> ServerT Raw m #

Same as serveDirectoryFileServer. It used to be the only file serving function in servant pre-0.10 and will be kept around for a few versions, but is deprecated.

serveDirectoryWith :: StaticSettings -> ServerT Raw m #

Alias for staticApp. Lets you serve a directory with arbitrary StaticSettings. Useful when you want particular settings not covered by the four other variants. This is the most flexible method.

serveDirectoryWebApp :: FilePath -> ServerT Raw m #

Serve anything under the specified directory as a Raw endpoint.

type MyApi = "static" :> Raw

server :: Server MyApi
server = serveDirectoryWebApp "/var/www"

would capture any request to /static/<something> and look for <something> under /var/www.

It will do its best to guess the MIME type for that file, based on the extension, and send an appropriate Content-Type header if possible.

If your goal is to serve HTML, CSS and Javascript files that use the rest of the API as a webapp backend, you will most likely not want the static files to be hidden behind a /static/ prefix. In that case, remember to put the serveDirectoryWebApp handler in the last position, because servant will try to match the handlers in order.

Corresponds to the defaultWebAppSettings StaticSettings value.

layoutWithContext :: HasServer api context => Proxy api -> Context context -> Text #

Variant of layout that takes an additional Context.

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.

hoistServer :: HasServer api ([] :: [*]) => Proxy api -> (forall x. m x -> n x) -> ServerT api m -> ServerT api n #

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

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

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

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

Minimal complete definition

route, hoistServerWithContext

Associated Types

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

Methods

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 #

Instances
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"
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT Raw m :: * #

Methods

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

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

HasServer EmptyAPI context

The server for an EmptyAPI is emptyAPIServer.

type MyApi = "nothing" :> EmptyApi

server :: Server MyApi
server = emptyAPIServer
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT EmptyAPI m :: * #

Methods

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

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

(TypeError (HasServerArrowTypeError a b) :: Constraint) => HasServer (a -> b :: *) context

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

Associated Types

type ServerT (a -> b) m :: * #

Methods

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

hoistServerWithContext :: Proxy (a -> b) -> Proxy context -> (forall x. m x -> n x) -> ServerT (a -> b) m -> ServerT (a -> b) n #

(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 = ...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (a :<|> b) m :: * #

Methods

route :: Proxy (a :<|> b) -> Context context -> Delayed env (Server (a :<|> b)) -> Router env #

hoistServerWithContext :: Proxy (a :<|> b) -> Proxy context -> (forall x. m x -> n x) -> ServerT (a :<|> b) m -> ServerT (a :<|> b) n #

(HasContextEntry context (NamedContext name subContext), HasServer subApi subContext) => HasServer (WithNamedContext name subContext subApi :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (WithNamedContext name subContext subApi) m :: * #

Methods

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

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 #

(TypeError (HasServerArrowKindError arr) :: Constraint) => HasServer (arr :> api :: *) context

This instance catches mistakes when there are non-saturated type applications on LHS of :>.

>>> serve (Proxy :: Proxy (Capture "foo" :> Get '[JSON] Int)) (error "...")
...
...Expected something of kind Symbol or *, got: k -> l on the LHS of ':>'.
...Maybe you haven't applied enough arguments to
...Capture' '[] "foo"
...
>>> undefined :: Server (Capture "foo" :> Get '[JSON] Int)
...
...Expected something of kind Symbol or *, got: k -> l on the LHS of ':>'.
...Maybe you haven't applied enough arguments to
...Capture' '[] "foo"
...
Instance details

Defined in Servant.Server.Internal

Associated Types

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

Methods

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

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

HasServer api context => HasServer (HttpVersion :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

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

Methods

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

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

(AllCTUnrender list a, HasServer api context, SBoolI (FoldLenient mods)) => HasServer (ReqBody' mods 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...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (ReqBody' mods list a :> api) m :: * #

Methods

route :: Proxy (ReqBody' mods list a :> api) -> Context context -> Delayed env (Server (ReqBody' mods list a :> api)) -> Router env #

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 #

HasServer api context => HasServer (RemoteHost :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

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

Methods

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

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

(KnownSymbol sym, FromHttpApiData a, HasServer api context, SBoolI (FoldRequired mods), SBoolI (FoldLenient mods)) => HasServer (QueryParam' mods 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...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (QueryParam' mods sym a :> api) m :: * #

Methods

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

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 #

(KnownSymbol sym, FromHttpApiData a, HasServer api context) => HasServer (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...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (QueryParams sym a :> api) m :: * #

Methods

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

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 #

(KnownSymbol sym, HasServer api context) => HasServer (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...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (QueryFlag sym :> api) m :: * #

Methods

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

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

(KnownSymbol sym, FromHttpApiData a, HasServer api context, SBoolI (FoldRequired mods), SBoolI (FoldLenient mods)) => HasServer (Header' mods 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
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Header' mods sym a :> api) m :: * #

Methods

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

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 #

HasServer api context => HasServer (IsSecure :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

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

Methods

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

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

HasServer api ctx => HasServer (Summary desc :> api :: *) ctx

Ignore Summary in server handlers.

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Summary desc :> api) m :: * #

Methods

route :: Proxy (Summary desc :> api) -> Context ctx -> Delayed env (Server (Summary desc :> api)) -> Router env #

hoistServerWithContext :: Proxy (Summary desc :> api) -> Proxy ctx -> (forall x. m x -> n x) -> ServerT (Summary desc :> api) m -> ServerT (Summary desc :> api) n #

HasServer api ctx => HasServer (Description desc :> api :: *) ctx

Ignore Description in server handlers.

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Description desc :> api) m :: * #

Methods

route :: Proxy (Description desc :> api) -> Context ctx -> Delayed env (Server (Description desc :> api)) -> Router env #

hoistServerWithContext :: Proxy (Description desc :> api) -> Proxy ctx -> (forall x. m x -> n x) -> ServerT (Description desc :> api) m -> ServerT (Description desc :> api) n #

(KnownSymbol capture, FromHttpApiData a, HasServer api context) => HasServer (Capture' mods 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 = ...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Capture' mods capture a :> api) m :: * #

Methods

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

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 #

(KnownSymbol capture, FromHttpApiData a, HasServer api context) => HasServer (CaptureAll capture a :> api :: *) 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 = ...
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (CaptureAll capture a :> api) m :: * #

Methods

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

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 #

(KnownSymbol realm, HasServer api context, HasContextEntry context (BasicAuthCheck usr)) => HasServer (BasicAuth realm usr :> api :: *) context

Basic Authentication

Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (BasicAuth realm usr :> api) m :: * #

Methods

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

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 #

HasServer api context => HasServer (Vault :> api :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

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

Methods

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

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

(KnownSymbol path, HasServer api context) => HasServer (path :> api :: *) context

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

Associated Types

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

Methods

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

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

(AllCTRender ctypes a, ReflectMethod method, KnownNat status) => HasServer (Verb method status ctypes a :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Verb method status ctypes a) m :: * #

Methods

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

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 #

(AllCTRender ctypes a, ReflectMethod method, KnownNat status, GetHeaders (Headers h a)) => HasServer (Verb method status ctypes (Headers h a) :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Verb method status ctypes (Headers h a)) m :: * #

Methods

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

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 #

(MimeRender ctype a, ReflectMethod method, KnownNat status, FramingRender framing ctype, ToStreamGenerator b a) => HasServer (Stream method status framing ctype b :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Stream method status framing ctype b) m :: * #

Methods

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

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

(MimeRender ctype a, ReflectMethod method, KnownNat status, FramingRender framing ctype, ToStreamGenerator b a, GetHeaders (Headers h b)) => HasServer (Stream method status framing ctype (Headers h b) :: *) context 
Instance details

Defined in Servant.Server.Internal

Associated Types

type ServerT (Stream method status framing ctype (Headers h b)) m :: * #

Methods

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

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

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

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

Instances
Functor BasicAuthResult 
Instance details

Defined in Servant.Server.Internal.BasicAuth

Methods

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

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

Eq usr => Eq (BasicAuthResult usr) 
Instance details

Defined in Servant.Server.Internal.BasicAuth

Read usr => Read (BasicAuthResult usr) 
Instance details

Defined in Servant.Server.Internal.BasicAuth

Show usr => Show (BasicAuthResult usr) 
Instance details

Defined in Servant.Server.Internal.BasicAuth

Generic (BasicAuthResult usr) 
Instance details

Defined in Servant.Server.Internal.BasicAuth

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) 
Instance details

Defined in Servant.Server.Internal.BasicAuth

type Rep (BasicAuthResult usr) = D1 (MetaData "BasicAuthResult" "Servant.Server.Internal.BasicAuth" "servant-server-0.14.1-8QeZlk3HyJYB7GKYC8rKfC" 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 :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 usr))))

newtype BasicAuthCheck usr #

Datatype wrapping a function used to check authentication.

Instances
Functor BasicAuthCheck 
Instance details

Defined in Servant.Server.Internal.BasicAuth

Methods

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

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

Generic (BasicAuthCheck usr) 
Instance details

Defined in Servant.Server.Internal.BasicAuth

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) 
Instance details

Defined in Servant.Server.Internal.BasicAuth

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

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

Apply a transformation to the response of a Router.

err505 :: ServantErr #

err505 HTTP Version not supported

Example usage:

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

err504 :: ServantErr #

err504 Gateway Time-out

Example:

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

err503 :: ServantErr #

err503 Service Unavailable

Example:

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

err502 :: ServantErr #

err502 Bad Gateway

Example:

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

err501 :: ServantErr #

err501 Not Implemented

Example:

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

err500 :: ServantErr #

err500 Internal Server Error

Example:

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

err422 :: ServantErr #

err422 Unprocessable Entity

Example:

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

err418 :: ServantErr #

err418 Expectation Failed

Example:

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

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." }

err416 :: ServantErr #

err416 Request range not satisfiable

Example:

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

err415 :: ServantErr #

err415 Unsupported Media Type

Example:

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

err414 :: ServantErr #

err414 Request-URI Too Large

Example:

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

err413 :: ServantErr #

err413 Request Entity Too Large

Example:

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

err412 :: ServantErr #

err412 Precondition Failed

Example:

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

err411 :: ServantErr #

err411 Length Required

Example:

failingHandler :: Handler ()
failingHandler = throwError err411

err410 :: ServantErr #

err410 Gone

Example:

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

err409 :: ServantErr #

err409 Conflict

Example:

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

err407 :: ServantErr #

err407 Proxy Authentication Required

Example:

failingHandler :: Handler ()
failingHandler = throwError err407

err406 :: ServantErr #

err406 Not Acceptable

Example:

failingHandler :: Handler ()
failingHandler = throwError err406

err405 :: ServantErr #

err405 Method Not Allowed

Example:

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

err404 :: ServantErr #

err404 Not Found

Example:

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

err403 :: ServantErr #

err403 Forbidden

Example:

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

err402 :: ServantErr #

err402 Payment Required

Example:

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

err401 :: ServantErr #

err401 Unauthorized

Example:

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

err400 :: ServantErr #

err400 Bad Request

Example:

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

err307 :: ServantErr #

err307 Temporary Redirect

Example:

failingHandler :: Handler ()
failingHandler = throwError err307

err305 :: ServantErr #

err305 Use Proxy

Example:

failingHandler :: Handler ()
failingHandler = throwError err305

err304 :: ServantErr #

err304 Not Modified

Example:

failingHandler :: Handler ()
failingHandler = throwError err304

err303 :: ServantErr #

err303 See Other

Example:

failingHandler :: Handler ()
failingHandler = throwError err303

err302 :: ServantErr #

err302 Found

Example:

failingHandler :: Handler ()
failingHandler = throwError err302

err301 :: ServantErr #

err301 Moved Permanently

Example:

failingHandler :: Handler ()
failingHandler = throwError err301

err300 :: ServantErr #

err300 Multiple Choices

Example:

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

descendIntoNamedContext :: HasContextEntry context (NamedContext name subContext) => Proxy name -> Context context -> Context subContext #

descendIntoNamedContext allows you to access NamedContexts. 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

data Context (contextTypes :: [*]) where #

Contexts 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 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 ([] :: [*]) 
(:.) :: Context (x ': xs) infixr 5 
Instances
(Eq a, Eq (Context as)) => Eq (Context (a ': as)) 
Instance details

Defined in Servant.Server.Internal.Context

Methods

(==) :: Context (a ': as) -> Context (a ': as) -> Bool #

(/=) :: Context (a ': as) -> Context (a ': as) -> Bool #

Eq (Context ([] :: [*])) 
Instance details

Defined in Servant.Server.Internal.Context

Methods

(==) :: Context [] -> Context [] -> Bool #

(/=) :: Context [] -> Context [] -> Bool #

(Show a, Show (Context as)) => Show (Context (a ': as)) 
Instance details

Defined in Servant.Server.Internal.Context

Methods

showsPrec :: Int -> Context (a ': as) -> ShowS #

show :: Context (a ': as) -> String #

showList :: [Context (a ': as)] -> ShowS #

Show (Context ([] :: [*])) 
Instance details

Defined in Servant.Server.Internal.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 Contexts. 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 xs val => HasContextEntry (notIt ': xs) val 
Instance details

Defined in Servant.Server.Internal.Context

Methods

getContextEntry :: Context (notIt ': xs) -> val #

HasContextEntry (val ': xs) val 
Instance details

Defined in Servant.Server.Internal.Context

Methods

getContextEntry :: Context (val ': xs) -> val #

data NamedContext (name :: Symbol) (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 Contexts.

Constructors

NamedContext (Context subContext) 

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 (s :: k) 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

Instances
ToJSON2 (Tagged :: * -> * -> *) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> Tagged a b -> Value #

liftToJSONList2 :: (a -> Value) -> ([a] -> Value) -> (b -> Value) -> ([b] -> Value) -> [Tagged a b] -> Value #

liftToEncoding2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> Tagged a b -> Encoding #

liftToEncodingList2 :: (a -> Encoding) -> ([a] -> Encoding) -> (b -> Encoding) -> ([b] -> Encoding) -> [Tagged a b] -> Encoding #

FromJSON2 (Tagged :: * -> * -> *) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser (Tagged a b) #

liftParseJSONList2 :: (Value -> Parser a) -> (Value -> Parser [a]) -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser [Tagged a b] #

Bitraversable (Tagged :: * -> * -> *) 
Instance details

Defined in Data.Tagged

Methods

bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Tagged a b -> f (Tagged c d) #

Bifoldable (Tagged :: * -> * -> *) 
Instance details

Defined in Data.Tagged

Methods

bifold :: Monoid m => Tagged m m -> m #

bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Tagged a b -> m #

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Tagged a b -> c #

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Tagged a b -> c #

Bifunctor (Tagged :: * -> * -> *) 
Instance details

Defined in Data.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 #

Eq2 (Tagged :: * -> * -> *) 
Instance details

Defined in Data.Tagged

Methods

liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> Tagged a c -> Tagged b d -> Bool #

Ord2 (Tagged :: * -> * -> *) 
Instance details

Defined in Data.Tagged

Methods

liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> Tagged a c -> Tagged b d -> Ordering #

Read2 (Tagged :: * -> * -> *) 
Instance details

Defined in Data.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] #

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

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

Show2 (Tagged :: * -> * -> *) 
Instance details

Defined in Data.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 #

Generic1 (Tagged s :: * -> *) 
Instance details

Defined in Data.Tagged

Associated Types

type Rep1 (Tagged s) :: k -> * #

Methods

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

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

Monad (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

(>>=) :: Tagged s a -> (a -> Tagged s b) -> Tagged s b #

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

return :: a -> Tagged s a #

fail :: String -> Tagged s a #

Functor (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

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

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

Applicative (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

pure :: a -> Tagged s a #

(<*>) :: Tagged s (a -> b) -> Tagged s a -> Tagged s b #

liftA2 :: (a -> b -> c) -> Tagged s a -> Tagged s b -> Tagged s c #

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

(<*) :: Tagged s a -> Tagged s b -> Tagged s a #

Foldable (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

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

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

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

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

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

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

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

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

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

null :: Tagged s a -> Bool #

length :: Tagged s a -> Int #

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

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

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

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

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

Traversable (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

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

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

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

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

ToJSON1 (Tagged a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Value) -> ([a0] -> Value) -> Tagged a a0 -> Value #

liftToJSONList :: (a0 -> Value) -> ([a0] -> Value) -> [Tagged a a0] -> Value #

liftToEncoding :: (a0 -> Encoding) -> ([a0] -> Encoding) -> Tagged a a0 -> Encoding #

liftToEncodingList :: (a0 -> Encoding) -> ([a0] -> Encoding) -> [Tagged a a0] -> Encoding #

FromJSON1 (Tagged a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (Tagged a a0) #

liftParseJSONList :: (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [Tagged a a0] #

Eq1 (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

liftEq :: (a -> b -> Bool) -> Tagged s a -> Tagged s b -> Bool #

Ord1 (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

liftCompare :: (a -> b -> Ordering) -> Tagged s a -> Tagged s b -> Ordering #

Read1 (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Tagged s a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Tagged s a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Tagged s a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Tagged s a] #

Show1 (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Tagged s a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Tagged s a] -> ShowS #

Bounded b => Bounded (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

minBound :: Tagged s b #

maxBound :: Tagged s b #

Enum a => Enum (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

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

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

toEnum :: Int -> Tagged s a #

fromEnum :: Tagged s a -> Int #

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

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

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

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

Eq b => Eq (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

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

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

Floating a => Floating (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

pi :: Tagged s a #

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Fractional a => Fractional (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

(/) :: Tagged s a -> Tagged s a -> Tagged s a #

recip :: Tagged s a -> Tagged s a #

fromRational :: Rational -> Tagged s a #

Integral a => Integral (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

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

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

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

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

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

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

toInteger :: Tagged s a -> Integer #

(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) #

gunfold :: (forall b0 r. Data b0 => c (b0 -> 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 b0. Data b0 => b0 -> b0) -> 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 s a) 
Instance details

Defined in Data.Tagged

Methods

(+) :: Tagged s a -> Tagged s a -> Tagged s a #

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

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

negate :: Tagged s a -> Tagged s a #

abs :: Tagged s a -> Tagged s a #

signum :: Tagged s a -> Tagged s a #

fromInteger :: Integer -> Tagged s a #

Ord b => Ord (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

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

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

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

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

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

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

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

Read b => Read (Tagged s b) 
Instance details

Defined in Data.Tagged

Real a => Real (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

toRational :: Tagged s a -> Rational #

RealFloat a => RealFloat (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

floatRadix :: Tagged s a -> Integer #

floatDigits :: Tagged s a -> Int #

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

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

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

exponent :: Tagged s a -> Int #

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

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

isNaN :: Tagged s a -> Bool #

isInfinite :: Tagged s a -> Bool #

isDenormalized :: Tagged s a -> Bool #

isNegativeZero :: Tagged s a -> Bool #

isIEEE :: Tagged s a -> Bool #

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

RealFrac a => RealFrac (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

properFraction :: Integral b => Tagged s a -> (b, Tagged s a) #

truncate :: Integral b => Tagged s a -> b #

round :: Integral b => Tagged s a -> b #

ceiling :: Integral b => Tagged s a -> b #

floor :: Integral b => Tagged s a -> b #

Show b => Show (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

showsPrec :: Int -> Tagged s b -> ShowS #

show :: Tagged s b -> String #

showList :: [Tagged s b] -> ShowS #

Ix b => Ix (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

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

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

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

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

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

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

IsString a => IsString (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

fromString :: String -> Tagged s a #

Generic (Tagged s b) 
Instance details

Defined in Data.Tagged

Associated Types

type Rep (Tagged s b) :: * -> * #

Methods

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

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

Semigroup a => Semigroup (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

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

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

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

(Semigroup a, Monoid a) => Monoid (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

mempty :: Tagged s a #

mappend :: Tagged s a -> Tagged s a -> Tagged s a #

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

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

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: Tagged a b -> Value #

toEncoding :: Tagged a b -> Encoding #

toJSONList :: [Tagged a b] -> Value #

toEncodingList :: [Tagged a b] -> Encoding #

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

Defined in Data.Aeson.Types.ToJSON

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

Defined in Data.Aeson.Types.FromJSON

Methods

parseJSON :: Value -> Parser (Tagged a b) #

parseJSONList :: Value -> Parser [Tagged a b] #

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

Defined in Data.Aeson.Types.FromJSON

Storable a => Storable (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

sizeOf :: Tagged s a -> Int #

alignment :: Tagged s a -> Int #

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

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

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

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

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

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

Bits a => Bits (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

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

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

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

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

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

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

zeroBits :: Tagged s a #

bit :: Int -> Tagged s a #

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

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

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

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

bitSizeMaybe :: Tagged s a -> Maybe Int #

bitSize :: Tagged s a -> Int #

isSigned :: Tagged s a -> Bool #

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

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

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

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

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

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

popCount :: Tagged s a -> Int #

FiniteBits a => FiniteBits (Tagged s a) 
Instance details

Defined in Data.Tagged

NFData b => NFData (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

rnf :: Tagged s b -> () #

type Rep1 (Tagged s :: * -> *) 
Instance details

Defined in Data.Tagged

type Rep1 (Tagged s :: * -> *) = D1 (MetaData "Tagged" "Data.Tagged" "tagged-0.8.6-8akQ1aZG2N2GFJpoB5eGXO" 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.6-8akQ1aZG2N2GFJpoB5eGXO" True) (C1 (MetaCons "Tagged" PrefixI True) (S1 (MetaSel (Just "unTagged") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 b)))

runMagicbaneHandler :: β -> RIO β α -> Handler α Source #

magicbaneApp :: forall β χ ψ. HasServer χ ψ => Proxy χ -> Context ψ -> β -> ServerT χ (RIO β) -> Application Source #

Constructs a WAI application from an API definition, a Servant context (used for auth mainly), the app context and the actual action handlers.

data RIO env a #

The Reader+IO monad. This is different from a ReaderT because:

  • It's not a transformer, it hardcodes IO for simpler usage and error messages.
  • Instances of typeclasses like MonadLogger are implemented using classes defined on the environment, instead of using an underlying monad.
Instances
MonadReader env (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Methods

ask :: RIO env env #

local :: (env -> env) -> RIO env a -> RIO env a #

reader :: (env -> a) -> RIO env a #

HasStateRef s env => MonadState s (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Methods

get :: RIO env s #

put :: s -> RIO env () #

state :: (s -> (a, s)) -> RIO env a #

(Monoid w, HasWriteRef w env) => MonadWriter w (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Methods

writer :: (a, w) -> RIO env a #

tell :: w -> RIO env () #

listen :: RIO env a -> RIO env (a, w) #

pass :: RIO env (a, w -> w) -> RIO env a #

Monad (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Methods

(>>=) :: RIO env a -> (a -> RIO env b) -> RIO env b #

(>>) :: RIO env a -> RIO env b -> RIO env b #

return :: a -> RIO env a #

fail :: String -> RIO env a #

Functor (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Methods

fmap :: (a -> b) -> RIO env a -> RIO env b #

(<$) :: a -> RIO env b -> RIO env a #

Applicative (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Methods

pure :: a -> RIO env a #

(<*>) :: RIO env (a -> b) -> RIO env a -> RIO env b #

liftA2 :: (a -> b -> c) -> RIO env a -> RIO env b -> RIO env c #

(*>) :: RIO env a -> RIO env b -> RIO env b #

(<*) :: RIO env a -> RIO env b -> RIO env a #

MonadIO (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Methods

liftIO :: IO a -> RIO env a #

MonadUnliftIO (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Methods

askUnliftIO :: RIO env (UnliftIO (RIO env)) #

withRunInIO :: ((forall a. RIO env a -> IO a) -> IO b) -> RIO env b #

PrimMonad (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Associated Types

type PrimState (RIO env) :: * #

Methods

primitive :: (State# (PrimState (RIO env)) -> (#State# (PrimState (RIO env)), a#)) -> RIO env a #

MonadThrow (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

Methods

throwM :: Exception e => e -> RIO env a #

type PrimState (RIO env) 
Instance details

Defined in RIO.Prelude.RIO

type PrimState (RIO env) = PrimState IO
type StM (RIO env) a 
Instance details

Defined in RIO.Orphans

type StM (RIO env) a = a