Antoine Latter wrote:
It should be pretty easy to write an adapter function of type "String ->
(Show a => a)".

The type needs to be

   String -> (exists a. Show a => a)

which is equivalent to

   String -> (forall a. Show a => a -> c) -> c


Here is the implementation of the adapter

   newtype ExistsShow = E { showE :: String }
   instance Show ExistsShow where
       show = showE

   withShow :: String -> (forall a. Show a => a -> c) -> c
   withShow s f = f (E s)

Essentially, the point is that the types are equivalent

   ExistsShow  ==  exists a. Show a => a


Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to