| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Monoid.Diff.Internal
Documentation
The Difference Monoid.
Constructors
| !a :-: !a infixl 6 |
Instances
| Monad Diff Source # | |
| Functor Diff Source # | |
| MonadFix Diff Source # | |
| Applicative Diff Source # | |
| Foldable Diff Source # | |
| Traversable Diff Source # | |
| Distributive Diff Source # | |
| Representable Diff Source # | |
| Read1 Diff Source # | |
| Show1 Diff Source # | |
| MonadZip Diff Source # | |
| Comonad Diff Source # | |
| ComonadApply Diff Source # | |
| Traversable1 Diff Source # | |
| Foldable1 Diff Source # | |
| Apply Diff Source # | |
| Bind Diff Source # | |
| Extend Diff Source # | |
| Adjunction Parity Diff Source # | |
| Bounded a => Bounded (Diff a) Source # | |
| (Eq a, Semigroup a) => Eq (Diff a) Source # | |
| Data a => Data (Diff a) Source # | |
| (Ord a, Semigroup a) => Ord (Diff a) Source # | |
| Read a => Read (Diff a) Source # | |
| Show a => Show (Diff a) Source # | |
| Generic (Diff a) Source # | |
| Semigroup a => Semigroup (Diff a) Source # | |
| Monoid a => Monoid (Diff a) Source # | |
| NFData a => NFData (Diff a) Source # | |
| Monoid a => Group (Diff a) Source # | |
| Generic1 * Diff Source # | |
| type Rep Diff Source # | |
| type Rep (Diff a) Source # | |
| type Rep1 * Diff Source # | |
diff :: Monoid a => a -> Diff a Source #
Lift a monoid into the difference monoid.
>>>diff (Sum 1)Sum {getSum = 1} :-: Sum {getSum = 0}
foldDiff :: Group b => (a -> b) -> Diff a -> b Source #
A group homomorphism given a monoid homomorphism.
normalize :: (a -> a -> (a, a)) -> Diff a -> Diff a Source #
Given a "normalizing" function, try simplify the representation.
For instance, one such normalizing function may be to take the numeric difference of two types:
>>>let sumNorm x y = if x >= y then (x - y, 0) else (0, y - x)>>>normalize sumNorm ((foldMap (diff.Sum) [1..10]) <> (invert (foldMap (diff.Sum) [1..5])))Sum {getSum = 40} :-: Sum {getSum = 0}
runDiff :: (a -> a -> b) -> Diff a -> b Source #
Interpret the difference using a subtraction function.
Instances
| Monad Parity Source # | |
| Functor Parity Source # | |
| MonadFix Parity Source # | |
| Applicative Parity Source # | |
| Foldable Parity Source # | |
| Traversable Parity Source # | |
| Comonad Parity Source # | |
| ComonadApply Parity Source # | |
| Traversable1 Parity Source # | |
| Foldable1 Parity Source # | |
| Apply Parity Source # | |
| Bind Parity Source # | |
| Extend Parity Source # | |
| Adjunction Parity Diff Source # | |
| ComonadEnv Odd Parity Source # | |
| Bounded a => Bounded (Parity a) Source # | |
| Eq a => Eq (Parity a) Source # | |
| Ord a => Ord (Parity a) Source # | |
| Read a => Read (Parity a) Source # | |
| Show a => Show (Parity a) Source # | |
| Ix a => Ix (Parity a) Source # | |
| Semigroup a => Semigroup (Parity a) Source # | |
| Monoid a => Monoid (Parity a) Source # | |
| NFData a => NFData (Parity a) Source # | |
>>>import Data.Monoid hiding (diff, (<>))