Skip to content

Commit f1e0f8e

Browse files
committed
Clean up <*> development artifacts
Some silly remnants of my thought process remained in the code. Remove them.
1 parent 55f65cd commit f1e0f8e

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

Data/Sequence.hs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -338,15 +338,18 @@ aptyMiddle firstf
338338
(Deep s (squashL pr prm) mm (squashR sfm sf)))
339339
(fmap (fmap lastf) sfm)
340340

341-
-- At the bottom
341+
-- At the bottom. Note that these appendTree0 calls are very cheap, because in
342+
-- each case, one of the arguments is guaranteed to be Empty or Single.
342343
aptyMiddle firstf
343344
lastf
344345
map23
345346
fs
346347
(Deep s pr m sf)
347-
= (fmap (fmap firstf) m `snocTree` fmap firstf (digitToNode sf))
348-
`appendTree0` middle `appendTree0`
349-
(fmap lastf (digitToNode pr) `consTree` fmap (fmap lastf) m)
348+
= fmap (fmap firstf) m `appendTree0`
349+
((fmap firstf (digitToNode sf)
350+
`consTree` middle)
351+
`snocTree` fmap lastf (digitToNode pr))
352+
`appendTree0` fmap (fmap lastf) m
350353
where middle = case trimTree $ mapMulFT s (\(Elem f) -> fmap (fmap (map23 f)) converted) fs of
351354
(firstMapped, restMapped, lastMapped) ->
352355
Deep (size firstMapped + size restMapped + size lastMapped)
@@ -469,17 +472,16 @@ rigidify Single{} = error "rigidify: singleton"
469472
-- | /O(log n)/ (incremental) Rejigger a finger tree so the digits are all ones
470473
-- and twos.
471474
thin :: Sized a => FingerTree a -> FingerTree a
472-
-- Note that 'thin' may call itself at most once before passing the job on to
473-
-- 'thin12'. 'thin12' will produce a 'Deep' constructor immediately before
474-
-- calling 'thin'.
475+
-- Note that 'thin12' will produce a 'Deep' constructor immediately before
476+
-- recursively calling 'thin'.
475477
thin Empty = Empty
476478
thin (Single a) = Single a
477479
thin t@(Deep s pr m sf) =
478480
case pr of
479481
One{} -> thin12 t
480482
Two{} -> thin12 t
481-
Three a b c -> thin $ Deep s (One a) (node2 b c `consTree` m) sf
482-
Four a b c d -> thin $ Deep s (Two a b) (node2 c d `consTree` m) sf
483+
Three a b c -> thin12 $ Deep s (One a) (node2 b c `consTree` m) sf
484+
Four a b c d -> thin12 $ Deep s (Two a b) (node2 c d `consTree` m) sf
483485

484486
thin12 :: Sized a => FingerTree a -> FingerTree a
485487
thin12 (Deep s pr m sf@One{}) = Deep s pr (thin m) sf

0 commit comments

Comments
 (0)