Skip to content

Commit

Permalink
Merge pull request #376 from treeowl/kill-getSingleton
Browse files Browse the repository at this point in the history
Kill getSingleton
  • Loading branch information
treeowl committed Jan 6, 2017
2 parents d3ca45a + dbed0dd commit 9253dc6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Data/Sequence/Internal.hs
Expand Up @@ -4075,10 +4075,6 @@ splitMapNode splt f s (Node3 ns a b c) = Node3 ns (f first a) (f second b) (f th
(second, third) = splt (size b) r
#endif

getSingleton :: Seq a -> a
getSingleton (Seq (Single (Elem a))) = a
getSingleton _ = error "getSingleton: Not a singleton."

------------------------------------------------------------------------
-- Zipping
------------------------------------------------------------------------
Expand Down Expand Up @@ -4205,7 +4201,10 @@ zipWith f s1 s2 = zipWith' f s1' s2'

-- | A version of zipWith that assumes the sequences have the same length.
zipWith' :: (a -> b -> c) -> Seq a -> Seq b -> Seq c
zipWith' f s1 s2 = splitMap uncheckedSplitAt (\s a -> f a (getSingleton s)) s2 s1
zipWith' f s1 s2 = splitMap uncheckedSplitAt goLeaf s2 s1
where
goLeaf (Seq (Single (Elem b))) a = f a b
goLeaf _ _ = error "Data.Sequence.zipWith'.goLeaf internal error: not a singleton"

-- | /O(min(n1,n2,n3))/. 'zip3' takes three sequences and returns a
-- sequence of triples, analogous to 'zip'.
Expand Down

0 comments on commit 9253dc6

Please sign in to comment.