-
-
Save aavogt/8e6a32595087ec9ed30de5b7226bb0df to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE OverlappingInstances #-} | |
| {-# LANGUAGE GADTs #-} | |
| module A where | |
| a0 :: EqBox A | |
| a0 = EqBox A | |
| data EqBox a where EqBox :: Eq a => a -> EqBox a | |
| data A = A | |
| instance Eq a where | |
| (==) _ _ = False |
This file contains hidden or 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
| import A | |
| instance Eq A where | |
| (==) _ _ = True | |
| a1 :: EqBox A | |
| a1 = EqBox A | |
| f :: EqBox a -> EqBox a -> Bool | |
| f (EqBox a) (EqBox b) = a == b | |
| main = do | |
| print $ f a0 a1 | |
| print $ f a1 a0 | |
| -- main prints True\nFalse, saying that the Eq dictionary from the second argument is used |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment