both-0.1.1.0: Like Maybe, but with a different Monoid instance.

Safe HaskellNone
LanguageHaskell2010

Data.Both

Description

The Both type and operations. Like Maybe, but not.

Synopsis

Documentation

newtype Both a Source

Constructors

Both 

Fields

getBoth :: Maybe a
 

Instances

Monad Both Source 
Functor Both Source 
Applicative Both Source 
Foldable Both Source 
Traversable Both Source 
Generic1 Both Source 
Alternative Both Source 
MonadPlus Both Source 
Eq a => Eq (Both a) Source 
Data a => Data (Both a) Source 
Ord a => Ord (Both a) Source 
Read a => Read (Both a) Source 
Show a => Show (Both a) Source 
Generic (Both a) Source 
(Monoid a, Semigroup a) => Monoid (Both a) Source 
Semigroup a => Semigroup (Both a) Source

The '(<>)' for Maybe is Just if either of the operands are, whereas here both must be.

Semigroup a => Zero (Both a) Source 
type Rep1 Both Source 
type Rep (Both a) Source 

both :: b -> (a -> b) -> Both a -> b Source

The both function takes a default value, a function, and a Both value. If the inner Maybe value is Nothing, the function returns the default value. Otherwise, it applies the function to the value inside the Just and returns the result.

fromBoth :: a -> Both a -> a Source

The fromBoth function takes a default value and a Both value. If the inner Maybe is Nothing, it returns the default value; otherwise, it returns the value contained within.