This module provides safe zipping functions which will fail
Nothing) on uneven length lists.
- pairWithBy :: (a -> b -> c) -> (c -> d -> d) -> d -> [a] -> [b] -> Maybe d
- pairWith :: (a -> b -> c) -> [a] -> [b] -> Maybe [c]
- pairBy :: ((a, b) -> m (a, b) -> m (a, b)) -> m (a, b) -> [a] -> [b] -> Maybe (m (a, b))
- pair :: [a] -> [b] -> Maybe [(a, b)]
- biject :: [a -> b] -> [a] -> Maybe [b]
- biject' :: [a -> b] -> [a] -> Maybe [b]
- zipWithBy :: (a -> b -> c) -> (c -> d -> d) -> d -> [a] -> [b] -> d
- zipBy :: ((a, b) -> m (a, b) -> m (a, b)) -> m (a, b) -> [a] -> [b] -> m (a, b)
Safe functions for zipping lists
A generic version of
pair. The first argument is a tuple
homomorphism (i.e. a function for how to combine values from the
two lists), the second two arguments form a list homomorphism
(i.e. so you can
[c] list directly without actually
In order to evaluate to WHNF
pairWithBy is strict in both list
arguments, as it must be, to determine that the lists are of the
same length. This means it can survive one infinite list (yielding
Nothing) but that it can't survive two. The implementation is
very efficient and uses a tight tail-recursive loop, however
with extremely long lists it will be churning through heap and
that tightness can make it hard to interrupt (lists of 1 million
elements return in 1~2 seconds, but lists of 10 million can lock
your system up).
A safe version of
zip that uses a user-defined list homomorphism.
Special safe zipping functions
A bijection from a list of functions and a list of arguments to a list of results of applying the functions bijectively.
A version of
biject that applies functions strictly. N.B.
the list is still lazily evaluated, this just makes the functions
strict in their argument.
New (unsafe) zipping functions
An unsafe variant of
pairWithBy to fill out the interface.