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

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, …