Skip to content

Instantly share code, notes, and snippets.

@berdario berdario/existential.purs
Last active Jun 26, 2016

Embed
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
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
You can’t perform that action at this time.