Skip to content

Instantly share code, notes, and snippets.

@dasch
Last active October 28, 2017 22:09
Show Gist options
  • Save dasch/18e77c22f08a12778d12960dd456fb45 to your computer and use it in GitHub Desktop.
Save dasch/18e77c22f08a12778d12960dd456fb45 to your computer and use it in GitHub Desktop.
type Product = Product Integer
instance Monoid Product where
empty : Product
empty = Product 1
add : Product -> Product -> Product
add (Product x) (Product y) = Product (x * y)
instance (Monoid a, Monoid b) => Monoid (a, b) where
empty : (a, b)
empty = (empty, empty)
add : (a, b) -> (a, b) -> (a, b)
add (x1, x2) (y1, y2) = (add x1 y1, add x2 y2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment