## ML-Style Typing, Lambda Lifting, and Partial Evaluation (1999)

Venue: | In CLAPF ’99 |

Citations: | 1 - 0 self |

### BibTeX

@INPROCEEDINGS{Thiemann99ml-styletyping,,

author = {Peter Thiemann},

title = {ML-Style Typing, Lambda Lifting, and Partial Evaluation},

booktitle = {In CLAPF ’99},

year = {1999}

}

### OpenURL

### Abstract

. Lambda lifting transforms local function definitions in functional programming languages into global ones to facilitate their efficient implementation. When considered as a source-to-source transformation for an ML-style typed language, all published algorithms for lambda lifting break typability. We break down two representative lambda lifting algorithms into four elementary transformation steps, analyze their typing properties, and define alternative steps that preserve ML typability where appropriate. Putting the revised steps together, we define a lambda lifter that preserves ML-style typability. Our algorithm provides a starting point for implementing efficient generating extensions that perform offline partial evaluation for polymorphically typed languages. 1 Introduction Lambda lifting is one of the standard transformations in the tool box of the implementor of functional programming languages. Its task is to close local function definitions by parameterizing them...

### Citations

607 |
The Definition of Standard ML (Revised
- Harper, Milner, et al.
- 1997
(Show Context)
Citation Context ... according to our rules, they type check neither in Objective Caml nor in Standard ML. This is caused by the value restriction, which only allows to generalize the types of let-bound syntactic values =-=[14]-=-. While fun x -? ... is a syntactic value, an application like h f g is not. Eta-expansion of h f g is possible, but it duplicates the computation of the value of h f g. In contrast, the algorithm tha... |

537 |
S.: The Implementation of Functional Programming Languages
- Jones
- 1987
(Show Context)
Citation Context ...ion [21] --- a close relative to lambda lifting --- gives rise to typing problems, too [15, 27, 26, 2]. Essentially, all presentations of various aspects of lambda lifting deal with untyped languages =-=[10, 17, 19, 20, 6]-=-. This is fine, because they are solving an important problem in an untyped intermediate language after type checking has been performed. In addition, most of them are informal, which makes it hard to... |

364 |
Types, abstraction and parametric polymorphism
- Reynolds
- 1983
(Show Context)
Citation Context ...l of Computer Science and Information Technology, University of Nottingham, UK. The author acknowledges support by EPSRC grant GR/M22840 "Semantics of Specialization". Reynolds' work on para=-=metricity [22]-=-. Therefore, it is wasteful to specialize with respect to different values of first-order polymorphic arguments. Of course, it might still make sense to specialize with respect to a polymorphic functi... |

300 | Definitional interpreters for higher-order programming languages
- Reynolds
- 1972
(Show Context)
Citation Context ...rogram, we have to worry whether lambda lifting preserves typability. It turns out that none of the published lambda lifters does. This does not come as a complete surprise because closure conversion =-=[21]-=- --- a close relative to lambda lifting --- gives rise to typing problems, too [15, 27, 26, 2]. Essentially, all presentations of various aspects of lambda lifting deal with untyped languages [10, 17,... |

260 | Compiling Polymorphism using Intensional Type Analysis
- Harper, Morrisett
- 1995
(Show Context)
Citation Context ...ves the operational properties. The EXPAND transformation does not cause problems in an explicitly typed language with first-class polymorphism (such languages are popular intermediate languages, cf. =-=[18, 7]-=-). In such a language, EXPAND would transform x = e with a free variable y : oe to x = y : oe:e[x := x y] without endangering typability. The EXPAND' transformation might be beneficial before transfor... |

179 | Lambda lifting: transforming programs to recursive equations
- Johnsson
- 1985
(Show Context)
Citation Context ...ion [21] --- a close relative to lambda lifting --- gives rise to typing problems, too [15, 27, 26, 2]. Essentially, all presentations of various aspects of lambda lifting deal with untyped languages =-=[10, 17, 19, 20, 6]-=-. This is fine, because they are solving an important problem in an untyped intermediate language after type checking has been performed. In addition, most of them are informal, which makes it hard to... |

155 | Typed Closure Conversion
- Minamide, Morrisett, et al.
- 1996
(Show Context)
Citation Context ...that none of the published lambda lifters does. This does not come as a complete surprise because closure conversion [21] --- a close relative to lambda lifting --- gives rise to typing problems, too =-=[15, 27, 26, 2]-=-. Essentially, all presentations of various aspects of lambda lifting deal with untyped languages [10, 17, 19, 20, 6]. This is fine, because they are solving an important problem in an untyped interme... |

120 | The Glasgow Haskell compiler: A technical overview
- Jones, Hall, et al.
- 1993
(Show Context)
Citation Context ...ves the operational properties. The EXPAND transformation does not cause problems in an explicitly typed language with first-class polymorphism (such languages are popular intermediate languages, cf. =-=[18, 7]-=-). In such a language, EXPAND would transform x = e with a free variable y : oe to x = y : oe:e[x := x y] without endangering typability. The EXPAND' transformation might be beneficial before transfor... |

117 | Automatic autoprojection of recursive equations with global variables and abstract data types
- Bondorf, Danvy
- 1991
(Show Context)
Citation Context ...the top-level where the compiler generates efficient code for them [9]. Lambda lifting is also a key transformation in program specializers, because it increases code sharing of specialized functions =-=[4]-=-. The intention is that the specializer runs at most once for every pair of source function and specializationtime arguments. A log keeps track of the started specializations and --- before starting a... |

93 |
Polymorphic type schemes and recursive definitions
- Mycroft
- 1984
(Show Context)
Citation Context ...ed, in the transformed expression the types of x 1 ; : : : ; xn are generalized already in the e 0 m . Compilers usually apply SPLIT based on the results of a dependency analysis before type checking =-=[16, 17]-=-. 3.4 LIFT The LIFT transformation floats let-bindings outside of other structures. It comprises five rules. x 62 S FV(e i ) n fx 1 ; : : : ; xn g x:let fxn = e n g in e 0 ; let fxn = e n g in x:e 0 (... |

72 |
98: A non-strict, purely functional language
- Haskell
- 1999
(Show Context)
Citation Context ...a finite number of times because each application removes at least one occurrence of a free variable. Polymorphic recursion EXPAND' does not help in a language with polymorphic recursion like Haskell =-=[8]-=- or Hope [5] because polymorphic recursion can use a function at an infinite number of different types. The following example (in Haskell syntax) serves as an illustration. data Nlist a = Nil --- Fork... |

60 |
An experimental applicative language
- HOPE
- 1980
(Show Context)
Citation Context ...ber of times because each application removes at least one occurrence of a free variable. Polymorphic recursion EXPAND' does not help in a language with polymorphic recursion like Haskell [8] or Hope =-=[5]-=- because polymorphic recursion can use a function at an infinite number of different types. The following example (in Haskell syntax) serves as an illustration. data Nlist a = Nil --- Fork a (Nlist [a... |

44 | Partial evaluation of standard ML
- Birkedal, Welinder
- 1993
(Show Context)
Citation Context ...oint in favor of local logs is increased efficiency in accessing the logs. However, the same efficiency may be obtained by careful structuring of the global log. The MLmix specializer for Standard ML =-=[3]-=- circumvents the problem with lambda lifting completely: firstly, it requires monomorphic source programs. All lambda lifting algorithms preserve monomorphic typing. Secondly, it does not perform lamb... |

41 |
Super Combinators: A New Implementation Method for Applicative Languages
- Hughes
- 1982
(Show Context)
Citation Context ...erizing them over their free variables. Once all functions have been closed in this way (turned into combinators), they are moved to the top-level where the compiler generates efficient code for them =-=[9]-=-. Lambda lifting is also a key transformation in program specializers, because it increases code sharing of specialized functions [4]. The intention is that the specializer runs at most once for every... |

39 | Lambda-dropping: transforming recursive equations into programs with block structure
- Danvy, Schultz
- 2000
(Show Context)
Citation Context ...ion [21] --- a close relative to lambda lifting --- gives rise to typing problems, too [15, 27, 26, 2]. Essentially, all presentations of various aspects of lambda lifting deal with untyped languages =-=[10, 17, 19, 20, 6]-=-. This is fine, because they are solving an important problem in an untyped intermediate language after type checking has been performed. In addition, most of them are informal, which makes it hard to... |

37 |
Implementing functional languages
- Jones, Lester
- 1992
(Show Context)
Citation Context |

33 | Type-driven defunctionalization
- Bell, Bellegarde, et al.
- 1997
(Show Context)
Citation Context ...that none of the published lambda lifters does. This does not come as a complete surprise because closure conversion [21] --- a close relative to lambda lifting --- gives rise to typing problems, too =-=[15, 27, 26, 2]-=-. Essentially, all presentations of various aspects of lambda lifting deal with untyped languages [10, 17, 19, 20, 6]. This is fine, because they are solving an important problem in an untyped interme... |

29 |
Handwriting cogen to avoid problems with static typing
- Holst, Launchbury
- 1991
(Show Context)
Citation Context ...ts. Of course, it might still make sense to specialize with respect to a polymorphic function. Our approach to an efficient implementation of partial evaluation is based on the cogen-by-hand approach =-=[11]-=-. In this approach, we want to transform---for the above reasons---the lambda-lifted polymorphic source program into its own generating extension (a specializer dedicated to specialize that particular... |

19 | Compiler-directed Type Reconstruction for Polymorphic Languages
- Aditya, Caro
- 1993
(Show Context)
Citation Context ...t decreases the number of type applications. This can be an advantage for an implementation that maintains type information at runtime, for example to do tag-free garbage collection [25] or debugging =-=[1]-=-, where a type application actually performs some work. In fact, this motivation has driven Saha and Shao [23] to define a transformation that eliminates all type applications at runtime. Their transf... |

14 |
A modular fully-lazy lambda lifter
- Jones, Lester
- 1991
(Show Context)
Citation Context |

13 | Optimal type lifting
- Saha, Shao
- 1998
(Show Context)
Citation Context ...pe information at runtime, for example to do tag-free garbage collection [25] or debugging [1], where a type application actually performs some work. In fact, this motivation has driven Saha and Shao =-=[23]-=- to define a transformation that eliminates all type applications at runtime. Their transformation is quite similar to lambda lifting. 3.3 SPLIT The SPLIT rule splits up a let-expression in two parts ... |

5 |
The Objective Caml system release 1.07, Documentation and user's manual
- Leroy
- 1997
(Show Context)
Citation Context ... We leave the semantics of the language unspecified because we want to consider both call-by-value and call-by-name variants of it. The examples have been type checked using the Objective Caml system =-=[12]-=-. Caml uses fun x -? e for x:e and let rec x 1 = e 1 and : : : and xn = e n in e instead of let fxn = e n g in e. 3 Transformation steps Lambda lifting comprises four elementary transformation steps, ... |

1 |
Polyvariant specialisation for higher-order, block-structured languages
- Malmkjaer, rbaek
- 1995
(Show Context)
Citation Context ... --- the specializer checks the log whether the work has been done already. Local function definitions require a more elaborate log structure which does not guarantee sharing of their specializations =-=[13]-=-. It is also advantageous to perform specialization in a polymorphic language: if a function is polymorphic in a first-order specialization-time argument then its specialization does not depend on the... |