Skip to content

Instantly share code, notes, and snippets.



Last active Jun 26, 2016
What would you like to do?
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
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