[Haskell-cafe] What does the `forall` mean ?

2009-11-11 Thread zaxis
import Text.ParserCombinators.Parsec data PermParser tok st a = Perm (Maybe a) [Branch tok st a] 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! thanks! - fac n = foldr (*)

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-11 Thread Joe Fredette
Forall means the same thing as it means in math, it means "for any type -- call it `b` -- then the type of the following it `Branch (PermParser tok st (b -> a)`" `tok`, `st` and `a` are all given by the declaration of the datatype itself. Hope that makes sense, /Joe On Nov 11, 2009, at

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-11 Thread Dan Piponi
On Wed, Nov 11, 2009 at 4:24 PM, zaxis 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

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-11 Thread zaxis
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 wrote: >> data Branch tok st a     = forall b. Branch (PermParser tok st (b -> a)) >> (GenParser tok st b) >> >> I have hoogle

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-12 Thread Andrew Coppin
Dan Piponi wrote: To use these types with ghc you need to use the compilation flag -XExistentialQuantification. Or, more portably, add {-# LANGUAGE ExistentialQuantification #-} at the top of the source file. It should now compile in any computer that supports this feature without any spec

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-12 Thread Andrew Coppin
Joe Fredette wrote: Forall means the same thing as it means in math ...which not everybody already knows about. ;-) Even I am still not 100% sure how placing forall in different positions does different things. But usually it's not something I need to worry about. :-) _

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-12 Thread Eugene Kirpichov
2009/11/12 Andrew Coppin : > Joe Fredette wrote: >> >> Forall means the same thing as it means in math > > ...which not everybody already knows about. ;-) > > Even I am still not 100% sure how placing forall in different positions does > different things. But usually it's not something I need to wo

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-12 Thread Neil Brown
Eugene Kirpichov wrote: 2009/11/12 Andrew Coppin : Even I am still not 100% sure how placing forall in different positions does different things. But usually it's not something I need to worry about. :-) To me it does not look like it does different things: everywhere it denotes univer

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-12 Thread Eugene Kirpichov
2009/11/12 Neil Brown : > Eugene Kirpichov wrote: >> >> 2009/11/12 Andrew Coppin : >> >>> >>> Even I am still not 100% sure how placing forall in different positions >>> does >>> different things. But usually it's not something I need to worry about. >>> :-) >>> >> >> To me it does not look like it

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-12 Thread Ryan Ingram
On Thu, Nov 12, 2009 at 2:50 AM, Eugene Kirpichov wrote: > But that's not an issue of semantics of forall, just of which part of > the rather broad and universal semantics is captured by which language > extensions. The forall for existential type quantification is wierd. > data Top = forall a.

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-12 Thread Andrew Coppin
Eugene Kirpichov wrote: 2009/11/12 Andrew Coppin : Joe Fredette wrote: Forall means the same thing as it means in math ...which not everybody already knows about. ;-) Even I am still not 100% sure how placing forall in different positions does different things. But usually it's

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-12 Thread Eugene Kirpichov
2009/11/12 Ryan Ingram : > On Thu, Nov 12, 2009 at 2:50 AM, Eugene Kirpichov > wrote: >> But that's not an issue of semantics of forall, just of which part of >> the rather broad and universal semantics is captured by which language >> extensions. > > The forall for existential type quantificatio

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-12 Thread David Virebayre
On Thu, Nov 12, 2009 at 8:52 PM, Andrew Coppin wrote: > I just meant it's not immediately clear how >  foo :: forall x. (x -> x -> y) > is different from > foo :: (forall x. x -> x) -> y > It takes a bit of getting used to. That still confuses me.

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-12 Thread Andrew Coppin
David Virebayre wrote: On Thu, Nov 12, 2009 at 8:52 PM, Andrew Coppin wrote: I just meant it's not immediately clear how foo :: forall x. (x -> x -> y) is different from foo :: (forall x. x -> x) -> y It takes a bit of getting used to. Tha

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-12 Thread Steffen Schuldenzucker
Andrew Coppin wrote: > > I just meant it's not immediately clear how > > foo :: forall x. (x -> x -> y) > > is different from > > foo :: (forall x. x -> x) -> y Uhm, I guess you meant foo :: forall x. ((x -> x) -> y) VS. foo :: (forall x. x -> x) -> y , didn't you? __

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-12 Thread Sean Leather
> I just meant it's not immediately clear how > > foo :: forall x. (x -> x -> y) > > is different from > > foo :: (forall x. x -> x) -> y > > It takes a bit of getting used to. Those are different functions all together, so perhaps you meant these. foo :: forall x y. (x -> x) -> y bar :: fo

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-14 Thread Mark Lentczner
On Nov 12, 2009, at 2:59 PM, Sean Leather wrote: > foo :: forall x y. (x -> x) -> y > bar :: forall y. (forall x . x -> x) -> y > > While neither function is seemingly useful, the second says that the > higher-order argument must be polymorphic. I see two options: AHA! This is the bit of ins

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-14 Thread Lennart Augustsson
Of the two declarations >data Fizzle a = Fizzle (b -> (a, b)) a >data Fizzle a = forall b. Fizzle (b -> (a, b)) a only the second one is allowed (with some suitable extension). Personally I think the first one should be allowed as well, with the same meaning as the second one. Some

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-14 Thread Felipe Lessa
On Sun, Nov 15, 2009 at 01:14:34AM +, Lennart Augustsson wrote: > Of the two declarations > >data Fizzle a = Fizzle (b -> (a, b)) a > >data Fizzle a = forall b. Fizzle (b -> (a, b)) a > only the second one is allowed (with some suitable extension). > > Personally I think the fir

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-15 Thread Sean Leather
On Sat, Nov 14, 2009 at 17:55, Mark Lentczner wrote: > Would I be correct in thinking: The difference between these two is that > the type b can be "fixed" upon application of amy to the first two arguments > (given context), whereas bob applied to two arguments MUST return a function > that is ap

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-15 Thread wren ng thornton
Mark Lentczner wrote: I also think I understand that the implicit 'forall' inherent in Haskell falls at different places in various constructs, which also had me confused. For example, while the above two function type declarations are equivalent, these two data declarations aren't: d