Re: [Haskell-cafe] What is the rank of a polymorphic type?

2009-12-06 Thread Dan Doel
Apologies for the double-reply... Your mail prompted me to finally get around to adding a mono/polytype system to an interpreter I've been working on for pure type systems, to see what a GHC-alike type system would look like. Here's what I came up with. Constants are: *m, []m, *p and []p

Re: [Haskell-cafe] What is the rank of a polymorphic type?

2009-12-06 Thread David Menendez
On Sun, Dec 6, 2009 at 8:39 AM, Dan Doel dan.d...@gmail.com wrote: Apologies for the double-reply... Your mail prompted me to finally get around to adding a mono/polytype system to an interpreter I've been working on for pure type systems, to see what a GHC-alike type system would look like.

[Haskell-cafe] What is the rank of a polymorphic type?

2009-12-05 Thread Eugene Kirpichov
Hello. Consider the type: (forall a . a) - String. On one hand, it is rank-2 polymorphic, because it abstracts over a rank-1 polymorphic type. On the other hand, it is monomorphic because it isn't actually quantified itself: in my intuitive view, a parametrically polymorphic type has infinitely

Re: [Haskell-cafe] What is the rank of a polymorphic type?

2009-12-05 Thread Martijn van Steenbergen
Eugene Kirpichov wrote: Hello. Consider the type: (forall a . a) - String. On one hand, it is rank-2 polymorphic, because it abstracts over a rank-1 polymorphic type. On the other hand, it is monomorphic because it isn't actually quantified itself: in my intuitive view, a parametrically

Re: [Haskell-cafe] What is the rank of a polymorphic type?

2009-12-05 Thread Stefan Holdermans
Eugene, Consider the type: (forall a . a) - String. It's of rank 2. What is the definition of rank of a polymorphic type? The minimal rank of a type is given by rank (forall a. t) = 1 `max` rank t rank (t - u) = (if rank t == 0 then 0 else rank t + 1) `max` rank u rank _

Re: [Haskell-cafe] What is the rank of a polymorphic type?

2009-12-05 Thread Eugene Kirpichov
2009/12/5 Stefan Holdermans ste...@cs.uu.nl: Eugene, Consider the type: (forall a . a) - String. It's of rank 2. What is the definition of rank of a polymorphic type? The minimal rank of a type is given by  rank (forall a. t) = 1 `max` rank t  rank (t - u)      = (if rank t == 0 then 0

Re: [Haskell-cafe] What is the rank of a polymorphic type?

2009-12-05 Thread Stefan Holdermans
Eugene, 1) Does there exist an authoritative source saying the same? Not that I'm doubting, just supposing that the source would have other interesting information, too :) You may want to have a look at the already mentioned JFP-article by Peyton Jones et al. and perhaps the work of Kfoury

Re: [Haskell-cafe] What is the rank of a polymorphic type?

2009-12-05 Thread Eugene Kirpichov
2009/12/6 Stefan Holdermans ste...@cs.uu.nl: Eugene, 1) Does there exist an authoritative source saying the same? Not that I'm doubting, just supposing that the source would have other interesting information, too :) You may want to have a look at the already mentioned JFP-article by Peyton

Re: [Haskell-cafe] What is the rank of a polymorphic type?

2009-12-05 Thread Dan Doel
On Sunday 06 December 2009 1:42:34 am Eugene Kirpichov wrote: OK, thanks. However, isn't the type (forall a . a) - String impredicative because it instantiates a type variable of the type constructor (-) p q with p = forall a . a? There's probably no clear cut answer to this independent of