Skip to content

Instantly share code, notes, and snippets.

@josejuan
Created January 22, 2018 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josejuan/f5e2c9761e3d58094fd1ca20c0790b31 to your computer and use it in GitHub Desktop.
Save josejuan/f5e2c9761e3d58094fd1ca20c0790b31 to your computer and use it in GitHub Desktop.
> :set -XGeneralizedNewtypeDeriving
> instance (Num a, Num b) => Num (a, b) where (a, b) + (c, d) = (a+c,b+d)
> newtype Z = Z (Int, Int) deriving (Eq, Ord, Show, Num)
> Z (3, 4) + Z (5, 6)
Z (8,10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment