HORIZON HASKELLDocslts/ghc-9.14.x45dd5372026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 45dd537 · 2026-10-11

Modulevortex-journal-0.1.0GHC2024

Vortex.Journal.Marking

A marking: a finite multiset of resource tokens. Markings are the linear part of a journal: a token is never copied or dropped, only consumed by one operation and produced by another, so the multiset operations here are the whole of the arithmetic a state is allowed.

  • 1 type
  • 15 values
newtypenewtype Marking tok
#

A multiset of tokens. The invariant, kept by every function here, is that no token is held with a count of zero, so two markings with the same tokens are equal as values.

Instances5Eq, Ord, Show, Semigroup, Monoid
  • Eq tok => Eq (Marking tok)Defined in vortex-journal-0.1.0 · Vortex.Journal.Marking
  • Ord tok => Ord (Marking tok)Defined in vortex-journal-0.1.0 · Vortex.Journal.Marking
  • Show tok => Show (Marking tok)Defined in vortex-journal-0.1.0 · Vortex.Journal.Marking
  • Ord tok => Semigroup (Marking tok)Defined in vortex-journal-0.1.0 · Vortex.Journal.Marking
  • Ord tok => Monoid (Marking tok)Defined in vortex-journal-0.1.0 · Vortex.Journal.Marking
valuetokens :: Ord tok => [tok] -> Marking tok
#

The marking holding each listed token once per mention.

valuefromCounts :: Ord tok => [(tok, Natural)] -> Marking tok
#

The marking holding each token as many times as the counts say, summed over repeats.

valueminus :: Ord tok => Marking tok -> Marking tok -> Marking tok
#

Multiset difference, truncated at zero. Where contains m n holds it is exact: plus (minus m n) n == m.

valuetoList :: Marking tok -> [tok]
#

Every token, repeated by its count, in token order.

valuebind :: Ord tok' => (tok -> Marking tok') -> Marking tok -> Marking tok'
#

The monoid homomorphism a map on tokens extends to: each token is replaced by its image, counts multiplying. Markings are the free commutative monoid on tokens, so every homomorphism is one of these.