| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
NumHask.Algebra.Bimonoid
Description
Bimonoid structure at the value level.
In linear logic the exponentials !A and ?A license the structural
rules of contractionweakening and cocontractioncoweakening. These are
not properties of the value itself in isolation; they are algebraic
structure on how values may be used. Because functions are first-class,
that structure can be made explicit as type classes.
Copyableis the!fragment: values may be duplicated and discarded.Mergeableis the?fragment: values may be combined with a unit.
For the function arrow (->) the cartesian structure gives a canonical
Copyable instance, while Mergeable is pointwise whenever the codomain
is mergeable.
Documentation
class Copyable a where Source #
A cocommutative comonoid in the category of Haskell functions.
This is the value-level content of the linear-logic exponential !A:
the value may be copied (contraction) and discarded (weakening).
class Mergeable a where Source #
A commutative monoid in the category of Haskell functions.
This is the value-level content of the linear-logic exponential ?A:
values may be merged (cocontraction) and introduced from nothing
(coweakening).
Methods
Combine two values.
The unit value, introduced from the terminal object ().
Instances
| Mergeable () Source # | Unit merges trivially. |
| Mergeable Bool Source # | Booleans merge by disjunction. |
| Additive a => Mergeable a Source # | Numeric types merge by addition. This generic instance covers every |
| Ord a => Mergeable (Set a) Source # | Sets merge by union. |
| Mergeable b => Mergeable (a -> b) Source # | Function merging is pointwise. |