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

This commit is contained in:
Tissevert 2020-03-18 15:06:20 +01:00
parent c8a5e2b191
commit 44125f75a6

View file

@ -12,12 +12,13 @@ module PDF.Box (
, at , at
, atAll , atAll
, edit , edit
, runRO
) where ) where
import Control.Monad.Except (ExceptT(..), runExceptT) import Control.Monad.Except (ExceptT(..), runExceptT)
import Control.Monad.Fail (MonadFail(..)) import Control.Monad.Fail (MonadFail(..))
import Control.Monad.State (MonadState(..)) import Control.Monad.State (MonadState(..))
--import Control.Monad.Reader (MonadReader(..)) import Control.Monad.Reader (ReaderT, runReaderT)
import Data.Id (Id, IdMap) import Data.Id (Id, IdMap)
import qualified Data.Id as Id (insert, lookup) import qualified Data.Id as Id (insert, lookup)
import Data.Map (Map) import Data.Map (Map)
@ -26,16 +27,8 @@ import Data.OrderedMap (OrderedMap)
import qualified Data.OrderedMap as OrderedMap (lookup, set) import qualified Data.OrderedMap as OrderedMap (lookup, set)
import Prelude hiding (fail) import Prelude hiding (fail)
{- runRO :: MonadState s m => ReaderT s m a -> m a
instance (Monad m, MonadState s m) => MonadReader s m where runRO ro = get >>= runReaderT ro
ask = get
local f m = do
backup <- get
put $ f backup
result <- m
put backup
return result
-}
newtype Index = Index Int newtype Index = Index Int
newtype Maybe_ x = Maybe_ x newtype Maybe_ x = Maybe_ x