Once upon a polymorphic type

We present a sound type-based 'usage analysis' for a realistic lazy functional language. Accurate information on the usage of program subexpressions in a lazy functional language permits a compiler to perform a number of useful optimisations. However, existing analyses are either ad-hoc and approximate, or defined over restricted languages.Our work extends the Once Upon A Type system of Turner, Mossin, and Wadler (FPCA'95). Firstly, we add type polymorphism, an essential feature of typed functional programming languages. Secondly, we include general Hsskell-style user-defined algebraic data types. Thirdly, we explain and solve the 'poisoning problem', which causes the earlier analysis to yield poor results. Interesting design choices turn up in each of these areas.Our analysis is sound with respect to a Launchbury-style operational semantics, and it is straightforward to implement. Good results have been obtained from a prototype implementation, and we are currently integrating the system into the Glasgow Haskell Compiler.

[1]  J. B. Wells,et al.  Typability and type checking in the second-order /spl lambda/-calculus are equivalent and undecidable , 1994, Proceedings Ninth Annual IEEE Symposium on Logic in Computer Science.

[2]  S. Jones,et al.  A Transformation-Based Optimiser for Haskell , 1998, Sci. Comput. Program..

[3]  Valeria de Paiva,et al.  Linear Explicit Substitutions ( Extended Abstract ) , 1998 .

[4]  Philip Wadler,et al.  Is there a use for linear logic? , 1991, PEPM '91.

[5]  Jörgen Gustavsson A type based sharing analysis for update avoidance and optimisation , 1998, ICFP '98.

[6]  Simon L. Peyton Jones,et al.  Let-floating: moving bindings to give faster programs , 1996, ICFP '96.

[7]  Philip Wadler,et al.  A Taste of Linear Logic , 1993, MFCS.

[8]  Matthias Felleisen,et al.  A call-by-need lambda calculus , 1995, POPL '95.

[9]  J. B. Wells Typability and type checking in the second-order Λ-calculus are equivalent and undecidable (Preliminary Draft) , 1993 .

[10]  Benjamin C. Pierce,et al.  Higher-Order Subtyping , 1994, Theor. Comput. Sci..

[11]  Giorgio Ghelli,et al.  Coherence of Subsumption, Minimum Typing and Type-Checking in F<= , 1992, Math. Struct. Comput. Sci..

[12]  John Launchbury,et al.  A natural semantics for lazy evaluation , 1993, POPL '93.

[13]  Andrew John Gill,et al.  Cheap deforestation for non-strict functional languages , 1996 .

[14]  Simon Marlow Update Avoidance Analysis by Abstract Interpretation , 1993, Functional Programming.

[15]  Philip Wadler,et al.  Once upon a type , 1995, FPCA '95.

[16]  Bart Jacobs,et al.  Semantics of Weakening and Contraction , 1994, Ann. Pure Appl. Log..

[17]  Philip Wadler,et al.  Linear Types can Change the World! , 1990, Programming Concepts and Methods.

[18]  Chris Okasaki,et al.  Purely functional data structures , 1998 .

[19]  Simon L. Peyton Jones,et al.  Avoiding Unnecessary Updates , 1992, Functional Programming.

[20]  Andrew Moran,et al.  Improvement in a lazy context: an operational theory for call-by-need , 1999, POPL '99.

[21]  Robert Harper,et al.  Compiling polymorphism using intensional type analysis , 1995, POPL '95.

[22]  David Wright Linear, Strictness and Usage Logics , 1996 .

[23]  Simon L. Peyton Jones,et al.  Compiling Haskell by Program Transformation: A Report from the Trenches , 1996, ESOP.

[24]  E. R I K B A R En D S E N,et al.  Uniqueness Typing for Functional Languages with Graph Rewriting Semantics , 1996 .

[25]  Simon L. Peyton Jones,et al.  A modular fully‐lazy lambda lifter in Haskell , 1991, Softw. Pract. Exp..

[26]  Jean-Yves Girard,et al.  Linear logic: its syntax and semantics , 1995 .

[27]  Simon Peyton Jones,et al.  Implementing Functional Languages: a tutorial , 2000 .

[28]  Patrick Lincoln,et al.  Linear logic , 1992, SIGA.

[29]  Matthias Felleisen,et al.  A Syntactic Approach to Type Soundness , 1994, Inf. Comput..

[30]  Simon L. Peyton Jones,et al.  Unboxed Values as First Class Citizens in a Non-Strict Functional Language , 1991, FPCA.

[31]  Torben Æ. Mogensen Types for 0, 1 or Many Uses , 1997, Implementation of Functional Languages.

[32]  Simon L. Peyton Jones,et al.  Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine , 1992, Journal of Functional Programming.

[33]  Peter Sewell Global/Local Subtyping and Capability Inference for a Distributed pi-calculus , 1998, ICALP.

[34]  André L. M. Santos,et al.  Compilation by transformation in non-strict functional languages , 1995 .

[35]  Richard S. Bird,et al.  Nested Datatypes , 1998, MPC.

[36]  Luca Cardelli,et al.  Subtyping recursive types , 1991, POPL '91.

[37]  Benjamin Goldberg,et al.  Detecting sharing of partial applications in functional programs , 1987, FPCA.

[38]  Udi Manber,et al.  Introduction to algorithms - a creative approach , 1989 .