module Data.Group
    ( module Data.Loop
    , module Data.Monoid
    , Group (..)
    ) where

import Control.Applicative
import Data.Loop
import Data.Monoid (Monoid, Semigroup)

-- | A 'Group' is a set with an invertible, associative binary
--   operation and an identity element. If you specialize 'negate',
--   @negate x = invl x = invr x@ must hold.
class (Loop g, Monoid g) => Group g where
    recip :: g -> g
    recip = invr

instance Group b => Group (a -> b) where
    recip = map recip
