Implicit 'forall' in data declarations

David Menendez dave at zednenem.com
Mon Oct 25 04:21:59 EDT 2010


On Mon, Oct 25, 2010 at 3:16 AM, Simon Peyton-Jones
<simonpj at microsoft.com> wrote:
> | On a related note, these are also apparently allowed (in 6.10.4):
> |     f :: forall a. (Eq a => a -> a) -> a -> a
> |    -- the Eq context prevents the function from ever being called.
>
> That's not true.  E.g.
>        f ((==) True) True
> works fine.

What I meant is that f cannot call its argument. That is,

  f :: forall a. (Eq a => a -> a) -> a -> a
  f g x = g x

is ill-typed.

>
> |    g :: forall a. Ord a => (Eq a => a -> a) -> a -> a
> |    -- the Eq context is effectively ignored
>
> That's a bit more true, because Ord a implies Eq a, but still not really.  It still says
> that you must pass evidence for equality to g's argument.

Is that different from forall a. Ord a => (a -> a) -> a -> a?

-- 
Dave Menendez <dave at zednenem.com>
<http://www.eyrie.org/~zednenem/>


More information about the Glasgow-haskell-users mailing list