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:
parent
c8a5e2b191
commit
44125f75a6
1 changed files with 4 additions and 11 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue