zero-0.1.4: Semigroups with absorption

Data.Zero

Description

Synopsis

# Semigroups with absorbing element

class Semigroup a => Zero a where Source

`Semigroup` with a `zero` element. It’s important to understand that the standard `Semigroup` types – i.e. `Maybe` and so on – are already biased, because they’re `Monoid`s. That’s why you’ll find a few `Zero` instances.

Should satisfies the following laws:

#### Annihilation

` a `<>` `zero` = `zero` `<>` a = `zero``

#### Associativity

` a `<>` b `<>` c = (a `<>` b) `<>` c = a `<>` (b `<>` c)`

Minimal complete definition

zero

Methods

zero :: a Source

The zero element.

zconcat :: [a] -> a Source

Concat all the elements according to (`<>`) and `zero`.

Instances

 Zero () Source Source Source Num a => Zero (Product a) Source Semigroup a => Zero (Success a) Source

# Num wrappers

newtype Product a :: * -> *

Monoid under multiplication.

Constructors

 Product FieldsgetProduct :: a

Instances

 Bounded a => Bounded (Product a) Eq a => Eq (Product a) Num a => Num (Product a) Ord a => Ord (Product a) Read a => Read (Product a) Show a => Show (Product a) Num a => Monoid (Product a) Num a => Semigroup (Product a) Num a => Zero (Product a) Source type Rep1 Product = D1 D1Product (C1 C1_0Product (S1 S1_0_0Product Par1)) type Rep (Product a) = D1 D1Product (C1 C1_0Product (S1 S1_0_0Product (Rec0 a)))

# Boolean wrappers

newtype Any :: *

Boolean monoid under disjunction (`||`).

Constructors

 Any FieldsgetAny :: Bool

Instances

 Source type Rep Any = D1 D1Any (C1 C1_0Any (S1 S1_0_0Any (Rec0 Bool)))

newtype All :: *

Boolean monoid under conjunction (`&&`).

Constructors

 All FieldsgetAll :: Bool

Instances

 Source type Rep All = D1 D1All (C1 C1_0All (S1 S1_0_0All (Rec0 Bool)))

# Maybe wrappers

newtype Success a Source

`Zero` for `Maybe`.

Called `Success` because of the absorbing law:

```  `Success` (`Just` a) `<>` `Success` `Nothing` = `Nothing`
```

Constructors

 Success FieldsgetSuccess :: Maybe a

Instances

 Source Source Source Source Source Source Eq a => Eq (Success a) Source Ord a => Ord (Success a) Source Read a => Read (Success a) Source Show a => Show (Success a) Source Semigroup a => Semigroup (Success a) Source Semigroup a => Zero (Success a) Source

success :: a -> Success a Source

A successful value.

A failure.