Java Stream Fusion: Adapting FP mechanisms for an OO setting

In this paper, we show how stream fusion, a program transformation technique used in functional programming, can be adapted for an Object-Oriented setting. This makes it possible to have more Stream operators than the ones currently provided by the Java Stream API. The addition of more operators allows for a greater deal of expressiveness. To this extent, we show how these operators are incorporated in the stream setting. Furthermore, we also demonstrate how a specific set of optimizations eliminates overheads and produces equivalent code in the form of for loops. In this way, programmers are relieved from the burden of writing code in such a cumbersome style, thus allowing for a more declarative and intuitive programming approach.

[1]  Patricia Johann,et al.  Short Cut Fusion for Effects , 2008, Trends in Functional Programming.

[2]  John Hughes,et al.  Why Functional Programming Matters , 1989, Comput. J..

[3]  Martin Fowler,et al.  Refactoring - Improving the Design of Existing Code , 1999, Addison Wesley object technology series.

[4]  Akihiko Takano,et al.  Shortcut deforestation in calculational form , 1995, FPCA '95.

[5]  João Saraiva,et al.  A shortcut fusion rule for circular program calculation , 2007, Haskell '07.

[6]  Olivier Danvy,et al.  A generic account of continuation-passing styles , 1994, POPL '94.

[7]  Akihiko Takano,et al.  Tupling calculation eliminates multiple data traversals , 1997, ICFP '97.

[8]  Simon L. Peyton Jones,et al.  A short cut to deforestation , 1993, FPCA '93.

[9]  Janis Voigtländer Semantics and Pragmatics of New Shortcut Fusion Rules , 2008, FLOPS.

[10]  João Paulo Fernandes,et al.  Shortcut fusion rules for the derivation of circular and higher-order programs , 2011, High. Order Symb. Comput..

[11]  João Saraiva,et al.  Multiple intermediate structure deforestation by shortcut fusion , 2016, Sci. Comput. Program..

[12]  Roman Leshchinskiy,et al.  Stream fusion: from lists to streams to nothing at all , 2007, ICFP '07.

[13]  Yannis Smaragdakis,et al.  Stream fusion, to completeness , 2017, POPL.

[14]  Danny Dig,et al.  LambdaFicator: From imperative to functional programming through automated refactoring , 2013, 2013 35th International Conference on Software Engineering (ICSE).

[15]  Frank Tip,et al.  Advanced refactorings in eclipse , 2004, OOPSLA '04.

[16]  Philip Wadler,et al.  Deforestation: Transforming Programs to Eliminate Trees , 1990, Theor. Comput. Sci..