| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Data.Monoid.LCM
Description
This module defines the LCMMonoid subclass of the Monoid class.
The LCMMonoid subclass adds the lcm operation, which takes two monoidal
arguments and finds their least common multiple, or (more generally) the
least monoid from which either argument can be subtracted with the </>
operation.
For LCM monoids that are distributive, this module also provides the
DistributiveLCMMonoid subclass of LCMMonoid.
All classes in this module are for Abelian, i.e., Commutative monoids.
Synopsis
- class GCDMonoid m => LCMMonoid m where
- lcm :: m -> m -> m
- class (DistributiveGCDMonoid m, LCMMonoid m) => DistributiveLCMMonoid m
Documentation
class GCDMonoid m => LCMMonoid m where Source #
Class of Abelian monoids that allow the least common multiple to be found for any two given values.
Operations must satisfy the following laws:
Reductivity
isJust(lcma b</>a)
isJust(lcma b</>b)
Uniqueness
allisJust[ c</>a , c</>b ,lcma b</>c ] ==> (lcma b==c)
Idempotence
lcma a==a
Identity
lcmmemptya==a
lcmamempty==a
Commutativity
lcma b==lcmb a
Associativity
lcm(lcma b) c==lcma (lcmb c)
Absorption
lcma (gcda b)==a
gcda (lcma b)==a
Instances
| LCMMonoid IntSet Source # | |
| LCMMonoid () Source # | |
Defined in Data.Monoid.LCM | |
| LCMMonoid a => LCMMonoid (Dual a) Source # | |
| LCMMonoid (Product Natural) Source # | |
| LCMMonoid (Sum Natural) Source # | |
| Ord a => LCMMonoid (Set a) Source # | |
| (LCMMonoid a, LCMMonoid b) => LCMMonoid (a, b) Source # | |
Defined in Data.Monoid.LCM | |
| (LCMMonoid a, LCMMonoid b, LCMMonoid c) => LCMMonoid (a, b, c) Source # | |
Defined in Data.Monoid.LCM | |
| (LCMMonoid a, LCMMonoid b, LCMMonoid c, LCMMonoid d) => LCMMonoid (a, b, c, d) Source # | |
Defined in Data.Monoid.LCM | |
class (DistributiveGCDMonoid m, LCMMonoid m) => DistributiveLCMMonoid m Source #
Class of commutative LCM monoids with distributivity.
In addition to the general LCMMonoid laws, instances of this class
must also satisfy the following laws:
The lcm operation itself must be both left-distributive and
right-distributive:
lcm(a<>b) (a<>c)==a<>lcmb c
lcm(a<>c) (b<>c)==lcma b<>c
The lcm and gcd operations must distribute over one another:
lcma (gcdb c)==gcd(lcma b) (lcma c)
gcda (lcmb c)==lcm(gcda b) (gcda c)
Instances
| DistributiveLCMMonoid IntSet Source # | |
Defined in Data.Monoid.LCM | |
| DistributiveLCMMonoid () Source # | |
Defined in Data.Monoid.LCM | |
| DistributiveLCMMonoid a => DistributiveLCMMonoid (Dual a) Source # | |
Defined in Data.Monoid.LCM | |
| DistributiveLCMMonoid (Product Natural) Source # | |
Defined in Data.Monoid.LCM | |
| DistributiveLCMMonoid (Sum Natural) Source # | |
Defined in Data.Monoid.LCM | |
| Ord a => DistributiveLCMMonoid (Set a) Source # | |
Defined in Data.Monoid.LCM | |