From 6348b2fb57b291b925ce27e9070eecc10d560608 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 23 Jan 2016 11:42:45 +0000 Subject: additional documentation --- server/src/Thermoprint/Server/API.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'server/src/Thermoprint/Server/API.hs') diff --git a/server/src/Thermoprint/Server/API.hs b/server/src/Thermoprint/Server/API.hs index 9559ad1..e147ac3 100644 --- a/server/src/Thermoprint/Server/API.hs +++ b/server/src/Thermoprint/Server/API.hs @@ -36,12 +36,16 @@ import Database.Persist.Sql type ProtoHandler = ReaderT HandlerInput (LoggingT IO) type Handler = EitherT ServantErr ProtoHandler -data HandlerInput = HandlerInput { sqlPool :: ConnectionPool +-- ^ Runtime configuration of our handlers +data HandlerInput = HandlerInput { sqlPool :: ConnectionPool -- ^ How to interact with 'persistent' storage } handlerNat :: ( MonadReader ConnectionPool m , MonadLoggerIO m ) => m (Handler :~> EitherT ServantErr IO) +-- ^ Servant requires its handlers to be 'EitherT ServantErr IO' +-- +-- This generates a 'Nat'ural transformation for squashing the monad-transformer-stack we use in our handlers to the monad 'servant-server' wants handlerNat = do sqlPool <- ask logFunc <- askLoggerIO @@ -54,6 +58,7 @@ handlerNat = do return $ hoistNat protoNat thermoprintServer :: ServerT ThermoprintAPI Handler +-- ^ A 'servant-server' for 'ThermoprintAPI' thermoprintServer = listPrinters :<|> (listJobs :<|> queueJob) :<|> getJob <||> jobStatus <||> deleteJob -- cgit v1.2.3