Skip to content

Instantly share code, notes, and snippets.

@dzackgarza
Last active August 29, 2015 14:21
Show Gist options
  • Save dzackgarza/80b8c3eb17afbb945ae0 to your computer and use it in GitHub Desktop.
Save dzackgarza/80b8c3eb17afbb945ae0 to your computer and use it in GitHub Desktop.
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