[Haskell-cafe] Help understanding type error

Ryan Ingram ryani.spam at gmail.com
Fri Sep 7 14:47:45 EDT 2007

This does what you want, I think:

{-# LANGUAGE ExistentialQuantification #-}
module Exist where

data Showable = forall a. (Show a) => Showable a
instance Show Showable where
   showsPrec p (Showable a) = showsPrec p a
   show (Showable a) = show a
   -- You have to use the default implementation of showList
   -- because a list could be heterogeneous

data T a = forall b. (Show b) => T b a

extShow :: T a -> Showable
extShow (T b _) = Showable b

  -- ryan

More information about the Haskell-Cafe mailing list