AW: AW: simulating dynamic dispatch

2003-03-24 Thread Markus . Schnell
Thanks! These examples and counterexamples help a lot in understanding. Markus > The reason is that sum only works on integer lists, whereas the given > type for fun requires that the first argument be a function that works > on lists of any type, such as length. > If sum were allowed as argumen

Re: AW: simulating dynamic dispatch

2003-03-24 Thread Janis Voigtlaender
[EMAIL PROTECTED] wrote: > > I think I get it. But to be sure: > The forall means: The type for a may not be the same > throughout the whole function. It just has to follow > the pattern specified inside the braces. Not exactly. In: > > fun::(forall a.[a]->Int)->[b]->[c]->Int > > fun f x y = f x

Re: AW: simulating dynamic dispatch

2003-03-24 Thread Steffen Mazanek
> Interestingly, when I want hugs to show me the type > of > > fun::(forall a.[a]->Int)->[b]->[c]->Int > it tells me: ERROR - Use of fun requires at least 1 argument > Why that? At least I have explicitely specified the type. Hmm, ghci behaves properly. But using hugs I get the same error :-(. N

AW: simulating dynamic dispatch

2003-03-24 Thread Markus . Schnell
I think I get it. But to be sure: The forall means: The type for a may not be the same throughout the whole function. It just has to follow the pattern specified inside the braces. Interestingly, when I want hugs to show me the type of > fun::(forall a.[a]->Int)->[b]->[c]->Int it tells me: ERROR -

Re: AW: simulating dynamic dispatch

2003-03-24 Thread Steffen Mazanek
> concrete: What is the difference between > (forall b. Term b => b -> b) -> a -> a > and > (Term b) => (b -> b) -> a -> a > ? One may want: fun f x y = f x + f y for instance: fun length [True, False] [1,2] Therefore, I would say, you need typing a la fun::(forall a.[a]->Int)->[b]->[c]->

AW: simulating dynamic dispatch

2003-03-24 Thread Markus . Schnell
> http://research.microsoft.com/~simonpj/papers/hmap/ The technique you describe in that paper is exactly what I was wanting for many times. I often stopped using algebraic data types because of the immense amount of boilerplate I had to introduce. Thanks! But now I have a question regarding th