[Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

Niemeijer, R.A. r.a.niemeijer at tue.nl
Sun Apr 19 17:46:48 EDT 2009

If only it were that easy. Sadly, it's not. Let's look at the following example:

data Test = Test { foo :: Int, bar :: Char, baz :: Bool }

smallPrint t = concatMap (\f -> show $ f t) [foo, bar, baz]

In this code the list [foo, bar, baz] should have the type [exists a. Show a => Test -> a].
If we explicitly specify the type, replacing the exists with a forall, then GHC complains about not being able to match Int, Char and Bool against type a.

Forall is not the same as exists and GHC only implements the former.
From: Bulat Ziganshin [bulat.ziganshin at gmail.com]
Sent: 19 April 2009 22:07
To: Niemeijer, R.A.
Cc: haskell-cafe at haskell.org
Subject: Re[2]: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

Hello R.A.,

Sunday, April 19, 2009, 11:46:53 PM, you wrote:

> Does anybody know if there are any plans to incorporate some of
> these extensions into GHC - specifically the existential typing ?

it is already here, but you should use "forall" keyword instead odf

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list