ocaml-export-0.3.0.0: Convert Haskell types in OCaml types

CopyrightPlow Technologies 2017
LicenseBSD3
Maintainermchaver@gmail.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

OCaml.Export

Description

 

Synopsis

Documentation

data OCamlPackage (packageName :: Symbol) (packageDependencies :: [*]) Source #

Instances

(HasOCamlTypeMetaData * (OCamlPackage packageName deps), HasOCamlTypeMetaData * rest) => HasOCamlTypeMetaData * ((:<|>) (OCamlPackage packageName deps) rest) Source #

packages

(HasOCamlTypeMetaData [*] deps, HasOCamlTypeMetaData k1 modules) => HasOCamlTypeMetaData * ((:>) * k1 (OCamlPackage packageName deps) modules) Source #

build a packages dependencies and its declared modules

Methods

mkOCamlTypeMetaData :: Proxy ((* :> k1) (OCamlPackage packageName deps) modules) a -> Map HaskellTypeMetaData OCamlTypeMetaData Source #

(HasOCamlTypeMetaData [*] deps, HasOCamlTypeMetaData k1 a, HasOCamlPackage' k1 a) => HasOCamlPackage * ((:>) * k1 (OCamlPackage packageName deps) a) Source # 

Methods

mkPackage :: Proxy ((* :> k1) (OCamlPackage packageName deps) a) a -> PackageOptions -> IO () Source #

type NoDependency = '[] Source #

data OCamlModule (modules :: [Symbol]) Source #

An OCamlModule as a Haskell type. File level modules is relative to a root directory prvoiided in the mkPackage function.

Instances

(KnownSymbols modules, HasOCamlTypeMetaData' k1 api) => HasOCamlTypeMetaData * ((:>) * k1 (OCamlModule modules) api) Source #

single module

(KnownSymbols modules, HasOCamlModule' k1 api) => HasOCamlModule * ((:>) * k1 (OCamlModule modules) api) Source # 

data OCamlSubModule (subModules :: Symbol) Source #

Symobl will be expaneded to "module SymbolName = struct ... end".

data OCamlTypeInFile a (filePath :: Symbol) Source #

A handwritten OCaml type, encoder and decoder from a file.

data PackageOptions Source #

Options for creating an OCaml package based on Haskell types.

Constructors

PackageOptions 

Fields

data SpecOptions Source #

Details for OCaml spec.

Constructors

SpecOptions 

Fields

mkFiles :: HasEmbeddedFile api => Bool -> Bool -> Proxy api -> Q Exp Source #

class OCamlType a where Source #

Create an OCaml type from a Haskell type. Use the Generic definition when possible. It also expects ToJSON and FromJSON to be derived generically.

Methods

toOCamlType :: a -> OCamlDatatype Source #

toOCamlType :: (Generic a, GenericOCamlDatatype (Rep a)) => a -> OCamlDatatype Source #

Instances

OCamlType Bool Source # 
OCamlType Char Source # 
OCamlType Double Source # 
OCamlType Float Source # 
OCamlType Int Source # 
OCamlType Int8 Source # 
OCamlType Int16 Source # 
OCamlType Int32 Source # 
OCamlType Int64 Source # 
OCamlType Integer Source # 
OCamlType Word Source # 
OCamlType Word8 Source # 
OCamlType Word16 Source # 
OCamlType Word32 Source # 
OCamlType Word64 Source # 
OCamlType () Source # 
OCamlType Text Source # 
OCamlType UTCTime Source # 
OCamlType Day Source # 
OCamlType TypeParameterRef5 Source # 
OCamlType TypeParameterRef4 Source # 
OCamlType TypeParameterRef3 Source # 
OCamlType TypeParameterRef2 Source # 
OCamlType TypeParameterRef1 Source # 
OCamlType TypeParameterRef0 Source # 
OCamlType a => OCamlType [a] Source # 
OCamlType a => OCamlType (Maybe a) Source # 
(OCamlType l, OCamlType r) => OCamlType (Either l r) Source # 
(OCamlType a, OCamlType b) => OCamlType (a, b) Source # 

Methods

toOCamlType :: (a, b) -> OCamlDatatype Source #

OCamlType a => OCamlType (Proxy * a) Source # 
(OCamlType a, OCamlType b, OCamlType c) => OCamlType (a, b, c) Source # 

Methods

toOCamlType :: (a, b, c) -> OCamlDatatype Source #

(OCamlType a, OCamlType b, OCamlType c, OCamlType d) => OCamlType (a, b, c, d) Source # 

Methods

toOCamlType :: (a, b, c, d) -> OCamlDatatype Source #

(OCamlType a, OCamlType b, OCamlType c, OCamlType d, OCamlType e) => OCamlType (a, b, c, d, e) Source # 

Methods

toOCamlType :: (a, b, c, d, e) -> OCamlDatatype Source #

(OCamlType a, OCamlType b, OCamlType c, OCamlType d, OCamlType e, OCamlType f) => OCamlType (a, b, c, d, e, f) Source # 

Methods

toOCamlType :: (a, b, c, d, e, f) -> OCamlDatatype Source #

data TypeParameterRef0 Source #

Used to fill the type parameters of proxy types. `Proxy :: Proxy (Maybe TypeParameterRef0)`, `Proxy :: Proxy Either TypeParameterRef0 TypeParameterRef1`. JSON representation is as an Int to simplify the automated tests.

Instances

Eq TypeParameterRef0 Source # 
Read TypeParameterRef0 Source # 
Show TypeParameterRef0 Source # 
Generic TypeParameterRef0 Source # 
Arbitrary TypeParameterRef0 Source # 
ToJSON TypeParameterRef0 Source # 
FromJSON TypeParameterRef0 Source # 
ToADTArbitrary TypeParameterRef0 Source # 
OCamlType TypeParameterRef0 Source # 
type Rep TypeParameterRef0 Source # 
type Rep TypeParameterRef0 = D1 * (MetaData "TypeParameterRef0" "OCaml.BuckleScript.Types" "ocaml-export-0.3.0.0-B2f4y8wRAkA7l2pQnl90re" True) (C1 * (MetaCons "TypeParameterRef0" PrefixI False) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * Int)))

data TypeParameterRef1 Source #

Second unique TypeParameterRef.

Instances

Eq TypeParameterRef1 Source # 
Read TypeParameterRef1 Source # 
Show TypeParameterRef1 Source # 
Generic TypeParameterRef1 Source # 
Arbitrary TypeParameterRef1 Source # 
ToJSON TypeParameterRef1 Source # 
FromJSON TypeParameterRef1 Source # 
ToADTArbitrary TypeParameterRef1 Source # 
OCamlType TypeParameterRef1 Source # 
type Rep TypeParameterRef1 Source # 
type Rep TypeParameterRef1 = D1 * (MetaData "TypeParameterRef1" "OCaml.BuckleScript.Types" "ocaml-export-0.3.0.0-B2f4y8wRAkA7l2pQnl90re" True) (C1 * (MetaCons "TypeParameterRef1" PrefixI False) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * Int)))

data TypeParameterRef2 Source #

Third unique TypeParameterRef.

Instances

Eq TypeParameterRef2 Source # 
Read TypeParameterRef2 Source # 
Show TypeParameterRef2 Source # 
Generic TypeParameterRef2 Source # 
Arbitrary TypeParameterRef2 Source # 
ToJSON TypeParameterRef2 Source # 
FromJSON TypeParameterRef2 Source # 
ToADTArbitrary TypeParameterRef2 Source # 
OCamlType TypeParameterRef2 Source # 
type Rep TypeParameterRef2 Source # 
type Rep TypeParameterRef2 = D1 * (MetaData "TypeParameterRef2" "OCaml.BuckleScript.Types" "ocaml-export-0.3.0.0-B2f4y8wRAkA7l2pQnl90re" False) (C1 * (MetaCons "TypeParameterRef2" PrefixI False) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * Int)))

data TypeParameterRef3 Source #

Fourth unique TypeParameterRef.

Instances

Eq TypeParameterRef3 Source # 
Read TypeParameterRef3 Source # 
Show TypeParameterRef3 Source # 
Generic TypeParameterRef3 Source # 
Arbitrary TypeParameterRef3 Source # 
ToJSON TypeParameterRef3 Source # 
FromJSON TypeParameterRef3 Source # 
ToADTArbitrary TypeParameterRef3 Source # 
OCamlType TypeParameterRef3 Source # 
type Rep TypeParameterRef3 Source # 
type Rep TypeParameterRef3 = D1 * (MetaData "TypeParameterRef3" "OCaml.BuckleScript.Types" "ocaml-export-0.3.0.0-B2f4y8wRAkA7l2pQnl90re" False) (C1 * (MetaCons "TypeParameterRef3" PrefixI False) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * Int)))

