Created
September 7, 2017 00:50
-
-
Save cdparks/a80972481b28af99775adc15a492391e to your computer and use it in GitHub Desktop.
Attempting to recreate https://twitter.com/CodaFi_/status/905583919550132226 in Haskell without unsafeCoerce
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 GADTs #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
import Data.Typeable | |
import Control.Monad | |
import Control.Exception | |
import Prelude hiding (id) | |
-- Is it possible to do something like this without Typeable? | |
id :: forall a. Typeable a => a -> a | |
id x = | |
case eqT of | |
Just (Refl :: a :~: Int) -> 5 | |
Nothing -> x | |
expect :: Bool -> IO () | |
expect cond = void (evaluate (assert cond ())) | |
main :: IO () | |
main = do | |
expect $ id True == True | |
expect $ id @Int 1 == 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment