Skip to content

Instantly share code, notes, and snippets.

@harpocrates
Created December 18, 2018 00:41
Show Gist options
  • Select an option

  • Save harpocrates/10f8a9edaaf91cbe446bed0f6cd09da1 to your computer and use it in GitHub Desktop.

Select an option

Save harpocrates/10f8a9edaaf91cbe446bed0f6cd09da1 to your computer and use it in GitHub Desktop.
Constraint tuples aren't (always?) normalized
{-# 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