Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 66a0549

Browse files
Create NonEmptySet type
1 parent a34deb2 commit 66a0549

File tree

5 files changed

+188
-144
lines changed

5 files changed

+188
-144
lines changed

‎Data/Map/Internal.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,7 @@ difference t1 (Bin (NonEmptyMap _ k _ l2 r2)) = case split k t1 of
19231923
withoutKeys :: Ord k => Map k a -> Set k -> Map k a
19241924
withoutKeys Tip _ = Tip
19251925
withoutKeys m Set.Tip = m
1926-
withoutKeys m (Set.Bin _ k ls rs) = case splitMember k m of
1926+
withoutKeys m (Set.Bin (Set.NonEmptySet_ k ls rs)) = case splitMember k m of
19271927
(lm, b, rm)
19281928
| not b && lm' `ptrEq` lm && rm' `ptrEq` rm -> m
19291929
| otherwise -> link2 lm' rm'
@@ -3316,7 +3316,8 @@ assocs m
33163316

33173317
keysSet :: Map k a -> Set.Set k
33183318
keysSet Tip = Set.Tip
3319-
keysSet (Bin (NonEmptyMap sz kx _ l r)) = Set.Bin sz kx (keysSet l) (keysSet r)
3319+
keysSet (Bin (NonEmptyMap sz kx _ l r)) = Set.Bin $
3320+
Set.NonEmptySet sz kx (keysSet l) (keysSet r)
33203321

33213322
-- | /O(n)/. Build a map from a set of keys and a function which for each key
33223323
-- computes its value.
@@ -3326,7 +3327,7 @@ keysSet (Bin (NonEmptyMap sz kx _ l r)) = Set.Bin sz kx (keysSet l) (keysSet r)
33263327

33273328
fromSet :: (k -> a) -> Set.Set k -> Map k a
33283329
fromSet _ Set.Tip = Tip
3329-
fromSet f (Set.Bin sz x l r) = Bin $ NonEmptyMap sz x (f x) (fromSet f l) (fromSet f r)
3330+
fromSet f (Set.Bin (Set.NonEmptySetsz x l r)) = Bin $ NonEmptyMap sz x (f x) (fromSet f l) (fromSet f r)
33303331

33313332
{--------------------------------------------------------------------
33323333
Lists

‎Data/Map/Strict/Internal.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,8 @@ mapKeysWith c f = fromListWith c . foldrWithKey (\k x xs -> (f k, x) : xs) []
14691469

14701470
fromSet :: (k -> a) -> Set.Set k -> Map k a
14711471
fromSet _ Set.Tip = Tip
1472-
fromSet f (Set.Bin sz x l r) = case f x of v -> v `seq` Bin (NonEmptyMap sz x v (fromSet f l) (fromSet f r))
1472+
fromSet f (Set.Bin (Set.NonEmptySet sz x l r)) = case f x of
1473+
v -> v `seq` Bin (NonEmptyMap sz x v (fromSet f l) (fromSet f r))
14731474

14741475
{--------------------------------------------------------------------
14751476
Lists

‎Data/Set.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ module Data.Set (
7070
Set -- instance Eq,Ord,Show,Read,Data,Typeable
7171
#else
7272
Set(..)
73+
, NonEmptySet(..)
7374
#endif
7475

7576
-- * Construction

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /