Last active
August 29, 2015 14:21
-
-
Save dzackgarza/80b8c3eb17afbb945ae0 to your computer and use it in GitHub Desktop.
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
class CustomClass a where | |
add :: a -> a -> a | |
mul :: a -> a -> a | |
newtype ZModZ7 = ZModZ7 Integer deriving (Eq, Show) | |
instance CustomClass ZModZ7 where | |
add a b = mod (a + b) 7 -- Here, 'a' matches an entire (ZModZ7 i), and mod won't function on the custom type. | |
mul a b = mod (a * b) 7 -- Based on discussion with monochrom@Freenode, equivalent to | |
-- = mod ( (ZModZ7 a') * (ZModZ7 b') ) | |
-- Note that the values of a and b are still boxed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment