agreeing-0.1.0.0: Idiomatic data structure for agreement
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Agreement

Description

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"

Synopsis

Documentation

data Agreement a Source #

We have the following constructors: * Somebody is a consistent choice of an element. * Nobody is an inconsistent choice. * Anybody is a failure to make any choice.

Constructors

Anybody 
Somebody a 
Nobody 

Instances

Instances details
Functor Agreement Source # 
Instance details

Defined in Data.Agreement

Methods

fmap :: (a -> b) -> Agreement a -> Agreement b #

(<$) :: a -> Agreement b -> Agreement a #

Eq a => Monoid (Agreement a) Source # 
Instance details

Defined in Data.Agreement

Eq a => Semigroup (Agreement a) Source # 
Instance details

Defined in Data.Agreement

Methods

(<>) :: Agreement a -> Agreement a -> Agreement a #

sconcat :: NonEmpty (Agreement a) -> Agreement a #

stimes :: Integral b => b -> Agreement a -> Agreement a #

getSomebody :: Agreement a -> Maybe a Source #

This picks out consistent choices as Just.