caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* What is "principal typing"?
@ 2006-12-20 21:53 Tom
  2006-12-21  4:10 ` [Caml-list] " Jeff Polakow
  0 siblings, 1 reply; 6+ messages in thread
From: Tom @ 2006-12-20 21:53 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 280 bytes --]

Now, this may sound a stupid question, but I am no guru of mathematics and
type theory... Could somebody point me to some documents explaining what the
principal typing is and why is it useful? (Supposedly, this is some property
that type inference systems should have...)

- Tom

[-- Attachment #2: Type: text/html, Size: 291 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] What is "principal typing"?
  2006-12-20 21:53 What is "principal typing"? Tom
@ 2006-12-21  4:10 ` Jeff Polakow
  2006-12-21  6:42   ` Tom
  2006-12-21  7:27   ` Christophe Dehlinger
  0 siblings, 2 replies; 6+ messages in thread
From: Jeff Polakow @ 2006-12-21  4:10 UTC (permalink / raw)
  To: Tom <tom.primozic; +Cc: caml-list, caml-list-bounces

[-- Attachment #1: Type: text/plain, Size: 1514 bytes --]

Hello,

  There are two notions, often conflated,  which you might be referring
to: principal types and principal typings. The following is taken from [1]
which is worth reading if you're interested in this topic.

    Principal Types
      Given: a term M typable with type assumptions A.
      There exists: a type sigma representing all possible types for M in
A.

    Principal Typings
      Given: a typable term M.
      There exists: a judgement A |- M : tau \x1c representing all possible
typings for M.

Principal types, which ML has, are useful because, for a given context,
there is a most general type for any typeable term. This is a useful
property to have for languages which attempt type inference.

Principal typeings, which ML does not have, are useful because they allow
for compositional type inference (i.e. each piece of the program can be
analyzed separately).

[1] J. B. Wells. The essence of principal typings. In Proc. 29th Int'l
Coll. Automata, Languages, and Programming, volume 2380 of LNCS, pages
913-925. Springer-Verlag, 2002.
(http://www.macs.hw.ac.uk/~jbw/papers/Wells:The-Essence-of-Principal-Typings:ICALP-2002.pdf)

--Jeff

---

This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.

[-- Attachment #2: Type: text/html, Size: 2678 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] What is "principal typing"?
  2006-12-21  4:10 ` [Caml-list] " Jeff Polakow
@ 2006-12-21  6:42   ` Tom
  2006-12-21 21:02     ` Jeff Polakow
  2006-12-21  7:27   ` Christophe Dehlinger
  1 sibling, 1 reply; 6+ messages in thread
From: Tom @ 2006-12-21  6:42 UTC (permalink / raw)
  To: Jeff Polakow; +Cc: caml-list, caml-list-bounces

[-- Attachment #1: Type: text/plain, Size: 414 bytes --]

Thanks!

On 21/12/06, Jeff Polakow <jeff.polakow@db.com> wrote:
>
>
>
> Principal types, which ML has, are useful because, for a given context,
> there is a most general type for any typeable term. This is a useful
> property to have for languages which attempt type inference.



Could you give some concrete example of a type inference engine and a
typable term, but which does not have a principal type?

- Tom

[-- Attachment #2: Type: text/html, Size: 754 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] What is "principal typing"?
  2006-12-21  4:10 ` [Caml-list] " Jeff Polakow
  2006-12-21  6:42   ` Tom
@ 2006-12-21  7:27   ` Christophe Dehlinger
  2006-12-21 21:07     ` Jeff Polakow
  1 sibling, 1 reply; 6+ messages in thread
From: Christophe Dehlinger @ 2006-12-21  7:27 UTC (permalink / raw)
  To: O'Caml Mailing List

On 12/21/06, Jeff Polakow <jeff.polakow@db.com> wrote:
>
> Principal typeings, which ML does not have, are useful because they allow for compositional type inference (i.e. each piece of the program can be analyzed separately).
>
>

According to a 2005 paper by Camarao and Figueiredo (found at
http://www.dcc.ufmg.br/~camarao/ml-has-pt.pdf ), there is a variation
of the usual Damas-Milner type system for core-ML that types the same
terms and also has principal typings.

So the language ML does have principal typings, in the sense that it
has a useful type system with principal typings, but afaik no ML
implementation uses a such a type system.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] What is "principal typing"?
  2006-12-21  6:42   ` Tom
@ 2006-12-21 21:02     ` Jeff Polakow
  0 siblings, 0 replies; 6+ messages in thread
From: Jeff Polakow @ 2006-12-21 21:02 UTC (permalink / raw)
  To: Tom <tom.primozic; +Cc: caml-list, caml-list-bounces

[-- Attachment #1: Type: text/plain, Size: 1020 bytes --]

Hello,

> Could you give some concrete example of a type inference engine and 
> a typable term, but which does not have a principal type?
> 
Here is a silly example. Consider a simply typed lambda calculus with 
subtyping on base types (e.g. int < real) but no structural subtyping 
(i.e. no subtype relation between functions). Then things like the 
identity function have no principal type. 

There are less trivial systems out there where, usually involving subtying 
and/or type classes, where principal types either don't exist or were 
tricky to figure out. But I am several years removed from actively 
thinking about this stuff and can't recall off hand more specific details.

-Jeff




---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.

[-- Attachment #2: Type: text/html, Size: 1810 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] What is "principal typing"?
  2006-12-21  7:27   ` Christophe Dehlinger
@ 2006-12-21 21:07     ` Jeff Polakow
  0 siblings, 0 replies; 6+ messages in thread
From: Jeff Polakow @ 2006-12-21 21:07 UTC (permalink / raw)
  To: christophedehlinger; +Cc: O'Caml Mailing List, caml-list-bounces

[-- Attachment #1: Type: text/plain, Size: 994 bytes --]

Hello,

> According to a 2005 paper by Camarao and Figueiredo (found at
> http://www.dcc.ufmg.br/~camarao/ml-has-pt.pdf ), there is a variation
> of the usual Damas-Milner type system for core-ML that types the same
> terms and also has principal typings.
> 
I hadn't heard of this work before. I'll try to take a look at it 
sometime.

> So the language ML does have principal typings, in the sense that it
> has a useful type system with principal typings, but afaik no ML
> implementation uses a such a type system.
> 
Yes, I should have been more careful with my assertion. The paper I 
referenced actually shows that Hindley/Milner has no principal typings.

-Jeff

---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.

[-- Attachment #2: Type: text/html, Size: 1809 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-12-21 21:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-20 21:53 What is "principal typing"? Tom
2006-12-21  4:10 ` [Caml-list] " Jeff Polakow
2006-12-21  6:42   ` Tom
2006-12-21 21:02     ` Jeff Polakow
2006-12-21  7:27   ` Christophe Dehlinger
2006-12-21 21:07     ` Jeff Polakow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).