data TypeParameterRef4 Source #

Fifth unique TypeParameterRef.

Instances

Eq TypeParameterRef4 Source # 
Read TypeParameterRef4 Source # 
Show TypeParameterRef4 Source # 
Generic TypeParameterRef4 Source # 
Arbitrary TypeParameterRef4 Source # 
ToJSON TypeParameterRef4 Source # 
FromJSON TypeParameterRef4 Source # 
ToADTArbitrary TypeParameterRef4 Source # 
OCamlType TypeParameterRef4 Source # 
type Rep TypeParameterRef4 Source # 
type Rep TypeParameterRef4 = D1 * (MetaData "TypeParameterRef4" "OCaml.BuckleScript.Types" "ocaml-export-0.3.0.0-B2f4y8wRAkA7l2pQnl90re" False) (C1 * (MetaCons "TypeParameterRef4" PrefixI False) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * Int)))

data TypeParameterRef5 Source #

Sixth unique TypeParameterRef.

Instances

Eq TypeParameterRef5 Source # 
Read TypeParameterRef5 Source # 
Show TypeParameterRef5 Source # 
Generic TypeParameterRef5 Source # 
Arbitrary TypeParameterRef5 Source # 
ToJSON TypeParameterRef5 Source # 
FromJSON TypeParameterRef5 Source # 
ToADTArbitrary TypeParameterRef5 Source # 
OCamlType TypeParameterRef5 Source # 
type Rep TypeParameterRef5 Source # 
type Rep TypeParameterRef5 = D1 * (MetaData "TypeParameterRef5" "OCaml.BuckleScript.Types" "ocaml-export-0.3.0.0-B2f4y8wRAkA7l2pQnl90re" False) (C1 * (MetaCons "TypeParameterRef5" PrefixI False) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * Int)))

mkOCamlSpecServer :: forall ocamlPackage. OCamlPackageTypeCount ocamlPackage => String -> Proxy ocamlPackage -> Q [Dec] Source #

type family MkOCamlSpecAPI a :: * where ... Source #

Convert an OCamlPackage into a servant API.

Equations

MkOCamlSpecAPI (OCamlPackage a deps :> rest) = MkOCamlSpecAPI rest 
MkOCamlSpecAPI ((OCamlModule modules :> api) :<|> rest) = MkOCamlSpecAPI' modules '[] api :<|> MkOCamlSpecAPI rest 
MkOCamlSpecAPI (OCamlModule modules :> api) = MkOCamlSpecAPI' modules '[] api 

mkGoldenFiles :: HasMkGoldenFiles a => Proxy a -> Int -> FilePath -> IO () Source #

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

A concrete, poly-kinded proxy type

Constructors

Proxy 

Instances

Generic1 k (Proxy k) 

Associated Types

type Rep1 (Proxy k) (f :: Proxy k -> *) :: k -> * #

Methods

from1 :: f a -> Rep1 (Proxy k) f a #

to1 :: Rep1 (Proxy k) f a -> f a #

Monad (Proxy *)

Since: 4.7.0.0

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: 4.7.0.0

Methods

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

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

Applicative (Proxy *)

