Safe Haskell | Safe-Inferred |
---|---|

Language | Haskell2010 |

A simple data structure helping us ask questions of the following
sort: "does all this data have the same *BLANK* and if so what is
it?"

For example:

doTheseHaveTheSameLength :: [String] -> String doTheseHaveTheSameLength l = case foldMap (Somebody . length) of Somebody n -> "They all have length " <> show n Nobody -> "The lengths differ" Anybody -> "You didn't give me any strings"

This can of course be done with `Maybe (Maybe x)` instead, but
doing so runs the risk of getting confused: which is `Nothing`

and
which is `Just Nothing`?

Unfortunately, there are two `Applicative`

instances.

One is easy to motivate intrinsically. If we think of `Anybody`

as
an empty list, `Somebody`

as a singleton list, and `Nobody`

as a
multi-element list, and think of the applicative instance on as
corresponding to the cartesian product, then we get an
`Applicative`

instance with

Anybody <*> Anybody = Anybody Anybody <*> Nobody = Nobody

This however cannot possibly correspond to a `Monad`

instance (if
the first argument of `>>=`

is Anybody, there's no way of
inspecting the second). We thus choose another, which does.

# Documentation

We have the following constructors:

#### Instances

Applicative Agreement Source # | Not the only possible instance: see introduction |

Functor Agreement Source # | |

Monad Agreement Source # | |

Eq a => Monoid (Agreement a) Source # | |

Eq a => Semigroup (Agreement a) Source # | |

Show a => Show (Agreement a) Source # | |

Eq a => Eq (Agreement a) Source # | |

Ord a => Ord (Agreement a) Source # | |

Defined in Data.Agreement |