sum package:base-prelude

The sum function computes the sum of the numbers of a structure.

Examples

Basic usage:
>>> sum []
0
>>> sum [42]
42
>>> sum [1..10]
55
>>> sum [4.1, 2.0, 1.7]
7.8
>>> sum [1..]
* Hangs forever *
Monoid under addition.
>>> getSum (Sum 1 <> Sum 2 <> mempty)
3
The sum of a collection of actions, generalizing concat. asum is just like msum, but generalised to Alternative.

Examples

Basic usage:
>>> asum [Just "Hello", Nothing, Just "World"]
Just "Hello"
The sum of a collection of actions, generalizing concat. msum is just like asum, but specialised to MonadPlus.