Created
December 18, 2018 00:41
-
-
Save harpocrates/10f8a9edaaf91cbe446bed0f6cd09da1 to your computer and use it in GitHub Desktop.
Constraint tuples aren't (always?) normalized
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 RankNTypes, ScopedTypeVariables, TypeApplications, ConstraintKinds #-} | |
| module Main where | |
| import Data.Constraint | |
| import Unsafe.Coerce | |
| newtype MyInt = MyInt Int | |
| instance Eq MyInt where { _ == _ = True } | |
| flip' :: forall a b. Dict (Eq a, Eq b) -> a -> a -> Bool | |
| flip' d x y = case unsafeCoerce d :: Dict (Eq b, Eq a) of | |
| Dict -> x == y | |
| main = print (flip' @Int @MyInt Dict 1 2) -- prints True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment