Skip to content

Instantly share code, notes, and snippets.

@jkarni
Last active September 3, 2015 05:05
Show Gist options
  • Save jkarni/0872c83bc4264a23fec1 to your computer and use it in GitHub Desktop.
Save jkarni/0872c83bc4264a23fec1 to your computer and use it in GitHub Desktop.
{-# 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