[Haskell-cafe] Re: Re[2]: what is a difference between existential quantification and polymorhic field?

Benjamin Franksen benjamin.franksen at bessy.de
Thu Sep 21 15:34:14 EDT 2006


Bulat Ziganshin wrote:
> Hello Ross,
> Thursday, September 21, 2006, 12:55:40 PM, you wrote:
>>> data Ex = forall a. Num a =>  Ex a
>>> 
>>> and
>>> 
>>> data Po = Po (forall a. Num a => a)
> 
>> Consider the types of the constructors:
> 
>> Ex :: forall a. (Num a) => a -> Ex
>> Po :: (forall a. (Num a) => a) -> Po
> 
> sorry, Ross, can you give me a more detailed explanation? it seems
> that Po argument is existential by itself, 

The Po argument is a polymorphic function, not an existential.

As I understand it, the constructor Ex _is_ a polymorphic function, whereas
the constructor Po (only) _takes_as_argument_ a polymorphic function. In
the latter case you store a polymorphic function inside your data, whereas
in the former case you construct (monomorphic) data in a polymorphic way,
which means that during the process you loose the concrete type of the
argument.

Ben



More information about the Haskell-Cafe mailing list