From 44125f75a6f10c79e42cab692e17180d2d4f4950 Mon Sep 17 00:00:00 2001 From: Tissevert Date: Wed, 18 Mar 2020 15:06:20 +0100 Subject: [PATCH] The orphan instance for MonadState s m => MonadReader s m really can't be used, so replace it with a mere function that runs an operation on a ReaderT into the monad State, allowing to borrow operations on MonadReader in a MonadState context --- src/PDF/Box.hs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/PDF/Box.hs b/src/PDF/Box.hs index efb2cc8..bf129f9 100644 --- a/src/PDF/Box.hs +++ b/src/PDF/Box.hs @@ -12,12 +12,13 @@ module PDF.Box ( , at , atAll , edit + , runRO ) where import Control.Monad.Except (ExceptT(..), runExceptT) import Control.Monad.Fail (MonadFail(..)) import Control.Monad.State (MonadState(..)) ---import Control.Monad.Reader (MonadReader(..)) +import Control.Monad.Reader (ReaderT, runReaderT) import Data.Id (Id, IdMap) import qualified Data.Id as Id (insert, lookup) import Data.Map (Map) @@ -26,16 +27,8 @@ import Data.OrderedMap (OrderedMap) import qualified Data.OrderedMap as OrderedMap (lookup, set) import Prelude hiding (fail) -{- -instance (Monad m, MonadState s m) => MonadReader s m where - ask = get - local f m = do - backup <- get - put $ f backup - result <- m - put backup - return result --} +runRO :: MonadState s m => ReaderT s m a -> m a +runRO ro = get >>= runReaderT ro newtype Index = Index Int newtype Maybe_ x = Maybe_ x