Since: 4.7.0.0

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: 4.7.0.0

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: 4.7.0.0

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 *) 

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 *) 

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: 4.9.0.0

Methods

empty :: Proxy * a #

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

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

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

MonadPlus (Proxy *)

Since: 4.9.0.0

Methods

mzero :: Proxy * a #

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

Eq1 (Proxy *)

Since: 4.9.0.0

Methods

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

Ord1 (Proxy *)

Since: 4.9.0.0

Methods

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

Read1 (Proxy *)

Since: 4.9.0.0

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: 4.9.0.0

Methods

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

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

Hashable1 (Proxy *) 

Methods

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

Bounded (Proxy k t) 

Methods

minBound :: Proxy k t #

maxBound :: Proxy k t #

Enum (Proxy k s)

Since: 4.7.0.0

Methods

succ :: Proxy k s -> Proxy k s #

pred :: Proxy k s -> Proxy k s #

toEnum :: Int -> Proxy k s #

fromEnum :: Proxy k s -> Int #

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

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

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

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

Eq (Proxy k s)

Since: 4.7.0.0

Methods

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

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

Ord (Proxy k s)

Since: 4.7.0.0

Methods

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

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

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

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

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

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

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

Read (Proxy k s)

Since: 4.7.0.0

Show (Proxy k s)

Since: 4.7.0.0

Methods

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

show :: Proxy k s -> String #

showList :: [Proxy k s] -> ShowS #

Ix (Proxy k s)

Since: 4.7.0.0

Methods

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

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

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

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

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

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

Generic (Proxy k t) 

Associated Types

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

Methods

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

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

Semigroup (Proxy k s)

Since: 4.9.0.0

Methods

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

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

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

Monoid (Proxy k s)

Since: 4.7.0.0

Methods

mempty :: Proxy k s #

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

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

Hashable (Proxy k a) 

Methods

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

hash :: Proxy k a -> Int #

ToJSON (Proxy k a) 

Methods

toJSON :: Proxy k a -> Value #

toEncoding :: Proxy k a -> Encoding #

toJSONList :: [Proxy k a] -> Value #

toEncodingList :: [Proxy k a] -> Encoding #

FromJSON (Proxy k a) 

Methods

parseJSON :: Value -> Parser (Proxy k a) #

parseJSONList :: Value -> Parser [Proxy k a] #

OCamlType a => OCamlType (Proxy * a) Source # 
type Rep1 k (Proxy k) 
type Rep1 k (Proxy k) = D1 k (MetaData "Proxy" "Data.Proxy" "base" False) (C1 k (MetaCons "Proxy" PrefixI False) (U1 k))
type Rep (Proxy k t) 
type Rep (Proxy k t) = D1 * (MetaData "Proxy" "Data.Proxy" "base" False) (C1 * (MetaCons "Proxy" PrefixI False) (U1 *))

data (k :> k1) (path :: k) (a :: k1) :: forall k k1. k -> k1 -> * 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

(KnownSymbol sym, ToHttpApiData v, HasLink k sub) => HasLink * ((:>) * k (QueryParam * sym v) sub) 

Associated Types

type MkLink ((* :> k) (QueryParam * sym v) sub) (endpoint :: (* :> k) (QueryParam * sym v) sub) :: * #

Methods

toLink :: Proxy ((* :> k) (QueryParam * sym v) sub) endpoint -> Link -> MkLink ((* :> k) (QueryParam * sym v) sub) endpoint #

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

Associated Types

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

Methods

toLink :: Proxy ((* :> k) (QueryParams * sym v) sub) endpoint -> Link -> MkLink ((* :> k) (QueryParams * sym v) sub) endpoint #

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

Associated Types

type MkLink ((* :> k) (QueryFlag sym) sub) (endpoint :: (* :> k) (QueryFlag sym) sub) :: * #

Methods

toLink :: Proxy ((* :> k) (QueryFlag sym) sub) endpoint -> Link -> MkLink ((* :> k) (QueryFlag sym) sub) endpoint #

