Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Magnify instance for CPS RWST #1060

Merged
merged 8 commits into from
May 5, 2024
2 changes: 1 addition & 1 deletion lens.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ library
indexed-traversable >= 0.1 && < 0.2,
indexed-traversable-instances >= 0.1 && < 0.2,
kan-extensions >= 5 && < 6,
mtl >= 2.2.1 && < 2.4,
mtl >= 2.3 && < 2.4,
BebeSparkelSparkel marked this conversation as resolved.
Show resolved Hide resolved
parallel >= 3.2.1.0 && < 3.3,
profunctors >= 5.5.2 && < 6,
reflection >= 2.1 && < 3,
Expand Down
6 changes: 6 additions & 0 deletions src/Control/Lens/Zoom.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import Control.Monad.Trans.Writer.Lazy as Lazy
import Control.Monad.Trans.Writer.Strict as Strict
import Control.Monad.Trans.RWS.Lazy as Lazy
import Control.Monad.Trans.RWS.Strict as Strict
import Control.Monad.Trans.RWS.CPS as CPS
BebeSparkelSparkel marked this conversation as resolved.
Show resolved Hide resolved
import Control.Monad.Trans.Except
import Control.Monad.Trans.Identity
import Control.Monad.Trans.Maybe
Expand Down Expand Up @@ -102,6 +103,7 @@ type instance Magnified (ReaderT b m) = Effect m
type instance Magnified ((->)b) = Const
type instance Magnified (Strict.RWST a w s m) = EffectRWS w s m
type instance Magnified (Lazy.RWST a w s m) = EffectRWS w s m
type instance Magnified (CPS.RWST a w s m) = EffectRWS w s m
BebeSparkelSparkel marked this conversation as resolved.
Show resolved Hide resolved
type instance Magnified (IdentityT m) = Magnified m

------------------------------------------------------------------------------
Expand Down Expand Up @@ -274,6 +276,10 @@ instance (Monad m, Monoid w) => Magnify (Lazy.RWST b w s m) (Lazy.RWST a w s m)
magnify l (Lazy.RWST m) = Lazy.RWST $ getEffectRWS #. l (EffectRWS #. m)
{-# INLINE magnify #-}

instance (Monad m, Monoid w, MonadReader b (CPS.RWST b w s m)) => Magnify (CPS.RWST b w s m) (CPS.RWST a w s m) b a where
magnify l m = CPS.rwsT $ getEffectRWS #. l (EffectRWS #. CPS.runRWST m)
{-# INLINE magnify #-}

instance Magnify m n b a => Magnify (IdentityT m) (IdentityT n) b a where
magnify l (IdentityT m) = IdentityT (magnify l m)
{-# INLINE magnify #-}
Loading