Skip to content

Commit

Permalink
use mapLiftingReader for local
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Hendrickson <[email protected]>
  • Loading branch information
BebeSparkelSparkel and rhendric authored Apr 18, 2024
1 parent cad092e commit 1843405
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Control/Monad/Reader/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,13 @@ newtype LiftingReader t m a = LiftingReader (t m a)

instance MonadReader r m => MonadReader r (LiftingReader (ReaderT r') m) where
ask = lift ask
local f (LiftingReader (ReaderT.ReaderT x)) = LiftingReader . ReaderT.ReaderT $ local f . x
local f = mapLiftingReader (ReaderT.mapReaderT (local f))
reader = lift . reader

instance (MonadReader r m, Monoid w) => MonadReader r (LiftingReader (LazyRWS.RWST r' w s) m) where
ask = lift ask
local f (LiftingReader (LazyRWS.RWST x)) = LiftingReader . LazyRWS.RWST $ \r s -> local f $ x r s
local f = mapLiftingReader (LazyRWS.mapRWST (local f))
reader = lift . reader

mapLiftingReader :: (t m a -> t n b) -> LiftingReader t m a -> LiftingReader t n b
mapLiftingReader = coerce

Check failure on line 225 in Control/Monad/Reader/Class.hs

View workflow job for this annotation

GitHub Actions / Native: GHC 9.0 on ubuntu-latest

Variable not in scope:

0 comments on commit 1843405

Please sign in to comment.