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

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Modulecommutative-semigroups-0.2.0.2Haskell2010

Numeric.Product.Commutative

  • 1 class
classclass Num a => CommutativeProduct a
#

Subclass of Num where (*) is commutative.

Num doesn't demand commutative (*), and there are reasonable "real-world" instances with non-commutative multiplication. There is also no canonical subclass in base that would suffice, as both Integral and Floating imply commutative (*) for different reasons.

Two examples of non-commutative (*):

  • Linear.Quaternion.Quaterion from the linear package has a Num instance, and quaternion multiplication is noncommutative.

  • Data.Matrix.Matrix from the matrix package uses (*) for matrix multiplication, which is also non-commutative (on square matrices, which is the only time the question makes sense).

Instances26CommutativeProduct, …