From 9ce1a48030a093eb2cfa7a6b9c48026604de749a Mon Sep 17 00:00:00 2001 From: Tissevert Date: Fri, 28 Feb 2020 18:15:40 +0100 Subject: [PATCH] Optimistically prepare the instance declaration for Pages that should replace get / getAll, not really getting out of the Monad --- src/PDF/Pages.hs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/PDF/Pages.hs b/src/PDF/Pages.hs index 14ad8fa..deee4ab 100755 --- a/src/PDF/Pages.hs +++ b/src/PDF/Pages.hs @@ -1,4 +1,7 @@ {-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE TypeSynonymInstances #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MultiParamTypeClasses #-} module PDF.Pages ( Page(..) , get @@ -109,6 +112,11 @@ loadPage source = do contents <- extractText =<< objectById source return $ Page {contents, source} +data Pages = Pages + +instance Box T Pages Layer (Map ObjectId Page) +instance Box T ObjectId Layer Page + getAll :: Layer -> Either String (Map Int Page) getAll content = runError $ fst <$> evalRWST getPages content Map.empty where