Created
June 5, 2015 10:12
-
-
Save takoeight0821/8d8d7603667dc8a2cf5d to your computer and use it in GitHub Desktop.
群 in Haskell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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