{-# LANGUAGE NoImplicitPrelude, UnicodeSyntax, TypeApplications, ScopedTypeVariables, CPP #-}
module Magicbane.App (
module X
, module Magicbane.App
, RIO
) where
import RIO
import Control.Monad.Trans.Except (ExceptT (..))
import Data.Proxy as X
import Servant as X hiding (And, Handler)
import qualified Servant
runMagicbaneHandler ∷ β → RIO β α → Servant.Handler α
runMagicbaneHandler ctx a = Servant.Handler $ ExceptT $ try $ runReaderT (unRIO a) ctx
magicbaneApp ∷ forall β χ ψ. (HasServer χ ψ) ⇒ Proxy χ → Context ψ → β → ServerT χ (RIO β) → Application
magicbaneApp api sctx ctx actions = serveWithContext api sctx $ srv ctx
where srv c = hoistServerWithContext api (Proxy @ψ) (runMagicbaneHandler c) actions