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.Cut

Description

The `Cut` monoid transformer introduces "cut points" such that all values between any two cut points are thrown away. That is,

    a b c | d e | f g h i | j k  ==  a b c | j k

Synopsis

- data Cut m
  - = Uncut m
  - | m :||: m
- cut :: Monoid m => Cut m

# Documentation

data Cut m Source #

A value of type `Cut m` is either a single `m`, or a pair of `m`'s separated by a divider. The divider represents a "cut point".

`Cut` is similar to Data.Monoid.Split, but split keeps only the rightmost divider and accumulates all values, whereas cut always keeps the leftmost and rightmost divider, coalescing them into one and throwing away all the information in between.

`Split` uses the asymmetric constructor `:|`, and `Cut` the symmetric constructor `:||:`, to emphasize the inherent asymmetry of `Split` and symmetry of `Cut`. `Split` keeps only the rightmost split and combines everything on the left; `Cut` keeps the outermost splits and throws away everything in between.

Constructors

Uncut m |
m :||: m infix 5 |

#### Instances

Instances details

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

Instance details

Defined in Data.Monoid.Cut

Methods

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

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

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

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

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

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

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

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

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

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

null :: Cut a -> Bool Source #

length :: Cut a -> Int Source #

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

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

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

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

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

Traversable Cut Source # |
Instance details Defined in Data.Monoid.Cut Methods traverse :: Applicative f => (a -> f b) -> Cut a -> f (Cut b) Source # sequenceA :: Applicative f => Cut (f a) -> f (Cut a) Source # mapM :: Monad m => (a -> m b) -> Cut a -> m (Cut b) Source # sequence :: Monad m => Cut (m a) -> m (Cut a) Source #
(Semigroup m, Monoid m) => Monoid (Cut m) Source # |
Instance details Defined in Data.Monoid.Cut Methods mempty :: Cut m Source # mappend :: Cut m -> Cut m -> Cut m Source # mconcat :: [Cut m] -> Cut m Source #

Semigroup m => Semigroup (Cut m) Source #

If `m` is a `Semigroup`, then `Cut m` is a semigroup which contains `m` as a sub-semigroup, but also contains elements of the form `m1 :||: m2`. When elements of `m` combine with such "cut" elements they are combined with the value on the corresponding side of the cut (e.g. `(Uncut m1) <> (m1' :||: m2) = (m1 <> m1') :||: m2`). When two "cut" elements meet, the two inside values are thrown away and only the outside values are kept.

Instance details Defined in Data.Monoid.Cut Methods (<>) :: Cut m -> Cut m -> Cut m Source # sconcat :: NonEmpty (Cut m) -> Cut m Source # stimes :: Integral b => b -> Cut m -> Cut m Source #
Data m => Data (Cut m) Source # |

Instance details

Defined in Data.Monoid.Cut

Methods

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

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

toConstr :: Cut m -> Constr Source #

dataTypeOf :: Cut m -> DataType Source #

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

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

gmapT :: (forall b. Data b => b -> b) -> Cut m -> Cut m Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Cut m -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Cut m -> r Source #

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

gmapQi :: Int -> (forall d. Data d => d -> u) -> Cut m -> u Source #

gmapM :: Monad m0 => (forall d. Data d => d -> m0 d) -> Cut m -> m0 (Cut m) Source #

gmapMp :: MonadPlus m0 => (forall d. Data d => d -> m0 d) -> Cut m -> m0 (Cut m) Source #

gmapMo :: MonadPlus m0 => (forall d. Data d => d -> m0 d) -> Cut m -> m0 (Cut m) Source #

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

cut :: Monoid m => Cut m Source #

A convenient name for `mempty :||: mempty`, so composing with `cut` introduces a cut point. For example, `Uncut a <> cut <> Uncut b == a :||: b`.