Data.ListLike.Utils

ListLike-3.1.5: Generic support for list-like structures

Portability | portable
Stability | provisional
Maintainer | John Lato <jwlato@gmail.com>
Safe Haskell | Safe-Infered

Data.ListLike.Utils

Description

Utilities for `ListLike` and friends. More functions similar to `List` but not part of the main typeclass.

Written by John Goerzen, jgoerzen@complete.org

Synopsis

- and :: ListLike full Bool => full -> Bool
- or :: ListLike full Bool => full -> Bool
- sum :: (Num a, ListLike full a) => full -> a
- product :: (Num a, ListLike full a) => full -> a
- zip :: (ListLike full item, ListLike fullb itemb, ListLike result (item, itemb)) => full -> fullb -> result
- zipWith :: (ListLike full item, ListLike fullb itemb, ListLike result resultitem) => (item -> itemb -> resultitem) -> full -> fullb -> result
- unzip :: (ListLike full (itema, itemb), ListLike ra itema, ListLike rb itemb) => full -> (ra, rb)
- sequence_ :: (Monad m, ListLike mfull (m item)) => mfull -> m ()
- toMonadPlus :: (MonadPlus m, ListLike full a) => full -> m (a, full)
- list :: ListLike full a => b -> (a -> full -> b) -> full -> b

# Documentation

and :: ListLike full Bool => full -> Bool

Returns True if all elements are True

or :: ListLike full Bool => full -> Bool

Returns True if any element is True

sum :: (Num a, ListLike full a) => full -> a

The sum of the list

product :: (Num a, ListLike full a) => full -> a

The product of the list

zip :: (ListLike full item, ListLike fullb itemb, ListLike result (item, itemb)) => full -> fullb -> result

Takes two lists and returns a list of corresponding pairs.

zipWith :: (ListLike full item, ListLike fullb itemb, ListLike result resultitem) => (item -> itemb -> resultitem) -> full -> fullb -> result

Takes two lists and combines them with a custom combining function

unzip :: (ListLike full (itema, itemb), ListLike ra itema, ListLike rb itemb) => full -> (ra, rb)

Converts a list of pairs into two separate lists of elements

sequence_ :: (Monad m, ListLike mfull (m item)) => mfull -> m ()

Evaluate each action, ignoring the results

toMonadPlus :: (MonadPlus m, ListLike full a) => full -> m (a, full)

Converts to a MonadPlus instance

list :: ListLike full a => b -> (a -> full -> b) -> full -> b

List-like destructor (like Data.Maybe.maybe)