Last active
June 11, 2018 13:20
-
-
Save andrewthad/53c6de3f2937eba51518341466d1418a to your computer and use it in GitHub Desktop.
Typeclass dictionary equality test
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
{-# language BangPatterns #-} | |
{-# language UnboxedTuples #-} | |
{-# language TypeInType #-} | |
{-# language GeneralizedNewtypeDeriving #-} | |
{-# language TypeApplications #-} | |
{-# language MagicHash #-} | |
import Data.Primitive | |
import GHC.Exts | |
import Data.Int | |
main :: IO () | |
main = do | |
putStrLn "Beginning" | |
let !x = (readByteArray# @Foo) | |
let !y = (unsafeCoerce# (readByteArray# @Bar)) | |
case reallyUnsafePtrEquality# x y of | |
1# -> putStrLn "Equal" | |
_ -> putStrLn "Not Equal" | |
putStrLn "Finished" | |
newtype Foo = Foo Int8 | |
deriving (Prim) | |
newtype Bar = Bar Int8 | |
deriving (Prim) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment