Copyright | Plow Technologies 2017 |
---|---|
License | BSD3 |
Maintainer | mchaver@gmail.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- data OCamlPackage (packageName :: Symbol) (packageDependencies :: [*])
- type NoDependency = '[]
- data OCamlModule (modules :: [Symbol])
- data OCamlSubModule (subModules :: Symbol)
- data OCamlTypeInFile a (filePath :: Symbol)
- data HaskellTypeName (name :: Symbol) a
- data PackageOptions = PackageOptions {}
- defaultPackageOptions :: PackageOptions
- data SpecOptions = SpecOptions {}
- defaultSpecOptions :: SpecOptions
- data EmbeddedOCamlFiles = EmbeddedOCamlFiles {}
- mkPackage :: HasOCamlPackage a => Proxy a -> PackageOptions -> IO ()
- mkFiles :: HasEmbeddedFile api => Bool -> Bool -> Proxy api -> Q Exp
- mkOCamlTypeMetaData :: HasOCamlTypeMetaData a => Proxy a -> Map HaskellTypeMetaData OCamlTypeMetaData
- class OCamlType a where
- toOCamlType :: a -> OCamlDatatype
- typeableToOCamlType :: forall a. Typeable a => Proxy a -> OCamlDatatype
- newtype TypeParameterRef0 = TypeParameterRef0 Int
- newtype TypeParameterRef1 = TypeParameterRef1 Int
- data TypeParameterRef2 = TypeParameterRef2 Int
- data TypeParameterRef3 = TypeParameterRef3 Int
- data TypeParameterRef4 = TypeParameterRef4 Int
- data TypeParameterRef5 = TypeParameterRef5 Int
- mkOCamlSpecServer :: forall ocamlPackage. OCamlPackageTypeCount ocamlPackage => String -> Proxy ocamlPackage -> Q [Dec]
- type family MkOCamlSpecAPI a :: * where ...
- mkGoldenFiles :: HasMkGoldenFiles a => Proxy a -> Int -> FilePath -> IO ()
- runGoldenSpec :: HasRunGoldenSpec a => Proxy a -> Int -> FilePath -> Spec
- data Proxy (t :: k) :: forall k. k -> Type = Proxy
- data (path :: k) :> a :: forall k. k -> Type -> Type
- data a :<|> b = a :<|> b
- type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived
- type Server (api :: k) = ServerT api Handler
- serve :: HasServer api ([] :: [Type]) => Proxy api -> Server api -> Application
Documentation
data OCamlPackage (packageName :: Symbol) (packageDependencies :: [*]) Source #
Instances
(HasOCamlTypeMetaData (OCamlPackage packageName deps), HasOCamlTypeMetaData rest) => HasOCamlTypeMetaData (OCamlPackage packageName deps :<|> rest :: Type) Source # | packages |
Defined in OCaml.BuckleScript.Internal.Package mkOCamlTypeMetaData :: Proxy (OCamlPackage packageName deps :<|> rest) -> Map HaskellTypeMetaData OCamlTypeMetaData Source # | |
(HasOCamlTypeMetaData deps, HasOCamlTypeMetaData modules) => HasOCamlTypeMetaData (OCamlPackage packageName deps :> modules :: Type) Source # | build a packages dependencies and its declared modules |
Defined in OCaml.BuckleScript.Internal.Package mkOCamlTypeMetaData :: Proxy (OCamlPackage packageName deps :> modules) -> Map HaskellTypeMetaData OCamlTypeMetaData Source # | |
(HasOCamlTypeMetaData deps, HasOCamlTypeMetaData a, HasOCamlPackage' a) => HasOCamlPackage (OCamlPackage packageName deps :> a :: Type) Source # | |
Defined in OCaml.BuckleScript.Internal.Package mkPackage :: Proxy (OCamlPackage packageName deps :> 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
(SingI modules, HasOCamlTypeMetaData' api) => HasOCamlTypeMetaData (OCamlModule modules :> api :: Type) Source # | single module |
Defined in OCaml.BuckleScript.Internal.Package mkOCamlTypeMetaData :: Proxy (OCamlModule modules :> api) -> Map HaskellTypeMetaData OCamlTypeMetaData Source # | |
(SingI modules, HasOCamlModule' api) => HasOCamlModule (OCamlModule modules :> api :: Type) Source # | |
Defined in OCaml.BuckleScript.Internal.Package mkModule :: Proxy (OCamlModule modules :> api) -> PackageOptions -> Map HaskellTypeMetaData OCamlTypeMetaData -> IO () 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 HaskellTypeName (name :: Symbol) a Source #
In case Generic is not derived, manually provide the type name user is responsible for making sure it is correct. otherwise it may lead to a compile error.
data PackageOptions Source #
Options for creating an OCaml package based on Haskell types.
PackageOptions | |
|
defaultPackageOptions :: PackageOptions Source #
Default PackageOptions
.
data SpecOptions Source #
Details for OCaml spec.
SpecOptions | |
|
defaultSpecOptions :: SpecOptions Source #
Default SpecOptions
.
data EmbeddedOCamlFiles Source #
Store OCamlFileInType data.
Instances
Show EmbeddedOCamlFiles Source # | |
Defined in OCaml.BuckleScript.Internal.Module showsPrec :: Int -> EmbeddedOCamlFiles -> ShowS # show :: EmbeddedOCamlFiles -> String # showList :: [EmbeddedOCamlFiles] -> ShowS # |
mkPackage :: HasOCamlPackage a => Proxy a -> PackageOptions -> IO () Source #
mkOCamlTypeMetaData :: HasOCamlTypeMetaData a => Proxy a -> Map HaskellTypeMetaData OCamlTypeMetaData 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.
Nothing
toOCamlType :: a -> OCamlDatatype Source #
toOCamlType :: (Generic a, GenericOCamlDatatype (Rep a)) => a -> OCamlDatatype Source #
Instances
typeableToOCamlType :: forall a. Typeable a => Proxy a -> OCamlDatatype Source #
for any type that does not use the same serialization as Generic Aeson and has a manually written OCaml definition, should manually derive OCamlType using this function for convenience.
instance OCamlType X where toOCamlType _ = typeableToOCamlType (Proxy :: Proxy X)
newtype 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
newtype TypeParameterRef1 Source #
Second unique TypeParameterRef.
Instances
data TypeParameterRef2 Source #
Third unique TypeParameterRef.
Instances
data TypeParameterRef3 Source #
Fourth unique TypeParameterRef.
Instances
data TypeParameterRef4 Source #
Fifth unique TypeParameterRef.
Instances
data TypeParameterRef5 Source #
Sixth unique TypeParameterRef.
Instances
mkOCamlSpecServer :: forall ocamlPackage. OCamlPackageTypeCount ocamlPackage => String -> Proxy ocamlPackage -> Q [Dec] Source #
type family MkOCamlSpecAPI a :: * where ... Source #
Convert an OCamlPackage into a servant API.
MkOCamlSpecAPI (OCamlPackage a deps :> rest) = MkOCamlSpecAPI rest | |
MkOCamlSpecAPI ((OCamlModule modules :> api) :<|> rest) = MkOCamlSpecAPI' modules '[] api :<|> MkOCamlSpecAPI rest | |
MkOCamlSpecAPI (OCamlModule modules :> api) = MkOCamlSpecAPI' modules '[] api |
data Proxy (t :: k) :: forall k. k -> Type #
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,
is a safer alternative to the
Proxy
:: Proxy
a'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
Instances
Generic1 (Proxy :: k -> Type) | |
Monad (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Functor (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Applicative (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Foldable (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Defined in Data.Foldable 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 # elem :: Eq a => a -> Proxy a -> Bool # maximum :: Ord a => Proxy a -> a # minimum :: Ord a => Proxy a -> a # | |
Traversable (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
ToJSON1 (Proxy :: Type -> Type) | |
Defined in Data.Aeson.Types.ToJSON 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 :: Type -> Type) | |
Alternative (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
MonadPlus (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Eq1 (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Ord1 (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
Read1 (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
Show1 (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Hashable1 (Proxy :: Type -> Type) | |
Defined in Data.Hashable.Class | |
Bounded (Proxy t) | Since: base-4.7.0.0 |
Enum (Proxy s) | Since: base-4.7.0.0 |
Eq (Proxy s) | Since: base-4.7.0.0 |
Ord (Proxy s) | Since: base-4.7.0.0 |
Read (Proxy t) | Since: base-4.7.0.0 |
Show (Proxy s) | Since: base-4.7.0.0 |
Ix (Proxy s) | Since: base-4.7.0.0 |
Generic (Proxy t) | |
Semigroup (Proxy s) | Since: base-4.9.0.0 |
Monoid (Proxy s) | Since: base-4.7.0.0 |
Hashable (Proxy a) | |
Defined in Data.Hashable.Class | |
ToJSON (Proxy a) | |
Defined in Data.Aeson.Types.ToJSON | |
FromJSON (Proxy a) | |
OCamlType a => OCamlType (Proxy a) Source # | |
Defined in OCaml.BuckleScript.Types toOCamlType :: Proxy a -> OCamlDatatype Source # | |
type Rep1 (Proxy :: k -> Type) | Since: base-4.6.0.0 |
type Rep (Proxy t) | Since: base-4.6.0.0 |
data (path :: k) :> a :: forall k. k -> Type -> Type 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 :: Type) | |
Defined in Servant.Links type MkLink (HttpVersion :> sub) a :: Type # toLink :: (Link -> a) -> Proxy (HttpVersion :> sub) -> Link -> MkLink (HttpVersion :> sub) a # | |
HasLink sub => HasLink (StreamBody' mods framing ct a :> sub :: Type) | |
Defined in Servant.Links type MkLink (StreamBody' mods framing ct a :> sub) a :: Type # toLink :: (Link -> a0) -> Proxy (StreamBody' mods framing ct a :> sub) -> Link -> MkLink (StreamBody' mods framing ct a :> sub) a0 # | |
HasLink sub => HasLink (ReqBody' mods ct a :> sub :: Type) | |
HasLink sub => HasLink (RemoteHost :> sub :: Type) | |
Defined in Servant.Links type MkLink (RemoteHost :> sub) a :: Type # 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 :: Type) | |
Defined in Servant.Links type MkLink (QueryParam' mods sym v :> sub) a :: Type # 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 :: Type) | |
Defined in Servant.Links type MkLink (QueryParams sym v :> sub) a :: Type # toLink :: (Link -> a) -> Proxy (QueryParams sym v :> sub) -> Link -> MkLink (QueryParams sym v :> sub) a # | |
(KnownSymbol sym, HasLink sub) => HasLink (QueryFlag sym :> sub :: Type) | |
HasLink sub => HasLink (Header' mods sym a :> sub :: Type) | |
HasLink sub => HasLink (IsSecure :> sub :: Type) | |
HasLink sub => HasLink (AuthProtect tag :> sub :: Type) | |
Defined in Servant.Links type MkLink (AuthProtect tag :> sub) a :: Type # toLink :: (Link -> a) -> Proxy (AuthProtect tag :> sub) -> Link -> MkLink (AuthProtect tag :> sub) a # | |
HasLink sub => HasLink (Summary s :> sub :: Type) | |
HasLink sub => HasLink (Description s :> sub :: Type) | |
Defined in Servant.Links type MkLink (Description s :> sub) a :: Type # toLink :: (Link -> a) -> Proxy (Description s :> sub) -> Link -> MkLink (Description s :> sub) a # | |
(ToHttpApiData v, HasLink sub) => HasLink (Capture' mods sym v :> sub :: Type) | |
(ToHttpApiData v, HasLink sub) => HasLink (CaptureAll sym v :> sub :: Type) | |
Defined in Servant.Links type MkLink (CaptureAll sym v :> sub) a :: Type # toLink :: (Link -> a) -> Proxy (CaptureAll sym v :> sub) -> Link -> MkLink (CaptureAll sym v :> sub) a # | |
HasLink sub => HasLink (BasicAuth realm a :> sub :: Type) | |
HasLink sub => HasLink (Vault :> sub :: Type) | |
(KnownSymbol sym, HasLink sub) => HasLink (sym :> sub :: Type) | |
(SingI modules, HasOCamlTypeMetaData' api) => HasOCamlTypeMetaData (OCamlModule modules :> api :: Type) Source # | single module |
Defined in OCaml.BuckleScript.Internal.Package mkOCamlTypeMetaData :: Proxy (OCamlModule modules :> api) -> Map HaskellTypeMetaData OCamlTypeMetaData Source # | |
(HasOCamlTypeMetaData deps, HasOCamlTypeMetaData modules) => HasOCamlTypeMetaData (OCamlPackage packageName deps :> modules :: Type) Source # | build a packages dependencies and its declared modules |
Defined in OCaml.BuckleScript.Internal.Package mkOCamlTypeMetaData :: Proxy (OCamlPackage packageName deps :> modules) -> Map HaskellTypeMetaData OCamlTypeMetaData Source # | |
(SingI modules, HasOCamlModule' api) => HasOCamlModule (OCamlModule modules :> api :: Type) Source # | |
Defined in OCaml.BuckleScript.Internal.Package mkModule :: Proxy (OCamlModule modules :> api) -> PackageOptions -> Map HaskellTypeMetaData OCamlTypeMetaData -> IO () Source # | |
(HasOCamlTypeMetaData deps, HasOCamlTypeMetaData a, HasOCamlPackage' a) => HasOCamlPackage (OCamlPackage packageName deps :> a :: Type) Source # | |
Defined in OCaml.BuckleScript.Internal.Package mkPackage :: Proxy (OCamlPackage packageName deps :> a) -> PackageOptions -> IO () Source # | |
(TypeError (HasServerArrowKindError arr) :: Constraint) => HasServer (arr :> api :: Type) context | This instance catches mistakes when there are non-saturated
type applications on LHS of
|
Defined in Servant.Server.Internal | |
HasServer api context => HasServer (HttpVersion :> api :: Type) context | |
Defined in Servant.Server.Internal type ServerT (HttpVersion :> api) m :: Type # 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 # | |
(FramingUnrender framing, FromSourceIO chunk a, MimeUnrender ctype chunk, HasServer api context) => HasServer (StreamBody' mods framing ctype a :> api :: Type) context | |
Defined in Servant.Server.Internal type ServerT (StreamBody' mods framing ctype a :> api) m :: Type # route :: Proxy (StreamBody' mods framing ctype a :> api) -> Context context -> Delayed env (Server (StreamBody' mods framing ctype a :> api)) -> Router env # hoistServerWithContext :: Proxy (StreamBody' mods framing ctype a :> api) -> Proxy context -> (forall x. m x -> n x) -> ServerT (StreamBody' mods framing ctype a :> api) m -> ServerT (StreamBody' mods framing ctype a :> api) n # | |
(AllCTUnrender list a, HasServer api context, SBoolI (FoldLenient mods)) => HasServer (ReqBody' mods list a :> api :: Type) context | If you use All it asks is for a 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... |
Defined in Servant.Server.Internal 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 :: Type) context | |
Defined in Servant.Server.Internal type ServerT (RemoteHost :> api) m :: Type # 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 :: Type) context | If you use 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 You can control how it'll be converted from 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... |
Defined in Servant.Server.Internal type ServerT (QueryParam' mods sym a :> api) m :: Type # 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 :: Type) context | If you use This lets servant worry about looking up 0 or more values in the query string
associated to You can control how the individual values are converted from 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... |
Defined in Servant.Server.Internal type ServerT (QueryParams sym a :> api) m :: Type # 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 :: Type) context | If you use 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... |
Defined in Servant.Server.Internal | |
(KnownSymbol sym, FromHttpApiData a, HasServer api context, SBoolI (FoldRequired mods), SBoolI (FoldLenient mods)) => HasServer (Header' mods sym a :> api :: Type) context | If you use All it asks is for a 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 |
Defined in Servant.Server.Internal 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 :: Type) context | |
Defined in Servant.Server.Internal | |
HasServer api ctx => HasServer (Summary desc :> api :: Type) ctx | Ignore |
Defined in Servant.Server.Internal | |
HasServer api ctx => HasServer (Description desc :> api :: Type) ctx | Ignore |
Defined in Servant.Server.Internal type ServerT (Description desc :> api) m :: Type # 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 :: Type) context | If you use You can control how it'll be converted from Example: type MyApi = "books" :> Capture "isbn" Text :> Get '[JSON] Book server :: Server MyApi server = getBook where getBook :: Text -> Handler Book getBook isbn = ... |
Defined in Servant.Server.Internal 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 :: Type) context | If you use You can control how they'll be converted from Example: type MyApi = "src" :> CaptureAll "segments" Text :> Get '[JSON] SourceFile server :: Server MyApi server = getSourceFile where getSourceFile :: [Text] -> Handler Book getSourceFile pathSegments = ... |
Defined in Servant.Server.Internal type ServerT (CaptureAll capture a :> api) m :: Type # 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 :: Type) context | Basic Authentication |
Defined in Servant.Server.Internal 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 :: Type) context | |
Defined in Servant.Server.Internal | |
(KnownSymbol path, HasServer api context) => HasServer (path :> api :: Type) context | Make sure the incoming request starts with |
Defined in Servant.Server.Internal | |
type MkLink (HttpVersion :> sub :: Type) a | |
Defined in Servant.Links | |
type MkLink (StreamBody' mods framing ct a :> sub :: Type) r | |
Defined in Servant.Links | |
type MkLink (ReqBody' mods ct a :> sub :: Type) r | |
type MkLink (RemoteHost :> sub :: Type) a | |
Defined in Servant.Links | |
type MkLink (QueryParam' mods sym v :> sub :: Type) a | |
Defined in Servant.Links type MkLink (QueryParam' mods sym v :> sub :: Type) a = If (FoldRequired mods) v (Maybe v) -> MkLink sub a | |
type MkLink (QueryParams sym v :> sub :: Type) a | |
Defined in Servant.Links | |
type MkLink (QueryFlag sym :> sub :: Type) a | |
type MkLink (Header' mods sym a :> sub :: Type) r | |
type MkLink (IsSecure :> sub :: Type) a | |
type MkLink (AuthProtect tag :> sub :: Type) a | |
Defined in Servant.Links | |
type MkLink (Summary s :> sub :: Type) a | |
type MkLink (Description s :> sub :: Type) a | |
Defined in Servant.Links | |
type MkLink (Capture' mods sym v :> sub :: Type) a | |
type MkLink (CaptureAll sym v :> sub :: Type) a | |
Defined in Servant.Links | |
type MkLink (BasicAuth realm a :> sub :: Type) r | |
type MkLink (Vault :> sub :: Type) a | |
type MkLink (sym :> sub :: Type) a | |
Defined in Servant.Links | |
type ServerT (arr :> api :: Type) m | |
Defined in Servant.Server.Internal | |
type ServerT (HttpVersion :> api :: Type) m | |
Defined in Servant.Server.Internal | |
type ServerT (StreamBody' mods framing ctype a :> api :: Type) m | |
Defined in Servant.Server.Internal | |
type ServerT (ReqBody' mods list a :> api :: Type) m | |
Defined in Servant.Server.Internal | |
type ServerT (RemoteHost :> api :: Type) m | |
Defined in Servant.Server.Internal | |
type ServerT (QueryParam' mods sym a :> api :: Type) m | |
Defined in Servant.Server.Internal | |
type ServerT (QueryParams sym a :> api :: Type) m | |
Defined in Servant.Server.Internal | |
type ServerT (QueryFlag sym :> api :: Type) m | |
type ServerT (Header' mods sym a :> api :: Type) m | |
Defined in Servant.Server.Internal | |
type ServerT (IsSecure :> api :: Type) m | |
type ServerT (Summary desc :> api :: Type) m | |
type ServerT (Description desc :> api :: Type) m | |
Defined in Servant.Server.Internal | |
type ServerT (Capture' mods capture a :> api :: Type) m | |
type ServerT (CaptureAll capture a :> api :: Type) m | |
Defined in Servant.Server.Internal | |
type ServerT (BasicAuth realm usr :> api :: Type) m | |
type ServerT (Vault :> api :: Type) m | |
type ServerT (path :> api :: Type) m | |
Defined in Servant.Server.Internal |
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 :}
a :<|> b infixr 3 |
Instances
Bitraversable (:<|>) | |
Defined in Servant.API.Alternative bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> (a :<|> b) -> f (c :<|> d) # | |
Bifoldable (:<|>) | |
Bifunctor (:<|>) | |
Biapplicative (:<|>) | |
Defined in Servant.API.Alternative | |
Functor ((:<|>) a) | |
Foldable ((:<|>) a) | |
Defined in Servant.API.Alternative 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] # length :: (a :<|> a0) -> Int # elem :: Eq a0 => a0 -> (a :<|> a0) -> Bool # maximum :: Ord a0 => (a :<|> a0) -> a0 # minimum :: Ord a0 => (a :<|> a0) -> a0 # | |
Traversable ((:<|>) a) | |
(HasLink a, HasLink b) => HasLink (a :<|> b :: Type) | |
(HasOCamlTypeMetaData modul, HasOCamlTypeMetaData rst) => HasOCamlTypeMetaData (modul :<|> rst :: Type) Source # | modules |
Defined in OCaml.BuckleScript.Internal.Package mkOCamlTypeMetaData :: Proxy (modul :<|> rst) -> Map HaskellTypeMetaData OCamlTypeMetaData Source # | |
(HasOCamlTypeMetaData (OCamlPackage packageName deps), HasOCamlTypeMetaData rest) => HasOCamlTypeMetaData (OCamlPackage packageName deps :<|> rest :: Type) Source # | packages |
Defined in OCaml.BuckleScript.Internal.Package mkOCamlTypeMetaData :: Proxy (OCamlPackage packageName deps :<|> rest) -> Map HaskellTypeMetaData OCamlTypeMetaData Source # | |
(HasServer a context, HasServer b context) => HasServer (a :<|> b :: Type) context | A server for 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 = ... |
Defined in Servant.Server.Internal | |
(Bounded a, Bounded b) => Bounded (a :<|> b) | |
(Eq a, Eq b) => Eq (a :<|> b) | |
(Show a, Show b) => Show (a :<|> b) | |
(Semigroup a, Semigroup b) => Semigroup (a :<|> b) | |
(Monoid a, Monoid b) => Monoid (a :<|> b) | |
type MkLink (a :<|> b :: Type) r | |
type ServerT (a :<|> b :: Type) 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")
serve :: HasServer api ([] :: [Type]) => 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