Skip to content

Commit d9b51a3

Browse files
Improving code with liftA2 calls.
1 parent b4589fc commit d9b51a3

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/Data/MonoTraversable/Keys.hs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,15 +2175,15 @@ instance MonoZip (Const m a) where
21752175
instance Functor m => MonoZip (ContT r m a) where
21762176
{-# INLINE ozipWith #-}
21772177

2178-
ozipWith f x y = f <$> x <*> y
2178+
ozipWith = liftA2
21792179

21802180

21812181
-- |
21822182
-- /Since @v0.1.0@/
21832183
instance MonoZip (Either a b) where
21842184
{-# INLINE ozipWith #-}
21852185

2186-
ozipWith f x y = f <$> x <*> y
2186+
ozipWith = liftA2
21872187

21882188

21892189
-- |
@@ -2211,7 +2211,7 @@ instance MonoZip (Identity a) where
22112211
instance Applicative m => MonoZip (IdentityT m a) where
22122212
{-# INLINE ozipWith #-}
22132213

2214-
ozipWith f x y = f <$> x <*> y
2214+
ozipWith = liftA2
22152215

22162216

22172217
-- |
@@ -2231,7 +2231,7 @@ instance MonoZip (IntMap a) where
22312231
instance MonoZip (IO a) where
22322232
{-# INLINE ozipWith #-}
22332233

2234-
ozipWith f x y = f <$> x <*> y
2234+
ozipWith = liftA2
22352235

22362236

22372237
-- |
@@ -2255,7 +2255,7 @@ instance Ord k => MonoZip (Map k v) where
22552255
instance MonoZip (Maybe a) where
22562256
{-# INLINE ozipWith #-}
22572257

2258-
ozipWith f x y = f <$> x <*> y
2258+
ozipWith = liftA2
22592259

22602260

22612261
-- |
@@ -2279,7 +2279,7 @@ instance MonoZip (NonEmpty a) where
22792279
instance MonoZip (Option a) where
22802280
{-# INLINE ozipWith #-}
22812281

2282-
ozipWith f x y = f <$> x <*> y
2282+
ozipWith = liftA2
22832283

22842284

22852285
-- |
@@ -2299,7 +2299,7 @@ instance ( Zip f
22992299
instance Applicative m => MonoZip (ReaderT r m a) where
23002300
{-# INLINE ozipWith #-}
23012301

2302-
ozipWith f x y = f <$> x <*> y
2302+
ozipWith = liftA2
23032303

23042304

23052305
-- |
@@ -2427,31 +2427,31 @@ instance MonoZip (ViewR a) where
24272427
instance Arrow a => MonoZip (WrappedArrow a b c) where
24282428
{-# INLINE ozipWith #-}
24292429

2430-
ozipWith f x y = f <$> x <*> y
2430+
ozipWith = liftA2
24312431

24322432

24332433
-- |
24342434
-- /Since @v0.1.0@/
24352435
instance Monad m => MonoZip (WrappedMonad m a) where
24362436
{-# INLINE ozipWith #-}
24372437

2438-
ozipWith f x y = f <$> x <*> y
2438+
ozipWith = liftA2
24392439

24402440

24412441
-- |
24422442
-- /Since @v0.1.0@/
24432443
instance (Applicative m, Monoid w) => MonoZip (WriterT w m a) where
24442444
{-# INLINE ozipWith #-}
24452445

2446-
ozipWith f x y = f <$> x <*> y
2446+
ozipWith = liftA2
24472447

24482448

24492449
-- |
24502450
-- /Since @v0.1.0@/
24512451
instance (Applicative m, Monoid w) => MonoZip (S.WriterT w m a) where
24522452
{-# INLINE ozipWith #-}
24532453

2454-
ozipWith f x y = f <$> x <*> y
2454+
ozipWith = liftA2
24552455

24562456

24572457
-- |
@@ -2537,15 +2537,15 @@ instance MonoZipWithKey (Const m a) where
25372537
instance Functor m => MonoZipWithKey (ContT r m a) where
25382538
{-# INLINE ozipWithKey #-}
25392539

2540-
ozipWithKey f x y = (f ()) <$> x <*> y
2540+
ozipWithKey f = liftA2 (f ())
25412541

25422542

25432543
-- |
25442544
-- /Since @v0.1.0@/
25452545
instance MonoZipWithKey (Either a b) where
25462546
{-# INLINE ozipWithKey #-}
25472547

2548-
ozipWithKey f x y = (f ()) <$> x <*> y
2548+
ozipWithKey f = liftA2 (f ())
25492549

25502550

25512551
-- |
@@ -2573,7 +2573,7 @@ instance MonoZipWithKey (Identity a) where
25732573
instance Applicative m => MonoZipWithKey (IdentityT m a) where
25742574
{-# INLINE ozipWithKey #-}
25752575

2576-
ozipWithKey f x y = (f ()) <$> x <*> y
2576+
ozipWithKey f = liftA2 (f ())
25772577

25782578

25792579
-- |
@@ -2593,7 +2593,7 @@ instance MonoZipWithKey (IntMap a) where
25932593
instance MonoZipWithKey (IO a) where
25942594
{-# INLINE ozipWithKey #-}
25952595

2596-
ozipWithKey f x y = (f ()) <$> x <*> y
2596+
ozipWithKey f = liftA2 (f ())
25972597

25982598

25992599
-- |
@@ -2617,15 +2617,15 @@ instance Ord k => MonoZipWithKey (Map k v) where
26172617
instance MonoZipWithKey (Maybe a) where
26182618
{-# INLINE ozipWithKey #-}
26192619

2620-
ozipWithKey f x y = (f ()) <$> x <*> y
2620+
ozipWithKey f = liftA2 (f ())
26212621

26222622

26232623
-- |
26242624
-- /Since @v0.1.0@/
26252625
instance Monad m => MonoZipWithKey (MaybeT m a) where
26262626
{-# INLINE ozipWithKey #-}
26272627

2628-
ozipWithKey f x y = (f ()) <$> x <*> y
2628+
ozipWithKey f = liftA2 (f ())
26292629

26302630

26312631
-- |
@@ -2641,7 +2641,7 @@ instance MonoZipWithKey (NonEmpty a) where
26412641
instance MonoZipWithKey (Option a) where
26422642
{-# INLINE ozipWithKey #-}
26432643

2644-
ozipWithKey f x y = (f ()) <$> x <*> y
2644+
ozipWithKey f = liftA2 (f ())
26452645

26462646

26472647
-- |
@@ -2789,31 +2789,31 @@ instance MonoZipWithKey (ViewR a) where
27892789
instance Arrow a => MonoZipWithKey (WrappedArrow a b c) where
27902790
{-# INLINE ozipWithKey #-}
27912791

2792-
ozipWithKey f x y = f () <$> x <*> y
2792+
ozipWithKey f = liftA2 $ f ()
27932793

27942794

27952795
-- |
27962796
-- /Since @v0.1.0@/
27972797
instance Monad m => MonoZipWithKey (WrappedMonad m a) where
27982798
{-# INLINE ozipWithKey #-}
27992799

2800-
ozipWithKey f x y = f () <$> x <*> y
2800+
ozipWithKey f = liftA2 $ f ()
28012801

28022802

28032803
-- |
28042804
-- /Since @v0.1.0@/
28052805
instance (Applicative m, Monoid w) => MonoZipWithKey (WriterT w m a) where
28062806
{-# INLINE ozipWithKey #-}
28072807

2808-
ozipWithKey f x y = f () <$> x <*> y
2808+
ozipWithKey f = liftA2 $ f ()
28092809

28102810

28112811
-- |
28122812
-- /Since @v0.1.0@/
28132813
instance (Applicative m, Monoid w) => MonoZipWithKey (S.WriterT w m a) where
28142814
{-# INLINE ozipWithKey #-}
28152815

2816-
ozipWithKey f x y = f () <$> x <*> y
2816+
ozipWithKey f = liftA2 $ f ()
28172817

28182818

28192819
-- |

0 commit comments

Comments
 (0)