HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulecommutative-semigroups-0.2.0.1Haskell2010

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