{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE DatatypeContexts #-} -- | These algebraic structures have sacrificed generality in favor of being easily used with the standard Haskell Prelude. The fact that monoids are not guaranteed to be semigroups makes this difficult. module HLearn.Algebra.Structures.Groups ( -- * Type classes RegularSemigroup (..) , Group(..) , Abelian (..) , module Data.Semigroup ) where import Control.DeepSeq import Data.Semigroup import GHC.Exts (Constraint) ------------------------------------------------------------------------------- -- class (c a) => Abelian (a :: *) (c :: * -> Constraint) where -- op :: a -> a -> a class (Semigroup sg) => Abelian sg ------------------------------------------------------------------------------- -- Inverses -- | Semigroups that also have an inverse. See class (Semigroup g) => RegularSemigroup g where inverse :: g -> g -- -- | Semigroups where a unique inverse exists for each element. See -- class (RegularSemigroup g) => InverseSemigroup g -- | Regular semigroups that also have an identity; alternatively, monoids where every element has a unique inverse. See class (RegularSemigroup g, Monoid g) => Group g instance (RegularSemigroup g, Monoid g) => Group g