If m is a Monoid, then Deletable m (intuitively speaking)
adds two distinguished new elements [ and ], such that an
occurrence of [ "deletes" everything from it to the next ]. For
example,
abc[def]gh == abcghThis is all you really need to know to use Deletable m
values; to understand the actual implementation, read on.
To properly deal with nesting and associativity we need to be
able to assign meanings to things like [[, ][, and so on. (We
cannot just define, say, [[ == [, since then ([[)] == [] ==
id but [([]) == [id == [.) Formally, elements of Deletable
m are triples of the form (r, m, l) representing words ]^r m
[^l. When combining two triples (r1, m1, l1) and (r2, m2, l2)
there are three cases:
If l1 == r2 then the [s from the left and ]s from the right exactly cancel, and we are left with (r1, m1 <> m2, l2).
If l1 < r2 then all of the [s cancel with some of the ]s, but m1 is still inside the remaining ]s and is deleted, yielding (r1 + r2 - l1, m2, l2)
The remaining case is symmetric with the second.
Instances8Functor, Foldable, Traversable, Data, Read, Show, …
Functor DeletableDefined in monoid-extras-0.6.2 · Data.Monoid.DeletableFoldable DeletableDefined in monoid-extras-0.6.2 · Data.Monoid.DeletableTraversable DeletableDefined in monoid-extras-0.6.2 · Data.Monoid.DeletableData m => Data (Deletable m)Defined in monoid-extras-0.6.2 · Data.Monoid.DeletableRead m => Read (Deletable m)Defined in monoid-extras-0.6.2 · Data.Monoid.DeletableShow m => Show (Deletable m)Defined in monoid-extras-0.6.2 · Data.Monoid.DeletableSemigroup m => Semigroup (Deletable m)Defined in monoid-extras-0.6.2 · Data.Monoid.Deletable(Semigroup m, Monoid m) => Monoid (Deletable m)Defined in monoid-extras-0.6.2 · Data.Monoid.Deletable