| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Magicbane.App
Description
Extends Servant with context. Basically wrapping Servant in a ReaderT of your type. Which should be a tuple of all your moudles and configs and stuff, so that the Data.Has module would let you access these items by type.
- newtype MagicbaneApp β α = MagicbaneApp {
- unMagicbaneApp :: ReaderT β (ExceptT ServantErr IO) α
- runMagicbaneExcept :: β -> MagicbaneApp β α -> ExceptT ServantErr IO α
- magicbaneToExcept :: β -> MagicbaneApp β :~> ExceptT ServantErr IO
- magicbaneApp :: (HasServer * api context, Enter typ ((:~>) * (MagicbaneApp β) (ExceptT ServantErr IO)) (ServerT * api Handler)) => Proxy * api -> Context context -> β -> typ -> Application
- askObj :: (Has β α, MonadReader α μ) => μ β
- askOpt :: (Has β α, MonadReader α μ) => (β -> ψ) -> μ ψ
Documentation
newtype MagicbaneApp β α Source #
Constructors
| MagicbaneApp | |
Fields
| |
Instances
| MonadReader β (MagicbaneApp β) Source # | |
| MonadBaseControl IO (MagicbaneApp β) Source # | |
| MonadBase IO (MagicbaneApp β) Source # | |
| MonadError ServantErr (MagicbaneApp β) Source # | |
| Monad (MagicbaneApp β) Source # | |
| Functor (MagicbaneApp β) Source # | |
| Applicative (MagicbaneApp β) Source # | |
| MonadIO (MagicbaneApp β) Source # | |
| MonadCatch (MagicbaneApp β) Source # | |
| MonadThrow (MagicbaneApp β) Source # | |
| type StM (MagicbaneApp β) α Source # | |
runMagicbaneExcept :: β -> MagicbaneApp β α -> ExceptT ServantErr IO α Source #
magicbaneToExcept :: β -> MagicbaneApp β :~> ExceptT ServantErr IO Source #
magicbaneApp :: (HasServer * api context, Enter typ ((:~>) * (MagicbaneApp β) (ExceptT ServantErr IO)) (ServerT * api Handler)) => Proxy * api -> Context context -> β -> typ -> Application Source #
Constructs a WAI application from an API definition, a Servant context (used for auth mainly), the app context and the actual action handlers.
askObj :: (Has β α, MonadReader α μ) => μ β Source #
Gets a value of any type from the context.
askOpt :: (Has β α, MonadReader α μ) => (β -> ψ) -> μ ψ Source #
Gets a thing from a value of any type from the context. (Useful for configuration fields.)