71 research outputs found

    Migratory Typing: Ten Years Later

    Get PDF
    In this day and age, many developers work on large, untyped code repositories. Even if they are the creators of the code, they notice that they have to figure out the equivalent of method signatures every time they work on old code. This step is time consuming and error prone. Ten years ago, the two lead authors outlined a linguistic solution to this problem. Specifically they proposed the creation of typed twins for untyped programming languages so that developers could migrate scripts from the untyped world to a typed one in an incremental manner. Their programmatic paper also spelled out three guiding design principles concerning the acceptance of grown idioms, the soundness of mixed-typed programs, and the units of migration. This paper revisits this idea of a migratory type system as implemented for Racket. It explains how the design principles have been used to produce the Typed Racket twin and presents an assessment of the project\u27s status, highlighting successes and failures

    Polymorphic set-theoretic types for functional languages

    Get PDF
    We study set-theoretic types: types that include union, intersection, and negation connectives. Set-theoretic types, coupled with a suitable subtyping relation, are useful to type several programming language constructs \u2013 including conditional branching, pattern matching, and function overloading \u2013 very precisely. We define subtyping following the semantic subtyping approach, which interprets types as sets and defines subtyping as set inclusion. Our set-theoretic types are polymorphic, that is, they contain type variables to allow parametric polymorphism. We extend previous work on set-theoretic types and semantic subtyping by showing how to adapt them to new settings and apply them to type various features of functional languages. More precisely, we integrate semantic subtyping with three important language features. In Part I we study implicitly typed languages with let-polymorphism and type inference (previous work on semantic subtyping focused on explicitly typed languages). We describe an implicitly typed lambda-calculus and a declarative type system for which we prove soundness. We study type inference and prove results of soundness and completeness. Then, we show how to make type inference more precise when programs are partially annotated with types. In Part II we study gradual typing. We describe a new approach to add gradual typing to a static type system; the novelty is that we give a declarative presentation of the type system, while previous work considered algorithmic presentations. We first illustrate the approach on a Hindley-Milner type system without subtyping. We describe declarative typing, compilation to a cast language, and sound and complete type inference. Then, we add set-theoretic types, defining a subtyping relation on set-theoretic gradual types, and we describe sound type inference for the extended system. In Part III we consider non-strict semantics. The existing semantic subtyping systems are designed for call-by-value languages and are unsound for non-strict semantics. We adapt them to obtain soundness for call-by-need. To do so, we introduce an explicit representation for divergence in the types, allowing the type system to distinguish the expressions that are already evaluated from those that are computations which might diverge.Cette th\ue8se porte sur l'\ue9tude des types ensemblistes : des types qui contiennent des connecteurs d'union, d'intersection et de n\ue9gation. Les types ensemblistes permettent de typer de mani\ue8re tr\ue8s pr\ue9cise plusieurs constructions des langages de programmation (comme par exemple les branches conditionnelles, le filtrage par motif et la surcharge des fonctions) lorsqu'ils sont utilis\ue9s avec une notion appropri\ue9e de sous-typage. Pour d\ue9finir celle-ci, nous utilisons l'approche du sous-typage s\ue9mantique, dans laquelle les types sont interpr\ue9t\ue9s comme des ensembles, et o\uf9 le sous-typage est d\ue9fini comme l'inclusion ensembliste. Dans la plupart de cette th\ue8se, les types ensemblistes sont polymorphes, dans le sens o\uf9 ils contiennent des variables de type pour permettre le polymorphisme param\ue9trique. La th\ue8se \ue9tend les travaux pr\ue9c\ue9dents sur les types ensemblistes et le sous-typage s\ue9mantique en montrant comment les adapter \ue0 des nouveaux contextes et comment les utiliser pour typer plusieurs aspects des langages fonctionnels. Elle se compose de trois parties. La premi\ue8re partie porte sur une \ue9tude des langages typ\ue9s de mani\ue8re implicite avec polymorphisme du "let" et inf\ue9rence de types (contrairement aux travaux pr\ue9c\ue9dents sur le sous-typage s\ue9mantique qui \ue9tudiaient des langages typ\ue9s explicitement). Nous y d\ue9crivons un lambda-calcul typ\ue9 implicitement avec un syst\ue8me de types dont nous d\ue9montrons la correction. De m\ueame, nous y \ue9tudions l'inf\ue9rence de types dont nous d\ue9montrons la correction et la compl\ue9tude. Enfin, nous montrons comment rendre l'inf\ue9rence plus pr\ue9cise quand les programmes sont partiellement annot\ue9s avec des types. La deuxi\ue8me partie d\ue9crit une nouvelle approche permettant d'\ue9tendre un syst\ue8me de types statique avec du typage graduel; l'originalit\ue9 venant du fait que nous d\ue9crivons le syst\ue8me de types de fa\ue7on d\ue9clarative, lorsque les syst\ue8mes existants proposent des descriptions algorithmiques. Nous illustrons cette approche en ajoutant le typage graduel \ue0 un syst\ue8me de types \ue0 la Hindley-Milner sans sous-typage. Nous d\ue9crivons pour cela un syst\ue8me de types d\ue9claratif, un processus de compilation vers un langage avec v\ue9rifications de type dynamiques (ou "casts"), et nous pr\ue9sentons un syst\ue8me d'inf\ue9rence de types correct et complet. Ensuite, nous y ajoutons les types ensemblistes, en d\ue9finissant une relation de sous-typage sur les types graduel ensemblistes, puis en pr\ue9sentant un syst\ue8me d'inf\ue9rence de types correct pour le syst\ue8me \ue9tendu. La troisi\ue8me partie porte sur l'\ue9tude des s\ue9mantiques non-strictes. Les syst\ue8mes existants qui utilisent le sous-typage s\ue9mantique ont \ue9t\ue9 d\ue9velopp\ue9s pour des langages avec appel par valeur et ne sont pas s\ufbrs pour des s\ue9mantiques non-strictes. Nous montrons ici comment les adapter pour garantir leur s\ufbret\ue9 en appel par n\ue9cessit\ue9. Pour faire \ue7a, nous introduisons dans les types une repr\ue9sentation explicite de la divergence, afin que le syst\ue8me des types puisse distinguer les expressions qui ne demandent pas d'\ue9valuation de celles qui la demandent et pourraient ainsi diverger

    Staattisesti tyypitetyt ohjelmointikielet JavaScript-ekosysteemissä: tyyppijärjestelmien näkökulma

    Get PDF
    JavaScript is a ubiquitous programming language with usage in web, mobile applications and server software. The status of the language as the de-facto programming language of the web has made the language ecosystem advanced with a great number of userspace libraries and major companies working on efficient runtime systems. The core language, however, has numerous known difficulties caused by the initial design and persisted by the requirements for backwards-compatibility. In the last decade, a number of programming languages have chosen JavaScript as the compile target of the language. Type theory and its application, programming language type systems, is an essential area of study in the design of programming languages. Every high-level programming language features a type system that greatly influences the ways of designing and implementing programs in the language. This thesis examines a group of selected statically-typed programming languages that compile to JavaScript. The core topics of research in this thesis are the motivation for new JS-compiled languages, the type system design of the languages, and the future direction of the JavaScript ecosystem based on the current trends and parallels to other programming ecosystems. The results of the work include identifying several trends in type systems for the JS ecosystem and the web. These include unsound yet convenient partially inferred type systems for object-oriented and multi-paradigm programming and fully inferred extended Hindley-Milner type systems for primarily functional programming languages. Additionally, different options for the advancement of the programming ecosystem, including type annotations, inference of dynamically typed languages and new compile targets, are explored. Finally, based on the design choices of the languages researched, we provide several recommendations for safe and productive statically typed programming in the JavaScript ecosystem.JavaScript on laajalti käytetty ohjelmointikieli, jonka käyttö ulottuu web- ja mobiilisovelluksiin sekä palvelinohjelmistoon. Kielen asema web-kehityksen de-facto-ohjelmointikielenä on luonut sen ympärille laajan ohjelmistoekosysteemin, joka kattaa suuren määrän ohjelmistokirjastoja sekä tehokkaita ajoympäristöjä. Itse kieli aiheuttaa tästä huolimatta vaikeuksia alkuperäisten suunnitteluvirheiden ja vaaditun taaksepäinyhteensopivuuden vuoksi. Viimeisen vuosikymmenen aikana useampi ohjelmointikieli on alkanut käyttää JavaScriptia käännöskohteenaan. Tyyppiteoria ja sen sovellus, ohjelmointikielten tyyppijärjestelmät, on tärkeä tutkimusala liittyen ohjelmointikielten suunnitteluun. Tyyppijärjestelmä on osa jokaista korkean tason ohjelmoinikieltä ja vaikuttaa täten suuresti itse ohjelmointikielen muihin ominaisuuksiin ja käyttöön. Tämä tutkimus käsittelee joukkoa staattisesti tyypitettyjä ohjelmointikieliä, jotka kääntyvät JavaScript-koodiksi. Tutkimuksen ytimessä ovat uusien kielten kehityksen motiivit, kielten tyyppijärjestelmien suunnittelu ja ominaisuudet sekä JavaScript-ekosysteemin mahdolliset tulevaisuuden suunnat. Työn tuloksena tunnistamme useita trendejä tyyppijärjestelmien suunnittelussa JavaScript-ekosysteemiin. Näihin kuuluu käytännölliset, mutta teoriassa epäturvalliset tyyppijärjestelmät olio- ja moniparadigmaohjelmoinkieliin sekä funktionaalisten ohjelmointikielien Hindley-Milner-pohjaiset tyyppijärjestelmät, joissa muuttujien tyypit pystytään täysin päättelemään ilman ohjelman kirjoittajan annotaatioita. Lisäksi nostamme esiin useita tulevaisuuden suuntia, jotka voisivat viedä JS-ekosysteemiä eteenpäin. Näihin kuuluvat tyyppiannotaatiot, dynaamisten kielten tyyppi-inferenssi ja uudet käännöskohteet web-ekosysteemiin. Lopuksi annamme tutkimuksen perusteella suosituksia ominaisuuksista ja suunnitteluratkaisuista, jotka voisivat mahdollistaa tehokkaan ja turvallisen ohjelmistokehityksen JavaScript-ekosysteemissä tulevaisuudessa

    Blossom: A Language Built to Grow

    Get PDF

    Static and Dynamic Types for Functional Languages

    Get PDF

    Gradual Liquid Type Inference

    Full text link
    Liquid typing provides a decidable refinement inference mechanism that is convenient but subject to two major issues: (1) inference is global and requires top-level annotations, making it unsuitable for inference of modular code components and prohibiting its applicability to library code, and (2) inference failure results in obscure error messages. These difficulties seriously hamper the migration of existing code to use refinements. This paper shows that gradual liquid type inference---a novel combination of liquid inference and gradual refinement types---addresses both issues. Gradual refinement types, which support imprecise predicates that are optimistically interpreted, can be used in argument positions to constrain liquid inference so that the global inference process e effectively infers modular specifications usable for library components. Dually, when gradual refinements appear as the result of inference, they signal an inconsistency in the use of static refinements. Because liquid refinements are drawn from a nite set of predicates, in gradual liquid type inference we can enumerate the safe concretizations of each imprecise refinement, i.e. the static refinements that justify why a program is gradually well-typed. This enumeration is useful for static liquid type error explanation, since the safe concretizations exhibit all the potential inconsistencies that lead to static type errors. We develop the theory of gradual liquid type inference and explore its pragmatics in the setting of Liquid Haskell.Comment: To appear at OOPSLA 201
    corecore