Optimistically prepare the instance declaration for Pages that should replace get / getAll, not really getting out of the Monad

This commit is contained in:
Tissevert 2020-02-28 18:15:40 +01:00
parent 4969c6442e
commit 9ce1a48030

View file

@ -1,4 +1,7 @@
{-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module PDF.Pages ( module PDF.Pages (
Page(..) Page(..)
, get , get
@ -109,6 +112,11 @@ loadPage source = do
contents <- extractText =<< objectById source contents <- extractText =<< objectById source
return $ Page {contents, 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 :: Layer -> Either String (Map Int Page)
getAll content = runError $ fst <$> evalRWST getPages content Map.empty getAll content = runError $ fst <$> evalRWST getPages content Map.empty
where where