monoid-extras-0.4.4: Various extra monoid-related definitions and utilities

Copyright(c) 2012-2015 diagrams-core team (see LICENSE)
LicenseBSD-style (see LICENSE)
Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellSafe
LanguageHaskell2010

Data.Monoid.Recommend

Description

A type for representing values with an additional bit saying whether the value is "just a recommendation" (to be used only if nothing better comes along) or a "committment" (to certainly be used, overriding merely recommended values), along with corresponding Semigroup and Monoid instances.

Synopsis

Documentation

data Recommend a Source #

A value of type Recommend a consists of a value of type a wrapped up in one of two constructors. The Recommend constructor indicates a "non-committal recommendation"---that is, the given value should be used if no other/better values are available. The Commit constructor indicates a "commitment"---a value which should definitely be used, overriding any Recommended values.

Constructors

Recommend a 
Commit a 

Instances

Functor Recommend Source # 

Methods

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

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

Foldable Recommend Source # 

Methods

fold :: Monoid m => Recommend m -> m #

foldMap :: Monoid m => (a -> m) -> Recommend a -> m #

foldr :: (a -> b -> b) -> b -> Recommend a -> b #

foldr' :: (a -> b -> b) -> b -> Recommend a -> b #

foldl :: (b -> a -> b) -> b -> Recommend a -> b #

foldl' :: (b -> a -> b) -> b -> Recommend a -> b #

foldr1 :: (a -> a -> a) -> Recommend a -> a #

foldl1 :: (a -> a -> a) -> Recommend a -> a #

toList :: Recommend a -> [a] #

null :: Recommend a -> Bool #

length :: Recommend a -> Int #

elem :: Eq a => a -> Recommend a -> Bool #

maximum :: Ord a => Recommend a -> a #

minimum :: Ord a => Recommend a -> a #

sum :: Num a => Recommend a -> a #

product :: Num a => Recommend a -> a #

Traversable Recommend Source # 

Methods

traverse :: Applicative f => (a -> f b) -> Recommend a -> f (Recommend b) #

sequenceA :: Applicative f => Recommend (f a) -> f (Recommend a) #

mapM :: Monad m => (a -> m b) -> Recommend a -> m (Recommend b) #

sequence :: Monad m => Recommend (m a) -> m (Recommend a) #

Eq a => Eq (Recommend a) Source # 

Methods

(==) :: Recommend a -> Recommend a -> Bool #

(/=) :: Recommend a -> Recommend a -> Bool #

Data a => Data (Recommend a) Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Recommend a -> c (Recommend a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Recommend a) #

toConstr :: Recommend a -> Constr #

dataTypeOf :: Recommend a -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (Recommend a)) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Recommend a)) #

gmapT :: (forall b. Data b => b -> b) -> Recommend a -> Recommend a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Recommend a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Recommend a -> r #

gmapQ :: (forall d. Data d => d -> u) -> Recommend a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Recommend a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Recommend a -> m (Recommend a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Recommend a -> m (Recommend a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Recommend a -> m (Recommend a) #

Ord a => Ord (Recommend a) Source # 
Read a => Read (Recommend a) Source # 
Show a => Show (Recommend a) Source # 
Semigroup a => Semigroup (Recommend a) Source #

Commit overrides Recommend. Two values wrapped in the same constructor (both Recommend or both Commit) are combined according to the underlying Semigroup instance.

Methods

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

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

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

(Semigroup a, Monoid a) => Monoid (Recommend a) Source # 

getRecommend :: Recommend a -> a Source #

Extract the value of type a wrapped in Recommend a.