一个群扩展了幺半群的想法以允许逆。这允许:
gremove :: (Group a) => a -> a -> a
gremove x y = x `mappend` (invert y)
但是像自然数这样没有逆的结构呢?我在想:
class (Monoid a) => MRemove a where
mremove :: a -> a -> a
与法律:
x `mremove` x = mempty
x `mremove` mempty = x
(x `mappend` y) `mremove` y = x
另外:
class (MRemove a) => Group a where
invert :: a -> a
invert x = mempty `mremove` x
-- | For defining MRemove in terms of Group
defaultMRemove :: (Group a) => a -> a -> a
defaultMRemove x y = x `mappend` (invert y)
所以,我的问题是:什么是MRemove
?