HasLink k2 sub => HasLink * ((:>) * k2 (ReqBody k1 ct a) sub) 

Associated Types

type MkLink ((* :> k2) (ReqBody k1 ct a) sub) (endpoint :: (* :> k2) (ReqBody k1 ct a) sub) :: * #

Methods

toLink :: Proxy ((* :> k2) (ReqBody k1 ct a) sub) endpoint -> Link -> MkLink ((* :> k2) (ReqBody k1 ct a) sub) endpoint #

(ToHttpApiData v, HasLink k sub) => HasLink * ((:>) * k (Capture * sym v) sub) 

Associated Types

type MkLink ((* :> k) (Capture * sym v) sub) (endpoint :: (* :> k) (Capture * sym v) sub) :: * #

Methods

toLink :: Proxy ((* :> k) (Capture * sym v) sub) endpoint -> Link -> MkLink ((* :> k) (Capture * sym v) sub) endpoint #

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

Associated Types

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

Methods

toLink :: Proxy ((* :> k) (CaptureAll * sym v) sub) endpoint -> Link -> MkLink ((* :> k) (CaptureAll * sym v) sub) endpoint #

HasLink k sub => HasLink * ((:>) * k (Header sym a) sub) 

Associated Types

type MkLink ((* :> k) (Header sym a) sub) (endpoint :: (* :> k) (Header sym a) sub) :: * #

Methods

toLink :: Proxy ((* :> k) (Header sym a) sub) endpoint -> Link -> MkLink ((* :> k) (Header sym a) sub) endpoint #

HasLink k sub => HasLink * ((:>) * k RemoteHost sub) 

Associated Types

type MkLink ((* :> k) RemoteHost sub) (endpoint :: (* :> k) RemoteHost sub) :: * #

Methods

toLink :: Proxy ((* :> k) RemoteHost sub) endpoint -> Link -> MkLink ((* :> k) RemoteHost sub) endpoint #

HasLink k sub => HasLink * ((:>) * k (BasicAuth realm a) sub) 

Associated Types

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

Methods

toLink :: Proxy ((* :> k) (BasicAuth realm a) sub) endpoint -> Link -> MkLink ((* :> k) (BasicAuth realm a) sub) endpoint #

HasLink k2 sub => HasLink * ((:>) * k2 (AuthProtect k1 tag) sub) 

Associated Types

type MkLink ((* :> k2) (AuthProtect k1 tag) sub) (endpoint :: (* :> k2) (AuthProtect k1 tag) sub) :: * #

Methods

toLink :: Proxy ((* :> k2) (AuthProtect k1 tag) sub) endpoint -> Link -> MkLink ((* :> k2) (AuthProtect k1 tag) sub) endpoint #

(KnownSymbol sym, HasLink k sub) => HasLink * ((:>) Symbol k sym sub) 

Associated Types

type MkLink ((Symbol :> k) sym sub) (endpoint :: (Symbol :> k) sym sub) :: * #

Methods

toLink :: Proxy ((Symbol :> k) sym sub) endpoint -> Link -> MkLink ((Symbol :> k) sym sub) endpoint #

(HasOCamlTypeMetaData [*] deps, HasOCamlTypeMetaData k1 modules) => HasOCamlTypeMetaData * ((:>) * k1 (OCamlPackage packageName deps) modules) Source #

build a packages dependencies and its declared modules

Methods

mkOCamlTypeMetaData :: Proxy ((* :> k1) (OCamlPackage packageName deps) modules) a -> Map HaskellTypeMetaData OCamlTypeMetaData Source #

