HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulemonoid-extras-0.6.2Haskell2010

Data.Monoid.Cut

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
  • 1 type
  • 1 value
datadata Cut m
#

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

Instances8Functor, Foldable, Traversable, Data, Read, Show, …
  • Functor CutDefined in monoid-extras-0.6.2 · Data.Monoid.Cut
  • Foldable CutDefined in monoid-extras-0.6.2 · Data.Monoid.Cut
  • Traversable CutDefined in monoid-extras-0.6.2 · Data.Monoid.Cut
  • Data m => Data (Cut m)Defined in monoid-extras-0.6.2 · Data.Monoid.Cut
  • Read m => Read (Cut m)Defined in monoid-extras-0.6.2 · Data.Monoid.Cut
  • Show m => Show (Cut m)Defined in monoid-extras-0.6.2 · Data.Monoid.Cut
  • Semigroup m => Semigroup (Cut m)Defined in monoid-extras-0.6.2 · Data.Monoid.Cut

    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.

  • (Semigroup m, Monoid m) => Monoid (Cut m)Defined in monoid-extras-0.6.2 · Data.Monoid.Cut
valuecut :: Monoid m => Cut m
#

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