Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
群 in Haskell
import Data.Monoid
class Group g where
gidentity :: g
gop :: g -> g -> g
ginverse :: g -> g
instance Num a => Group (Sum a) where
gidentity = Sum 0
(Sum x) `gop` (Sum y) = Sum (x + y)
ginverse (Sum a) = Sum (negate a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.