Optimistically prepare the instance declaration for Pages that should replace get / getAll, not really getting out of the Monad
This commit is contained in:
parent
4969c6442e
commit
9ce1a48030
1 changed files with 8 additions and 0 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue