[Haskell-cafe] What does the `forall` mean ?
z_axis at 163.com
Thu Nov 12 02:37:39 EST 2009
Without `forall`, the ghci will complain: "Not in scope: type variable `b' "
It is clear now. thank you!
Dan Piponi-2 wrote:
> On Wed, Nov 11, 2009 at 4:24 PM, zaxis <z_axis at 163.com> wrote:
>> data Branch tok st a = forall b. Branch (PermParser tok st (b -> a))
>> (GenParser tok st b)
>> I have hoogled the `forall` but i cannot find any appropriate answer!
> That's an example of an existential type. What that line is saying is
> that for any type b (ie. for all b) that you could pick, the
> constructor called 'Branch' can take something of type 'PermParser tok
> st (b -> a)' and something of type 'GenParser tok st b' and make
> something of type 'Branch tok st a' out of it.
> The reason it's called an existential type is something like this:
> once you've constructed your thing of type 'Branch tok st a' you've
> lost the information about what the type b was. So all you know is
> that inside your thing is a pair of objects of type 'PermParser tok st
> (b -> a)' and 'GenParser tok st b' but you don't know what b is. All
> you know is that there exists some type 'b' that it was made of.
> To use these types with ghc you need to use the compilation flag
> There's more to be found here:
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
fac n = foldr (*) 1 [1..n]
View this message in context: http://old.nabble.com/What-does-the-%60forall%60-mean---tp26311291p26314602.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
More information about the Haskell-Cafe