Last active
September 3, 2015 00:32
-
-
Save jkarni/8d24a13b4be4cbbb1373 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 #-} | |
module Main where | |
import Data.Constraint | |
show' :: (Maybe (Dict (Show a))) -> a -> String | |
show' (Just Dict) x = show x | |
show' Nothing _ = "<<not showable>>" | |
t1 = show' (Just Dict) 5 | |
-- "5" | |
t2 = show' Nothing id | |
-- "<<not showable>>" | |
-- Doesn't typecheck | |
-- t3 = show' (Just Dict) id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment