From afaa0cc6790b55e2db31450d3a2951d524930585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 2 Aug 2026 11:00:02 +0200 Subject: Function to load Storable from Stored Object --- src/Erebos/Object/Internal.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/Erebos/Object/Internal.hs') diff --git a/src/Erebos/Object/Internal.hs b/src/Erebos/Object/Internal.hs index b624d1c..778f80a 100644 --- a/src/Erebos/Object/Internal.hs +++ b/src/Erebos/Object/Internal.hs @@ -30,7 +30,7 @@ module Erebos.Object.Internal ( storeRecItems, Load, LoadRec, - evalLoad, + evalLoad, evalLoadWithObject, loadCurrentRef, loadCurrentObject, loadRecCurrentRef, loadRecItems, @@ -454,8 +454,11 @@ newtype Load a = Load (ReaderT (Ref, Object) (Except ErebosError) a) deriving (Functor, Applicative, Alternative, Monad, MonadPlus, MonadError ErebosError) evalLoad :: Load a -> Ref -> a -evalLoad (Load f) ref = either (error {- TODO throw -} . ((BC.unpack (showRef ref) ++ ": ") ++) . showErebosError) id $ - runExcept $ runReaderT f (ref, lazyLoadObject ref) +evalLoad act ref = evalLoadWithObject act ref (lazyLoadObject ref) + +evalLoadWithObject :: Load a -> Ref -> Object -> a +evalLoadWithObject (Load f) ref obj = either (error {- TODO throw -} . ((BC.unpack (showRef ref) ++ ": ") ++) . showErebosError) id $ + runExcept $ runReaderT f ( ref, obj ) loadCurrentRef :: Load Ref loadCurrentRef = Load $ asks fst -- cgit v1.2.3