Skip to content

Commit dbf6ed1

Browse files
committed
use liftA3 instead of other applicative operations
1 parent e09db27 commit dbf6ed1

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

containers/src/Data/Map/Internal.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3551,10 +3551,7 @@ fromSet f = runIdentity . fromSetA (pure . f)
35513551
fromSetA :: Applicative f => (k -> f a) -> Set.Set k -> f (Map k a)
35523552
fromSetA _ Set.Tip = pure Tip
35533553
fromSetA f (Set.Bin sz x l r) =
3554-
flip (Bin sz x)
3555-
<$> fromSetA f l
3556-
<*> f x
3557-
<*> fromSetA f r
3554+
liftA3 (flip (Bin sz x)) (fromSetA f l) (f x) (fromSetA f r)
35583555
#if __GLASGOW_HASKELL__
35593556
{-# INLINABLE fromSetA #-}
35603557
#else

containers/src/Data/Map/Strict/Internal.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,10 +1482,8 @@ fromSet f = runIdentity . fromSetA (pure . f)
14821482
fromSetA :: Applicative f => (k -> f a) -> Set.Set k -> f (Map k a)
14831483
fromSetA _ Set.Tip = pure Tip
14841484
fromSetA f (Set.Bin sz x l r) =
1485-
flip (Bin sz x $!)
1486-
<$> fromSetA f l
1487-
<*> f x
1488-
<*> fromSetA f r
1485+
liftA3 (flip (Bin sz x) $!) (fromSetA f l) (f x) (fromSetA f r)
1486+
14891487
#if __GLASGOW_HASKELL__
14901488
{-# INLINABLE fromSetA #-}
14911489
#else

0 commit comments

Comments
 (0)