Advertisement

Asymptotic Improvement of Computations over Free Monads

  • Janis Voigtländer
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5133)

Abstract

We present a low-effort program transformation to improve the efficiency of computations over free monads in Haskell. The development is calculational and carried out in a generic setting, thus applying to a variety of datatypes. An important aspect of our approach is the utilisation of type class mechanisms to make the transformation as transparent as possible, requiring no restructuring of code at all. There is also no extra support necessary from the compiler (apart from an up-to-date type checker). Despite this simplicity of use, our technique is able to achieve true asymptotic runtime improvements. We demonstrate this by examples for which the complexity is reduced from quadratic to linear.

Keywords

Fusion Rule Functional Programming Program Transformation Type Checker Type Constructor 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Moggi, E.: Notions of computation and monads. Information and Computation 93(1), 55–92 (1991)zbMATHCrossRefMathSciNetGoogle Scholar
  2. 2.
    Peyton Jones, S., Wadler, P.: Imperative functional programming. In: Principles of Programming Languages, Proceedings, pp. 71–84. ACM Press, New York (1993)Google Scholar
  3. 3.
    Launchbury, J., Peyton Jones, S.: State in Haskell. Lisp and Symbolic Computation 8(4), 293–341 (1995)CrossRefGoogle Scholar
  4. 4.
    Wadler, P.: The essence of functional programming. In: Principles of Programming Languages, Proceedings, pp. 1–14. ACM Press, New York (1992) (invited talk)Google Scholar
  5. 5.
    Liang, S., Hudak, P., Jones, M.: Monad transformers and modular interpreters. In: Principles of Programming Languages, Proceedings, pp. 333–343. ACM Press, New York (1995)Google Scholar
  6. 6.
    Hughes, R.: A novel representation of lists and its application to the function “reverse”. Information Processing Letters 22(3), 141–144 (1986)CrossRefGoogle Scholar
  7. 7.
    Jones, M.: Functional programming with overloading and higher-order polymorphism. In: Jeuring, J., Meijer, E. (eds.) AFP 1995. LNCS, vol. 925, pp. 97–136. Springer, Heidelberg (1995)Google Scholar
  8. 8.
    Sheard, T., Pasalic, E.: Two-level types and parameterized modules. Journal of Functional Programming 14(5), 547–587 (2004)zbMATHCrossRefGoogle Scholar
  9. 9.
    Reynolds, J.: Types, abstraction and parametric polymorphism. In: Information Processing, Proceedings, pp. 513–523. Elsevier, Amsterdam (1983)Google Scholar
  10. 10.
    Wadler, P.: Theorems for free! In: Functional Programming Languages and Computer Architecture, Proceedings, pp. 347–359. ACM Press, New York (1989)CrossRefGoogle Scholar
  11. 11.
    Swierstra, W., Altenkirch, T.: Beauty in the beast — A functional semantics for the awkward squad. In: Haskell Workshop, Proceedings, pp. 25–36. ACM Press, New York (2007)CrossRefGoogle Scholar
  12. 12.
    Claessen, K., Hughes, R.: QuickCheck: A lightweight tool for random testing of Haskell programs. In: International Conference on Functional Programming, Proceedings, pp. 268–279. ACM Press, New York (2000)Google Scholar
  13. 13.
    Swierstra, W.: Data types à la carte. Journal of Functional Programming (to appear)Google Scholar
  14. 14.
    Swierstra, W., Altenkirch, T.: Dependent types for distributed arrays. In: Trends in Functional Programming, Draft Proceedings (2008)Google Scholar
  15. 15.
    Ghani, N., Johann, P., Uustalu, T., Vene, V.: Monadic augment and generalised short cut fusion. In: International Conference on Functional Programming, Proceedings, pp. 294–305. ACM Press, New York (2005)Google Scholar
  16. 16.
    Ghani, N., Johann, P.: Monadic augment and generalised short cut fusion. Journal of Functional Programming 17(6), 731–776 (2007)zbMATHCrossRefMathSciNetGoogle Scholar
  17. 17.
    Gill, A.: Cheap Deforestation for Non-strict Functional Languages. PhD thesis, University of Glasgow (1996)Google Scholar
  18. 18.
    Johann, P.: A generalization of short-cut fusion and its correctness proof. Higher-Order and Symbolic Computation 15(4), 273–300 (2002)zbMATHCrossRefGoogle Scholar
  19. 19.
    Chitil, O.: Type-Inference Based Deforestation of Functional Programs. PhD thesis, RWTH Aachen (2000)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2008

Authors and Affiliations

  • Janis Voigtländer
    • 1
  1. 1.Institut für Theoretische InformatikTechnische Universität DresdenDresdenGermany

Personalised recommendations