Last active
January 17, 2016 17:30
-
-
Save charles-cooper/2cea397ba24ecb017576 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
data Val a = Val Int deriving Show | |
instance Functor Val where | |
fmap _ (Val x) = Val x | |
coerce :: Val a -> Val b | |
coerce = fmap undefined | |
data Void | |
x :: Val Int | |
x = Val 1 | |
y :: Val Void | |
y = coerce x | |
-- Fails typechecking with: | |
-- Couldn't match type ‘Int’ with ‘Void’ | |
-- Expected type: Val Void | |
-- Actual type: Val Int | |
-- In the expression: x | |
-- In an equation for ‘z’: z = x | |
-- z :: Val Void | |
-- z = x | |
main = do | |
print x | |
print y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment