-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A monad type class shared between web services -- -- Please see README.md @package unitym @version 0.1.0.2 -- | One of the nice things about WAI is that it allows us to combine -- multiple different server frameworks in a single web server- allowing -- us to use (for example) Yesod to develop the server-side rendered HTML -- part of the website, and Servant to develop the REST API part. But -- this gives rise to a desire to share code between the different -- frameworks. This is where UnityM comes in. -- -- UnityM is a type class for monad transformer stacks for web servers. -- The assumption, in addition to being in some monad, is that we are -- responding to some HTTP request, and can thus assume three things: -- --
-- class HasFoo a where -- getFoo :: a -> Foo -- -- bar :: (Monad m, HasFoo c, UnityM c m) => Something -> m Whatever -- bar x = do -- myFoo <- getFoo <$> getContext -- ... ---- -- Note that this type class assumes the code is "low-level", away from -- the web request- buisness logic, database access, etc. And thus a rich -- API for different status responses is not needed. Only two error -- results are supported- the generic 500 Internal Server error, and the -- 403 Permission Denied error. The second is only supported so that -- access grants can be generalized. Error checking code that needs -- different status results should be written in a framework-specific -- way. -- -- The different implementations of the unity monad are in separate -- projects, so you don't get unnecessary dependencies. module Network.UnityM -- | The Unity Monad type class. -- -- For code that executes in multiple different web contexts. class UnityM c m | m -> c -- | Get the context, the global read-only data object getContext :: UnityM c m => m c -- | Short circuit the request with a 403 (Forbidden) status. permissionDenied :: UnityM c m => Text -> m a -- | Support monad transformers on top of a Unity monad. instance (GHC.Base.Monad m, Network.UnityM.UnityM c m, Control.Monad.Trans.Class.MonadTrans t) => Network.UnityM.UnityM c (t m)