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

Copyright | (c) 2012-2015 diagrams-core team (see LICENSE)
License | BSD-style (see LICENSE)
Maintainer | diagrams-discuss@googlegroups.com
Safe Haskell | Safe-Inferred
Language | Haskell2010

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 "commitment" (to certainly be used, overriding merely recommended values), along with corresponding `Semigroup` and `Monoid` instances.

Synopsis

- data Recommend a
  - = Recommend a
  - | Commit a
- getRecommend :: Recommend a -> a

# 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 `Recommend`ed values.

Constructors

Recommend a |
Commit a |

#### Instances

Instances details

Functor Recommend Source # |
Instance details Defined in Data.Monoid.Recommend Methods fmap :: (a -> b) -> Recommend a -> Recommend b Source # (<$) :: a -> Recommend b -> Recommend a Source #
Foldable Recommend Source # |

Instance details

Defined in Data.Monoid.Recommend

Methods

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

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

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

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

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

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

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

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

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

toList :: Recommend a -> [a] Source #

null :: Recommend a -> Bool Source #

length :: Recommend a -> Int Source #

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

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

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

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

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

Traversable Recommend Source # |
Instance details Defined in Data.Monoid.Recommend Methods traverse :: Applicative f => (a -> f b) -> Recommend a -> f (Recommend b) Source # sequenceA :: Applicative f => Recommend (f a) -> f (Recommend a) Source # mapM :: Monad m => (a -> m b) -> Recommend a -> m (Recommend b) Source # sequence :: Monad m => Recommend (m a) -> m (Recommend a) Source #
(Semigroup a, Monoid a) => Monoid (Recommend a) Source # |
Instance details Defined in Data.Monoid.Recommend Methods mempty :: Recommend a Source # mappend :: Recommend a -> Recommend a -> Recommend a Source # mconcat :: [Recommend a] -> 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.
Instance details Defined in Data.Monoid.Recommend Methods (<>) :: Recommend a -> Recommend a -> Recommend a Source # sconcat :: NonEmpty (Recommend a) -> Recommend a Source # stimes :: Integral b => b -> Recommend a -> Recommend a Source #
Data a => Data (Recommend a) Source # |

Instance details

Defined in Data.Monoid.Recommend

Methods

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

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

toConstr :: Recommend a -> Constr Source #

dataTypeOf :: Recommend a -> DataType Source #

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

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

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

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

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

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

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

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

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

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

Read a => Read (Recommend a) Source # |
Instance details Defined in Data.Monoid.Recommend Methods readsPrec :: Int -> ReadS (Recommend a) Source # readList :: ReadS [Recommend a] Source # readPrec :: ReadPrec (Recommend a) Source # readListPrec :: ReadPrec [Recommend a] Source #
Show a => Show (Recommend a) Source # |
Instance details Defined in Data.Monoid.Recommend Methods showsPrec :: Int -> Recommend a -> ShowS Source # show :: Recommend a -> String Source # showList :: [Recommend a] -> ShowS Source #
Eq a => Eq (Recommend a) Source # |
Instance details Defined in Data.Monoid.Recommend Methods (==) :: Recommend a -> Recommend a -> Bool Source # (/=) :: Recommend a -> Recommend a -> Bool Source #
Ord a => Ord (Recommend a) Source # |

Instance details

Defined in Data.Monoid.Recommend

Methods

compare :: Recommend a -> Recommend a -> Ordering Source #

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

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

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

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

max :: Recommend a -> Recommend a -> Recommend a Source #

min :: Recommend a -> Recommend a -> Recommend a Source #

getRecommend :: Recommend a -> a Source #

Extract the value of type `a` wrapped in `Recommend a`.