summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2024-02-19 22:07:46 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2024-02-19 22:07:46 +0100
commit43afce581e3cee0c85a2992b88a29e0fc8340242 (patch)
tree5767cefdeb8c82b245ec0945c449dbd0c05fa445
parent0769bfa51434b82159b4c68420330548b0451555 (diff)
Storage: replace Either in monad stack with Except
-rw-r--r--src/Erebos/Storage.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Erebos/Storage.hs b/src/Erebos/Storage.hs
index 2057072..0511814 100644
--- a/src/Erebos/Storage.hs
+++ b/src/Erebos/Storage.hs
@@ -573,11 +573,11 @@ newtype StoreRecM c a = StoreRecM (ReaderT (Storage' c) (Writer [IO [(ByteString
type StoreRec c = StoreRecM c ()
-newtype Load a = Load (ReaderT (Ref, Object) (Either String) a)
+newtype Load a = Load (ReaderT (Ref, Object) (Except String) a)
deriving (Functor, Applicative, Alternative, Monad, MonadPlus, MonadError String)
evalLoad :: Load a -> Ref -> a
-evalLoad (Load f) ref = either (error {- TODO throw -} . ((BC.unpack (showRef ref) ++ ": ")++)) id $ runReaderT f (ref, lazyLoadObject ref)
+evalLoad (Load f) ref = either (error {- TODO throw -} . ((BC.unpack (showRef ref) ++ ": ")++)) id $ runExcept $ runReaderT f (ref, lazyLoadObject ref)
loadCurrentRef :: Load Ref
loadCurrentRef = Load $ asks fst
@@ -585,7 +585,7 @@ loadCurrentRef = Load $ asks fst
loadCurrentObject :: Load Object
loadCurrentObject = Load $ asks snd
-newtype LoadRec a = LoadRec (ReaderT (Ref, [(ByteString, RecItem)]) (Either String) a)
+newtype LoadRec a = LoadRec (ReaderT (Ref, [(ByteString, RecItem)]) (Except String) a)
deriving (Functor, Applicative, Alternative, Monad, MonadPlus, MonadError String)
loadRecCurrentRef :: LoadRec Ref
@@ -754,7 +754,7 @@ loadRec :: LoadRec a -> Load a
loadRec (LoadRec lrec) = loadCurrentObject >>= \case
Rec rs -> do
ref <- loadCurrentRef
- either throwError return $ runReaderT lrec (ref, rs)
+ either throwError return $ runExcept $ runReaderT lrec (ref, rs)
_ -> throwError "Expecting record"
loadZero :: a -> Load a