Last active
June 26, 2016 19:41
-
-
Save berdario/2bf439e3ac9ba2ecd3f8031a1a27ca53 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
import Data.Exists | |
data Showable_ a = Showable_ a | |
data Showable = Showable (Exists Showable_) | |
instance showable_ :: (Show a) => Show (Showable_ a) where | |
show (Showable_ x) = show x | |
instance showable :: (Show (Showable_ a)) => Show Showable where | |
show (Showable v) = runExists show' v | |
where | |
show' :: forall a. (Show a) => Showable_ a -> String | |
show' x = show x | |
showable :: forall a. (Show a) => a -> Showable | |
showable = Showable <<< mkExists <<< Showable_ | |
[showable 1, showable "2"] | |
-- The `Show Showable` will result in the following error: | |
-- No type class instance was found for | |
-- Prelude.Show a0 | |
-- in value declaration showable | |
-- where a0 is a rigid type variable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment