minion-0.1.0.0: A Haskell introspectable web router
Safe HaskellSafe-Inferred
LanguageHaskell2010

Web.Minion

Synopsis

Minion

data Router' i (ts :: Type) m Source #

Instances

Instances details
IsString (Combinator i ts m) Source # 
Instance details

Defined in Web.Minion.Router.Internal

Methods

fromString :: String -> Combinator i ts m #

Monoid (Router' i ts r) Source # 
Instance details

Defined in Web.Minion.Router.Internal

Methods

mempty :: Router' i ts r #

mappend :: Router' i ts r -> Router' i ts r -> Router' i ts r #

mconcat :: [Router' i ts r] -> Router' i ts r #

Semigroup (Router' i ts r) Source # 
Instance details

Defined in Web.Minion.Router.Internal

Methods

(<>) :: Router' i ts r -> Router' i ts r -> Router' i ts r #

sconcat :: NonEmpty (Router' i ts r) -> Router' i ts r #

stimes :: Integral b => b -> Router' i ts r -> Router' i ts r #

IsList (Router' i ts r) Source # 
Instance details

Defined in Web.Minion.Router.Internal

Associated Types

type Item (Router' i ts r) #

Methods

fromList :: [Item (Router' i ts r)] -> Router' i ts r #

fromListN :: Int -> [Item (Router' i ts r)] -> Router' i ts r #

toList :: Router' i ts r -> [Item (Router' i ts r)] #

type Item (Router' i ts r) Source # 
Instance details

Defined in Web.Minion.Router.Internal

type Item (Router' i ts r) = Router' i ts r

type Router = Router' Void Source #

If you don't care about introspection

Combinators

type ValueCombinator i v ts m = Router' i (ts :+ v) m -> Router' i ts m Source #

type Combinator i ts m = Router' i ts m -> Router' i ts m Source #

alt :: [Router' i ts r] -> Router' i ts r Source #

Could be omitted with OverloadedLists

{-# LANGUAGE OverloadedLists #-}
"foo" />
  [ "bar" /> ...
  , "baz" /> ...
  ]
{-# LANGUAGE NoOverloadedLists #-}
"foo" /> alt
  [ "bar" /> ...
  , "baz" /> ...
  ]

(/>) infixr 0 Source #

Arguments

:: (Router' i ts r -> Router' i ts r) 
-> Router' i ts r

.

-> Router' i ts r 

Use it after Combinator

(.>) infixr 0 Source #

Arguments

:: (Router' i ts' r -> Router' i ts r) 
-> Router' i ts' r

.

-> Router' i ts r 

Use it after ValueCombinator and MapArgs

(!>) infixr 0 Source #

Arguments

:: (Router' i (ts :+ x) r -> Router' i ts r) 
-> Router' i (ts :+ Hide x) r

.

-> Router' i ts r 

Use it if you don't care about value captured by previous combinator

description :: Introspection i Description a => a -> Combinator i ts m Source #

Add description for route

Header

Query params

URL

Request

newtype ReqBody (cts :: [Type]) a Source #

Constructors

ReqBody a 

Instances

Instances details
IsRequest (ReqBody cts a) Source # 
Instance details

Defined in Web.Minion.Request.Body

Associated Types

type RequestValue (ReqBody cts a) Source #

Methods

getRequestValue :: ReqBody cts a -> RequestValue (ReqBody cts a) Source #

type RequestValue (ReqBody cts a) Source # 
Instance details

Defined in Web.Minion.Request.Body

type RequestValue (ReqBody cts a) = a

reqBody Source #

Arguments

:: forall cts r m i ts. Introspection i Request (ReqBody cts r) 
=> (MonadIO m, MonadThrow m) 
=> DecodeBody cts r 
=> ValueCombinator i (WithReq m (ReqBody cts r)) ts m

.

Extracts request body with specified Content-Type

... /> reqBody @'[PlainText] @MyRequest

reqPlainText Source #

Arguments

:: forall r m i ts. Introspection i Request (ReqBody '[PlainText] r) 
=> (MonadIO m, MonadThrow m) 
=> Decode PlainText r 
=> ValueCombinator i (WithReq m (ReqBody '[PlainText] r)) ts m

.

reqJson Source #

Arguments

:: forall r m i ts. Introspection i Request (ReqBody '[Json] r) 
=> FromJSON r 
=> (MonadIO m, MonadThrow m) 
=> ValueCombinator i (WithReq m (ReqBody '[Json] r)) ts m

.

Extracts JSON from request

... /> reqJson @MyType .> ...

newtype LazyBytes Source #

Constructors

LazyBytes ByteString 

Instances

Instances details
IsRequest LazyBytes Source # 
Instance details

Defined in Web.Minion.Raw

Associated Types

type RequestValue LazyBytes Source #

CanRespond LazyBytes Source # 
Instance details

Defined in Web.Minion.Response

Applicative m => ToResponse m LazyBytes Source # 
Instance details

Defined in Web.Minion.Response

type RequestValue LazyBytes Source # 
Instance details

Defined in Web.Minion.Raw

lazyBytesBody Source #

Arguments

:: forall m i ts. Introspection i Request LazyBytes 
=> MonadIO m 
=> ValueCombinator i (WithReq m LazyBytes) ts m

.

newtype Chunks Source #

Constructors

Chunks (IO ByteString) 

Instances

Instances details
IsRequest Chunks Source # 
Instance details

Defined in Web.Minion.Raw

Associated Types

type RequestValue Chunks Source #

CanRespond Chunks Source # 
Instance details

Defined in Web.Minion.Response

Applicative m => ToResponse m Chunks Source # 
Instance details

Defined in Web.Minion.Response

type RequestValue Chunks Source # 
Instance details

Defined in Web.Minion.Raw

chunksBody Source #

Arguments

:: forall m i ts. Introspection i Request Chunks 
=> MonadIO m 
=> ValueCombinator i (WithReq m Chunks) ts m

.

Response

data NoBody Source #

Constructors

NoBody 

Instances

Instances details
CanRespond NoBody Source # 
Instance details

Defined in Web.Minion.Response

Monad m => ToResponse m NoBody Source # 
Instance details

Defined in Web.Minion.Response

class ToResponse m r where Source #

Methods

toResponse :: [ByteString] -> r -> m Response Source #

Instances

Instances details
Applicative m => ToResponse m Chunks Source # 
Instance details

Defined in Web.Minion.Response

Applicative m => ToResponse m LazyBytes Source # 
Instance details

Defined in Web.Minion.Response

Monad m => ToResponse m NoBody Source # 
Instance details

Defined in Web.Minion.Response

(ToResponse m a, Monad m, ToResponse m (Union as)) => ToResponse m (Union (a ': as)) Source # 
Instance details

Defined in Web.Minion.Response.Union

Methods

toResponse :: [ByteString] -> Union (a ': as) -> m Response Source #

Monad m => ToResponse m (Union ('[] :: [Type])) Source # 
Instance details

Defined in Web.Minion.Response.Union

Methods

toResponse :: [ByteString] -> Union '[] -> m Response Source #

(ToResponse m a, UnwindHeaders hs, Monad m) => ToResponse m (AddHeaders hs a) Source # 
Instance details

Defined in Web.Minion.Response.Header

Methods

toResponse :: [ByteString] -> AddHeaders hs a -> m Response Source #

(EncodeBody (ct ': cts) a2, Encode ct a2, MonadIO m, ContentType ct) => ToResponse m (RespBody (ct ': cts) a2) Source # 
Instance details

Defined in Web.Minion.Response.Body

Methods

toResponse :: [ByteString] -> RespBody (ct ': cts) a2 -> m Response Source #

MonadIO m => ToResponse m (RespBody ('[] :: [k]) a) Source # 
Instance details

Defined in Web.Minion.Response.Body

Methods

toResponse :: [ByteString] -> RespBody '[] a -> m Response Source #

(ToResponse m a, Monad m, IsStatus status) => ToResponse m (WithStatus status a) Source # 
Instance details

Defined in Web.Minion.Response.Status

Methods

toResponse :: [ByteString] -> WithStatus status a -> m Response Source #

class CanRespond o where Source #

Methods

canRespond Source #

Arguments

:: [ByteString]

Accept header values

-> Bool 

Instances

Instances details
CanRespond Chunks Source # 
Instance details

Defined in Web.Minion.Response

CanRespond LazyBytes Source # 
Instance details

Defined in Web.Minion.Response

CanRespond NoBody Source # 
Instance details

Defined in Web.Minion.Response

(CanRespond a, CanRespond (Union as)) => CanRespond (Union (a ': as) :: Type) Source # 
Instance details

Defined in Web.Minion.Response.Union

CanRespond (Union ('[] :: [Type])) Source # 
Instance details

Defined in Web.Minion.Response.Union

CanRespond a => CanRespond (AddHeaders hs a :: Type) Source # 
Instance details

Defined in Web.Minion.Response.Header

AllContentTypes cts => CanRespond (RespBody cts a :: Type) Source # 
Instance details

Defined in Web.Minion.Response.Body

CanRespond a => CanRespond (WithStatus status a :: Type) Source # 
Instance details

Defined in Web.Minion.Response.Status

Handler

handle Source #

Arguments

:: forall o m ts i st. (HandleArgs ts st m, ToResponse m o, CanRespond o, Introspection i Response o) 
=> Method

.

-> (DelayedArgs st ~> m o) 
-> Router' i ts m 

Handles request with specified HTTP method

... /> handle @MyResponse GET someEndpoint

handleJson Source #

Arguments

:: forall o m ts i st. HandleArgs ts st m 
=> ToJSON o 
=> MonadIO m 
=> Introspection i Response (RespBody '[Json] o) 
=> Method

.

-> (DelayedArgs st ~> m o) 
-> Router' i ts m 

handlePlainText Source #

Arguments

:: forall o m ts i st. HandleArgs ts st m 
=> ToResponse m (RespBody '[PlainText] o) 
=> Introspection i Response (RespBody '[PlainText] o) 
=> Method

.

-> (DelayedArgs st ~> m o) 
-> Router' i ts m 

newtype RespBody cts a Source #

Constructors

RespBody a 

Instances

Instances details
AllContentTypes cts => CanRespond (RespBody cts a :: Type) Source # 
Instance details

Defined in Web.Minion.Response.Body

(EncodeBody (ct ': cts) a2, Encode ct a2, MonadIO m, ContentType ct) => ToResponse m (RespBody (ct ': cts) a2) Source # 
Instance details

Defined in Web.Minion.Response.Body

Methods

toResponse :: [ByteString] -> RespBody (ct ': cts) a2 -> m Response Source #

MonadIO m => ToResponse m (RespBody ('[] :: [k]) a) Source # 
Instance details

Defined in Web.Minion.Response.Body

Methods

toResponse :: [ByteString] -> RespBody '[] a -> m Response Source #

handleBody Source #

Arguments

:: forall cts o m ts i st. HandleArgs ts st m 
=> IsResponse m (RespBody cts o) 
=> Introspection i Response (RespBody cts o) 
=> Method

.

-> (DelayedArgs st ~> m o) 
-> Router' i ts m 

Handles request with specified HTTP method and responds with specified Content-Type

... /> handleBody GET @'[PlainText] @MyResponse someEndpoint

Middleware

middleware :: MiddlewareM m -> Combinator i ts m Source #

Injects middleware

... /> middleware Wai.realIp /> ...

Server

serveWithSettings :: (MonadIO m, MonadCatch m) => MinionSettings m -> Router' i Void m -> ApplicationM m Source #

The same as serve but allows to configure exceptions handlers

Exceptions

data NoMatch Source #

Constructors

NoMatch 

Instances

Instances details
Exception NoMatch Source # 
Instance details

Defined in Web.Minion.Error

Show NoMatch Source # 
Instance details

Defined in Web.Minion.Error

Args

Auth

Reexports

data Void #

Uninhabited data type

Since: base-4.8.0.0

Instances

Instances details
FromJSON Void 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Void

Since: aeson-2.1.2.0

Instance details

Defined in Data.Aeson.Types.FromJSON

ToJSON Void 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Void

Since: aeson-2.1.2.0

Instance details

Defined in Data.Aeson.Types.ToJSON

Semigroup Void

Since: base-4.9.0.0

Instance details

Defined in GHC.Base

Methods

(<>) :: Void -> Void -> Void #

sconcat :: NonEmpty Void -> Void #

stimes :: Integral b => b -> Void -> Void #

Exception Void

Since: base-4.8.0.0

Instance details

Defined in GHC.Exception.Type

Generic Void 
Instance details

Defined in GHC.Generics

Associated Types

type Rep Void :: Type -> Type #

Methods

from :: Void -> Rep Void x #

to :: Rep Void x -> Void #

Read Void

Reading a Void value is always a parse error, considering Void as a data type with no constructors.

Since: base-4.8.0.0

Instance details

Defined in GHC.Read

Show Void

Since: base-4.8.0.0

Instance details

Defined in GHC.Show

Methods

showsPrec :: Int -> Void -> ShowS #

show :: Void -> String #

showList :: [Void] -> ShowS #

NFData Void

Defined as rnf = absurd.

Since: deepseq-1.4.0.0

Instance details

Defined in Control.DeepSeq

Methods

rnf :: Void -> () #

Eq Void

Since: base-4.8.0.0

Instance details

Defined in GHC.Base

Methods

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

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

Ord Void

Since: base-4.8.0.0

Instance details

Defined in GHC.Base

Methods

compare :: Void -> Void -> Ordering #

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

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

(>) :: Void -> Void -> Bool #

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

max :: Void -> Void -> Void #

min :: Void -> Void -> Void #

Hashable Void 
Instance details

Defined in Data.Hashable.Class

Methods

hashWithSalt :: Int -> Void -> Int #

hash :: Void -> Int #

FromFormKey Void 
Instance details

Defined in Web.Internal.FormUrlEncoded

ToFormKey Void 
Instance details

Defined in Web.Internal.FormUrlEncoded

Methods

toFormKey :: Void -> Text #

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

ToHttpApiData Void 
Instance details

Defined in Web.Internal.HttpApiData

RHListToHList Void Source # 
Instance details

Defined in Web.Minion.Args.Internal

Associated Types

type HListTypes Void :: [Type] Source #

Lift Void

Since: template-haskell-2.15.0.0

Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Quote m => Void -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => Void -> Code m Void #

Show (RHList Void) Source # 
Instance details

Defined in Web.Minion.Args.Internal

type Rep Void

Since: base-4.8.0.0

Instance details

Defined in GHC.Generics

type Rep Void = D1 ('MetaData "Void" "GHC.Base" "base" 'False) (V1 :: Type -> Type)
type HListTypes Void Source # 
Instance details

Defined in Web.Minion.Args.Internal

type HListTypes Void = '[] :: [Type]
type Introspection Void 'Capture Source # 
Instance details

Defined in Web.Minion.Introspect

type Introspection Void 'Captures Source # 
Instance details

Defined in Web.Minion.Introspect

type Introspection Void 'Header Source # 
Instance details

Defined in Web.Minion.Introspect

type Introspection Void 'QueryParam Source # 
Instance details

Defined in Web.Minion.Introspect

type Introspection Void 'Request Source # 
Instance details

Defined in Web.Minion.Introspect

type Introspection Void 'Response Source # 
Instance details

Defined in Web.Minion.Introspect

class MonadThrow m => MonadCatch (m :: Type -> Type) where #

A class for monads which allow exceptions to be caught, in particular exceptions which were thrown by throwM.

Instances should obey the following law:

catch (throwM e) f = f e

Note that the ability to catch an exception does not guarantee that we can deal with all possible exit points from a computation. Some monads, such as continuation-based stacks, allow for more than just a success/failure strategy, and therefore catch cannot be used by those monads to properly implement a function such as finally. For more information, see MonadMask.

Methods

catch :: (HasCallStack, Exception e) => m a -> (e -> m a) -> m a #

Provide a handler for exceptions thrown during execution of the first action. Note that type of the type of the argument to the handler will constrain which exceptions are caught. See Control.Exception's catch.

Instances

Instances details
MonadCatch STM 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: (HasCallStack, Exception e) => STM a -> (e -> STM a) -> STM a #

MonadCatch IO 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: (HasCallStack, Exception e) => IO a -> (e -> IO a) -> IO a #

e ~ SomeException => MonadCatch (Either e)

Since: exceptions-0.8.3

Instance details

Defined in Control.Monad.Catch

Methods

catch :: (HasCallStack, Exception e0) => Either e a -> (e0 -> Either e a) -> Either e a #

MonadCatch m => MonadCatch (MaybeT m)

Catches exceptions from the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

catch :: (HasCallStack, Exception e) => MaybeT m a -> (e -> MaybeT m a) -> MaybeT m a #

MonadCatch m => MonadCatch (ExceptT e m)

Catches exceptions from the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

catch :: (HasCallStack, Exception e0) => ExceptT e m a -> (e0 -> ExceptT e m a) -> ExceptT e m a #

MonadCatch m => MonadCatch (IdentityT m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: (HasCallStack, Exception e) => IdentityT m a -> (e -> IdentityT m a) -> IdentityT m a #

MonadCatch m => MonadCatch (ReaderT r m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: (HasCallStack, Exception e) => ReaderT r m a -> (e -> ReaderT r m a) -> ReaderT r m a #

MonadCatch m => MonadCatch (StateT s m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: (HasCallStack, Exception e) => StateT s m a -> (e -> StateT s m a) -> StateT s m a #

MonadCatch m => MonadCatch (StateT s m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: (HasCallStack, Exception e) => StateT s m a -> (e -> StateT s m a) -> StateT s m a #

(MonadCatch m, Monoid w) => MonadCatch (WriterT w m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: (HasCallStack, Exception e) => WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a #

(MonadCatch m, Monoid w) => MonadCatch (WriterT w m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: (HasCallStack, Exception e) => WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a #

(MonadCatch m, Monoid w) => MonadCatch (RWST r w s m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: (HasCallStack, Exception e) => RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a #

(MonadCatch m, Monoid w) => MonadCatch (RWST r w s m) 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: (HasCallStack, Exception e) => RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a #

class Monad m => MonadThrow (m :: Type -> Type) where #

A class for monads in which exceptions may be thrown.

Instances should obey the following law:

throwM e >> x = throwM e

In other words, throwing an exception short-circuits the rest of the monadic computation.

Methods

throwM :: (HasCallStack, Exception e) => e -> m a #

Throw an exception. Note that this throws when this action is run in the monad m, not when it is applied. It is a generalization of Control.Exception's throwIO.

Should satisfy the law:

throwM e >> f = throwM e

Instances

Instances details
MonadThrow STM 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e) => e -> STM a #

MonadThrow IO 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e) => e -> IO a #

MonadThrow Q 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e) => e -> Q a #

MonadThrow Maybe 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e) => e -> Maybe a #

MonadThrow List 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e) => e -> [a] #

e ~ SomeException => MonadThrow (Either e) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e0) => e0 -> Either e a #

MonadThrow (ST s) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e) => e -> ST s a #

MonadThrow m => MonadThrow (MaybeT m)

Throws exceptions into the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e) => e -> MaybeT m a #

MonadThrow m => MonadThrow (ExceptT e m)

Throws exceptions into the base monad.

Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e0) => e0 -> ExceptT e m a #

MonadThrow m => MonadThrow (IdentityT m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e) => e -> IdentityT m a #

MonadThrow m => MonadThrow (ReaderT r m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e) => e -> ReaderT r m a #

MonadThrow m => MonadThrow (StateT s m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e) => e -> StateT s m a #

MonadThrow m => MonadThrow (StateT s m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e) => e -> StateT s m a #

(MonadThrow m, Monoid w) => MonadThrow (WriterT w m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e) => e -> WriterT w m a #

(MonadThrow m, Monoid w) => MonadThrow (WriterT w m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e) => e -> WriterT w m a #

MonadThrow m => MonadThrow (ContT r m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e) => e -> ContT r m a #

(MonadThrow m, Monoid w) => MonadThrow (RWST r w s m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e) => e -> RWST r w s m a #

(MonadThrow m, Monoid w) => MonadThrow (RWST r w s m) 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e) => e -> RWST r w s m a #