PofoliaPofolia ile paylaşıldı

ACM Transactions on Programming Languages and Systems· 2026Q2

ML için Yönsel Olmayan Tip Çıkarımı: Her Yönden Prensip

Omnidirectional type inference for ML: principality any way

Alistair O'Brien, Didier Rémy, Gabriel Scherer

Kısa özet

Yeni bir yönsel olmayan tip çıkarımı algoritması, tip bilgisinin sabit bir sıra yerine dinamik olarak akmasına izin vererek, statik aşırı yükleme ve birinci sınıf polimorfizm gibi kırılgan özelliklerle genişletilmiş ML benzeri dillerde prensip özelliğini (benzersiz en genel tip) geri kazandırır.

Yapay zekâ ile başlık ve abstract'tan üretildi; tam metin okunmaz.

Ana noktalar

  • Tip çıkarımı için dinamik bilgi akışını sağlayan yönsel olmayan tip çıkarımını önerir.
  • Kırılgan yapılarla (örn. GADT'ler, yüksek dereceli polimorfizm, statik aşırı yükleme) ML benzeri dillere prensip özelliğini geri kazandırır.
  • Kısmen çözülmüş tip şemalarıyla let-genelleştirmeyi ele almak için artımlı örneklemeyi tanıtır.
  • OCaml'ın mevcut tip denetleyicilerinden daha fazla ifade gücünü statik aşırı yükleme ve birinci sınıf polimorfizm için gösterir.

Yapay zekâ ile başlık ve abstract'tan üretildi; tam metin okunmaz.

Özet (abstract)

The Damas-Hindley-Milner (ML) type system owes its success to principality , the property that every well-typed expression has a unique most general type. This makes inference predictable and efficient. Yet, principality is fragile : many extensions of ML—GADTs, higher-rank polymorphism, and static overloading—break it by introducing fragile constructs that resist principal inference. Existing approaches recover principality through directional inference algorithms, which propagate known type information in a fixed (or static ) order ( e.g. as in bidirectional typing) to disambiguate such constructs. However, the rigidity of a static inference order often causes otherwise well-typed programs to be rejected. We propose omnidirectional type inference, where type information flows in a dynamic order. Typing constraints may be solved in any order, suspending when progress requires known type information and resuming once it becomes available, using suspended match constraints . This approach is straightforward for simply typed systems, but extending it to ML is challenging due to let-generalization . Existing ML inference algorithms type let-bindings in a fixed order—type the let-bound expression first, generalize its type, and then type the let-body. To overcome this, we introduce incremental instantiation , allowing partially solved type schemes containing suspended constraints to be instantiated, with a mechanism to incrementally update instances as the scheme is refined. Omnidirectionality provides a general framework for restoring principality in the presence of fragile features. We demonstrate its versatility on two fundamentally different features of OCaml: static overloading of record labels and datatype constructors and semi-explicit first-class polymorphism. In both cases, we obtain a principal type inference algorithm that is more expressive than OCaml’s current typechecker.

Yazarların özeti; kaynağından alınmıştır. ACM Transactions on Programming Languages and Systems, 2026 · DOI ↗

ÇıkarımlarPremium
Makaleye SorÜcretsiz hesapla

Ücretsiz hesapla devam et

Makaleye Sor ile bu makaleye günde 3 soru ücretsiz; makaleyi kaydet, kaynakçasını al, ilgi alanına göre her gün yeni özetler. Çıkarımlar Premium.

Web'de ücretsiz devam et

Google ya da Apple hesabınla giriş; kart istemez. Bu makaleye geri dönersin.

Telefonda:

Alan: Yapay Zeka

Artificial IntelligenceComputer Science