Last active
September 3, 2015 05:05
-
-
Save jkarni/0872c83bc4264a23fec1 to your computer and use it in GitHub Desktop.
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 ConstraintKinds #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# OPTIONS_GHC -fdefer-type-errors #-} | |
module Main where | |
import Data.Constraint | |
import Control.Exception | |
import System.IO.Unsafe | |
show' y = unsafePerformIO $ do | |
res <- try $ evaluate $ show'' Dict y | |
case res of | |
Right x -> return x | |
Left (ErrorCall _) -> return "no show" | |
show'' :: (Dict (Show a)) -> a -> String | |
show'' Dict x = show x | |
t1 = show' 5 | |
-- "5" | |
t2 = show' id | |
-- "no show" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment