Skip to content

Instantly share code, notes, and snippets.

@nonowarn
Created July 11, 2010 04:50
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 nonowarn/471287 to your computer and use it in GitHub Desktop.
Save nonowarn/471287 to your computer and use it in GitHub Desktop.
instance Fractional Integer where
fromRational x = 0
instance Fractional Int where
fromRational x = 1
a :: Int
a = 0
b :: Fractional a => a
b = 0.0
c :: Int
c = 0
d :: Fractional a => a
d = 0.0
main = do
print $ a + c == 0 -- True.
print $ a == c -- True. a == c == 0.
print $ c == 0 -- True. Of course.
print $ a + d == 1 -- True. d == 1.
print $ b + c == 1 -- True. b == 1.
print $ b + d == 0 -- True. What happened?!
print $ b == d -- True. ?!
print $ d == 0 -- True. ?!?!
-- hints to make answer unique (perhaps...)
print $ sum [a, b, c] -- 1
print $ sum [a, b, d] -- 1
print $ [a, b, c] !! a -- 0
print $ [a, b, c] !! b -- 1
print $ [a, b, c] !! c -- 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment