Skip to content

Commit 1e962fc

Browse files
committed
Make applicativeTree aim for safe digits
As previously discussed, this gives the tree more flexibility and matches what other functions do.
1 parent 55f65cd commit 1e962fc

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Data/Sequence.hs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -856,17 +856,14 @@ applicativeTree n mSize m = mSize `seq` case n of
856856
4 -> deepA two emptyTree two
857857
5 -> deepA three emptyTree two
858858
6 -> deepA three emptyTree three
859-
7 -> deepA four emptyTree three
860-
8 -> deepA four emptyTree four
861859
_ -> case n `quotRem` 3 of
862860
(q,0) -> deepA three (applicativeTree (q - 2) mSize' n3) three
863-
(q,1) -> deepA four (applicativeTree (q - 2) mSize' n3) three
864-
(q,_) -> deepA four (applicativeTree (q - 2) mSize' n3) four
861+
(q,1) -> deepA two (applicativeTree (q - 1) mSize' n3) two
862+
(q,_) -> deepA three (applicativeTree (q - 1) mSize' n3) two
865863
where
866864
one = fmap One m
867865
two = liftA2 Two m m
868866
three = liftA3 Three m m m
869-
four = liftA3 Four m m m <*> m
870867
deepA = liftA3 (Deep (n * mSize))
871868
mSize' = 3 * mSize
872869
n3 = liftA3 (Node3 mSize') m m m
@@ -2335,7 +2332,7 @@ unstableSortBy cmp (Seq xs) =
23352332
toPQ cmp (\ (Elem x) -> PQueue x Nil) xs
23362333

23372334
-- | fromList2, given a list and its length, constructs a completely
2338-
-- balanced Seq whose elements are that list using the applicativeTree
2335+
-- balanced Seq whose elements are that list using the replicateA
23392336
-- generalization.
23402337
fromList2 :: Int -> [a] -> Seq a
23412338
fromList2 n = execState (replicateA n (State ht))

0 commit comments

Comments
 (0)