From b3a0d801d4f67aff2551cb5a7ece1a11db0887ec Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 17:33:10 +0000 Subject: documentation --- server/src/Thermoprint/Server/API.hs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'server/src') diff --git a/server/src/Thermoprint/Server/API.hs b/server/src/Thermoprint/Server/API.hs index bff8eed..2aa9cb8 100644 --- a/server/src/Thermoprint/Server/API.hs +++ b/server/src/Thermoprint/Server/API.hs @@ -88,6 +88,7 @@ thermoprintServer = listPrinters infixr 9 <||> lookupPrinter :: Maybe PrinterId -> Handler (PrinterId, Printer) +-- ^ Make sure a printer exists lookupPrinter pId = asks printers >>= maybePrinter' pId where maybePrinter' Nothing printerMap @@ -98,9 +99,11 @@ lookupPrinter pId = asks printers >>= maybePrinter' pId | otherwise = left $ err404 { errBody = "No such printer" } queue' :: MonadIO m => Printer -> m Queue +-- ^ Call 'queue' and handle concurrency queue' = liftIO . readTVarIO . queue extractJobs :: (PrinterId, Queue) -> Seq (API.JobId, JobStatus) +-- ^ Get an API-compatible list of all jobs from a 'Printer' 'Queue' extractJobs (pId, Queue pending current history) = fmap (, Queued pId) pending' <> maybe Seq.empty Seq.singleton (fmap (, Printing pId) current') <> fmap (second $ maybe Done Failed) history' where pending' = fmap (castId' . unJobKey) pending -- cgit v1.2.3