(KnownSymbols modules, HasOCamlTypeMetaData' k1 api) => HasOCamlTypeMetaData * ((:>) * k1 (OCamlModule modules) api) Source #

single module

(KnownSymbols modules, HasOCamlModule' k1 api) => HasOCamlModule * ((:>) * k1 (OCamlModule modules) api) Source # 
(HasOCamlTypeMetaData [*] deps, HasOCamlTypeMetaData k1 a, HasOCamlPackage' k1 a) => HasOCamlPackage * ((:>) * k1 (OCamlPackage packageName deps) a) Source # 

Methods

mkPackage :: Proxy ((* :> k1) (OCamlPackage packageName deps) a) a -> PackageOptions -> IO () Source #

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

Ignore Summary in server handlers.

Associated Types

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

Methods

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

hoistServerWithContext :: Proxy ((* :> k1) (Summary desc) api) ctx -> Proxy [*] context -> (forall x. m x -> n x) -> ServerT ((* :> k1) (Summary desc) api) ctx m -> ServerT ((* :> k1) (Summary desc) api) ctx n #

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

Ignore Description in server handlers.

Associated Types

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

Methods

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

hoistServerWithContext :: Proxy ((* :> k1) (Description desc) api) ctx -> Proxy [*] context -> (forall x. m x -> n x) -> ServerT ((* :> k1) (Description desc) api) ctx m -> ServerT ((* :> k1) (Description desc) api) ctx n #

(KnownSymbol sym, FromHttpApiData a, HasServer k1 api context) => HasServer * ((:>) * k1 (Header sym a) api) context

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

All it asks is for a FromHttpApiData instance.

Example:

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

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

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

Associated Types

type ServerT ((* :> k1) (Header sym a) api) (context :: (* :> k1) (Header sym a) api) (m :: * -> *) :: * #

Methods

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

hoistServerWithContext :: Proxy ((* :> k1) (Header sym a) api) context -> Proxy [*] context -> (forall x. m x -> n x) -> ServerT ((* :> k1) (Header sym a) api) context m -> ServerT ((* :> k1) (Header sym a) api) context n #

(KnownSymbol sym, FromHttpApiData a, HasServer k1 api context) => HasServer * ((:>) * k1 (QueryParam * sym a) api) context

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

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

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

Example:

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

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

Associated Types

type ServerT ((* :> k1) (QueryParam * sym a) api) (context :: (* :> k1) (QueryParam * sym a) api) (m :: * -> *) :: * #

Methods

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

hoistServerWithContext :: Proxy ((* :> k1) (QueryParam * sym a) api) context -> Proxy [*] context -> (forall x. m x -> n x) -> ServerT ((* :> k1) (QueryParam * sym a) api) context m -> ServerT ((* :> k1) (QueryParam * sym a) api) context n #

(KnownSymbol sym, FromHttpApiData a, HasServer k1 api context) => HasServer * ((:>) * k1 (QueryParams * sym a) api) context

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

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

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

Example:

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

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

Associated Types

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

Methods

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

hoistServerWithContext :: Proxy ((* :> k1) (QueryParams * sym a) api) context -> Proxy [*] context -> (forall x. m x -> n x) -> ServerT ((* :> k1) (QueryParams * sym a) api) context m -> ServerT ((* :> k1) (QueryParams * sym a) api) context n #

(KnownSymbol sym, HasServer k1 api context) => HasServer * ((:>) * k1 (QueryFlag sym) api) context

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

Example:

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

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

Associated Types

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

Methods

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

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

(AllCTUnrender list a, HasServer k1 api context) => HasServer * ((:>) * k1 (ReqBody * list a) api) context

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

All it asks is for a FromJSON instance.

Example:

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

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

Associated Types

type ServerT ((* :> k1) (ReqBody * list a) api) (context :: (* :> k1) (ReqBody * list a) api) (m :: * -> *) :: * #

Methods

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

hoistServerWithContext :: Proxy ((* :> k1) (ReqBody * list a) api) context -> Proxy [*] context -> (forall x. m x -> n x) -> ServerT ((* :> k1) (ReqBody * list a) api) context m -> ServerT ((* :> k1) (ReqBody * list a) api) context n #

HasServer k1 api context => HasServer * ((:>) * k1 RemoteHost api) context 

Associated Types

type ServerT ((* :> k1) RemoteHost api) (context :: (* :> k1) RemoteHost api) (m :: * -> *) :: * #

Methods

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

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

HasServer k1 api context => HasServer * ((:>) * k1 IsSecure api) context 

Associated Types

type ServerT ((* :> k1) IsSecure api) (context :: (* :> k1) IsSecure api) (m :: * -> *) :: * #

Methods

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

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

(KnownSymbol capture, FromHttpApiData a, HasServer k1 api context) => HasServer * ((:>) * k1 (Capture * capture a) api) context

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

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

Example:

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

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

Associated Types

type ServerT ((* :> k1) (Capture * capture a) api) (context :: (* :> k1) (Capture * capture a) api) (m :: * -> *) :: * #

Methods

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

hoistServerWithContext :: Proxy ((* :> k1) (Capture * capture a) api) context -> Proxy [*] context -> (forall x. m x -> n x) -> ServerT ((* :> k1) (Capture * capture a) api) context m -> ServerT ((* :> k1) (Capture * capture a) api) context n #

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

Associated Types

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

Methods

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

hoistServerWithContext :: Proxy ((* :> k1) (CaptureAll * capture a) api) context -> Proxy [*] context -> (forall x. m x -> n x) -> ServerT ((* :> k1) (CaptureAll * capture a) api) context m -> ServerT ((* :> k1) (CaptureAll * capture a) api) context n #

HasServer k1 api context => HasServer * ((:>) * k1 Vault api) context 

Associated Types

type ServerT ((* :> k1) Vault api) (context :: (* :> k1) Vault api) (m :: * -> *) :: * #

Methods

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

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

HasServer k1 api context => HasServer * ((:>) * k1 HttpVersion api) context 

Associated Types

type ServerT ((* :> k1) HttpVersion api) (context :: (* :> k1) HttpVersion api) (m :: * -> *) :: * #

Methods

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

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

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

Basic Authentication

Associated Types

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

Methods

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

hoistServerWithContext :: Proxy ((* :> k1) (BasicAuth realm usr) api) context -> Proxy [*] context -> (forall x. m x -> n x) -> ServerT ((* :> k1) (BasicAuth realm usr) api) context m -> ServerT ((* :> k1) (BasicAuth realm usr) api) context n #

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

Make sure the incoming request starts with "/path", strip it and pass the rest of the request path to api.

Associated Types

type ServerT ((Symbol :> k1) path api) (context :: (Symbol :> k1) path api) (m :: * -> *) :: * #

Methods

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

hoistServerWithContext :: Proxy ((Symbol :> k1) path api) context -> Proxy [*] context -> (forall x. m x -> n x) -> ServerT ((Symbol :> k1) path api) context m -> ServerT ((Symbol :> k1) path api) context n #

type MkLink * ((:>) * k1 (AuthProtect k2 tag) sub) 
type MkLink * ((:>) * k1 (AuthProtect k2 tag) sub) = MkLink k1 sub
type MkLink * ((:>) * k (BasicAuth realm a) sub) 
type MkLink * ((:>) * k (BasicAuth realm a) sub) = MkLink k sub
type MkLink * ((:>) * k RemoteHost sub) 
type MkLink * ((:>) * k RemoteHost sub) = MkLink k sub
type MkLink * ((:>) * k (Header sym a) sub) 
type MkLink * ((:>) * k (Header sym a) sub) = MkLink k sub
type MkLink * ((:>) * k (CaptureAll * sym v) sub) 
type MkLink * ((:>) * k (CaptureAll * sym v) sub) = [v] -> MkLink k sub
type MkLink * ((:>) * k (Capture * sym v) sub) 
type MkLink * ((:>) * k (Capture * sym v) sub) = v -> MkLink k sub
type MkLink * ((:>) * k1 (ReqBody k2 ct a) sub) 
type MkLink * ((:>) * k1 (ReqBody k2 ct a) sub) = MkLink k1 sub
type MkLink * ((:>) * k (QueryFlag sym) sub) 
type MkLink * ((:>) * k (QueryFlag sym) sub) = Bool -> MkLink k sub
type MkLink * ((:>) * k (QueryParams * sym v) sub) 
type MkLink * ((:>) * k (QueryParams * sym v) sub) = [v] -> MkLink k sub
type MkLink * ((:>) * k (QueryParam * sym v) sub) 
type MkLink * ((:>) * k (QueryParam * sym v) sub) = Maybe v -> MkLink k sub
type MkLink * ((:>) Symbol k sym sub) 
type MkLink * ((:>) Symbol k sym sub) = MkLink k sub
type ServerT * ((:>) * k1 (BasicAuth realm usr) api) m 
type ServerT * ((:>) * k1 (BasicAuth realm usr) api) m = usr -> ServerT k1 api m
type ServerT * ((:>) * k1 (Description desc) api) m 
type ServerT * ((:>) * k1 (Description desc) api) m = ServerT k1 api m
type ServerT * ((:>) * k1 (Summary desc) api) m 
type ServerT * ((:>) * k1 (Summary desc) api) m = ServerT k1 api m
type ServerT * ((:>) * k1 HttpVersion api) m 
type ServerT * ((:>) * k1 HttpVersion api) m = HttpVersion -> ServerT k1 api m
type ServerT * ((:>) * k1 Vault api) m 
type ServerT * ((:>) * k1 Vault api) m = Vault -> ServerT k1 api m
type ServerT * ((:>) * k1 IsSecure api) m 
type ServerT * ((:>) * k1 IsSecure api) m = IsSecure -> ServerT k1 api m
type ServerT * ((:>) * k1 RemoteHost api) m 
type ServerT * ((:>) * k1 RemoteHost api) m = SockAddr -> ServerT k1 api m
type ServerT * ((:>) * k1 (ReqBody * list a) api) m 
type ServerT * ((:>) * k1 (ReqBody * list a) api) m = a -> ServerT k1 api m
type ServerT * ((:>) * k1 (QueryFlag sym) api) m 
type ServerT * ((:>) * k1 (QueryFlag sym) api) m = Bool -> ServerT k1 api m
type ServerT * ((:>) * k1 (QueryParams * sym a) api) m 
type ServerT * ((:>) * k1 (QueryParams * sym a) api) m = [a] -> ServerT k1 api m
type ServerT * ((:>) * k1 (QueryParam * sym a) api) m 
type ServerT * ((:>) * k1 (QueryParam * sym a) api) m = Maybe a -> ServerT k1 api m
type ServerT * ((:>) * k1 (Header sym a) api) m 
type ServerT * ((:>) * k1 (Header sym a) api) m = Maybe a -> ServerT k1 api m
type ServerT * ((:>) * k1 (CaptureAll * capture a) api) m 
type ServerT * ((:>) * k1 (CaptureAll * capture a) api) m = [a] -> ServerT k1 api m
type ServerT * ((:>) * k1 (Capture * capture a) api) m 
type ServerT * ((:>) * k1 (Capture * capture a) api) m = a -> ServerT k1 api m
type ServerT * ((:>) Symbol k1 path api) m 
type ServerT * ((:>) Symbol k1 path api) m = ServerT k1 api m

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) 

Methods

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

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

Foldable ((:<|>) a) 

Methods

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Traversable ((:<|>) a) 

Methods

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

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

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

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

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

Associated Types

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

Methods

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

(HasOCamlTypeMetaData * modul, HasOCamlTypeMetaData * rst) => HasOCamlTypeMetaData * ((:<|>) modul rst) Source #

modules

(HasOCamlTypeMetaData * (OCamlPackage packageName deps), HasOCamlTypeMetaData * rest) => HasOCamlTypeMetaData * ((:<|>) (OCamlPackage packageName deps) rest) Source #

packages

(HasServer * a context, HasServer * b context) => HasServer * ((:<|>) a b) context

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

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

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

Associated Types

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

Methods

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

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

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

Methods

minBound :: a :<|> b #

maxBound :: a :<|> b #

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

Methods

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

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

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

Methods

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

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

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

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

Methods

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

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

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

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

Methods

mempty :: a :<|> b #

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

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

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

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")

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

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