both-0.1.0.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

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

The mappend for Maybe is Just if either of the operands are, whereas here both must be.

Typeable (* -> *) Both 
type Rep1 Both 
type Rep (Both a) 

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.