Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Attempting to recreate https://twitter.com/CodaFi_/status/905583919550132226 in Haskell without unsafeCoerce
{-# 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
You can’t perform that action at this time.