Lightweight Polymorphic Effects

  • Lukas Rytz
  • Martin Odersky
  • Philipp Haller
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7313)


Type-and-effect systems are a well-studied approach for reasoning about the computational behavior of programs. Nevertheless, there is only one example of an effect system that has been adopted in a wide-spread industrial language: Java’s checked exceptions. We believe that the main obstacle to using effect systems in day-to-day programming is their verbosity, especially when writing functions that are polymorphic in the effect of their argument. To overcome this issue, we propose a new syntactically lightweight technique for writing effect-polymorphic functions. We show its independence from a specific kind of side-effect by embedding it into a generic and extensible framework for checking effects of multiple domains. Finally, we verify the expressiveness and practicality of the system by implementing it for the Scala programming language.


Function Type Evaluation Rule Typing Rule Dynamic Semantic Syntactic Form 
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.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Abadi, M., Birrell, A., Harris, T., Isard, M.: Semantics of transactional memory and automatic mutual exclusion. In: Proceedings of the 35th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2008, pp. 63–74. ACM, New York (2008)CrossRefGoogle Scholar
  2. 2.
    Bocchino Jr., R.L., Adve, V.S.: Types, Regions, and Effects for Safe Programming with Object-Oriented Parallel Frameworks. In: Mezini, M. (ed.) ECOOP 2011. LNCS, vol. 6813, pp. 306–332. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  3. 3.
    Bracha, G.: Pluggable type systems. In: OOPSLA 2004 Workshop on Revival of Dynamic Languages (2004)Google Scholar
  4. 4.
    Foster, J.S., Johnson, R., Kodumal, J., Aiken, A.: Flow-insensitive type qualifiers. ACM Trans. Program. Lang. Syst. 28, 1035–1087 (2006)CrossRefGoogle Scholar
  5. 5.
    Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design patterns: elements of reusable object-oriented software. Addison-Wesley Longman Publishing Co., Inc., Boston (1995)Google Scholar
  6. 6.
    Gibbons, J., Oliveira, B.C.D.S.: The essence of the iterator pattern. In: McBride, C., Uustalu, T. (eds.) Mathematically-Structured Functional Programming (2006)Google Scholar
  7. 7.
    Gifford, D.K., Jouvelot, P., Sheldon, M.A., O’Toole, J.W.: Report on the FX programming language. Technical report (1992)Google Scholar
  8. 8.
    Gosling, J., Joy, B., Steele, G., Bracha, G.: The Java(TM) Language Specification, 3rd edn. Addison-Wesley Professional (2005)Google Scholar
  9. 9.
    Haller, P., Odersky, M.: Scala actors: Unifying thread-based and event-based programming. Theor. Comput. Sci. 410(2-3), 202–220 (2009)MathSciNetzbMATHCrossRefGoogle Scholar
  10. 10.
    Hejlsberg, A.: The trouble with checked exceptions (2003),
  11. 11.
    King, D., Wadler, P.: Combining monads. In: Mathematical Structures in Computer Science, pp. 61–78 (1992)Google Scholar
  12. 12.
    Lea, D.: A Java fork/join framework. In: Java Grande, pp. 36–43 (2000)Google Scholar
  13. 13.
    Lucassen, J.M., Gifford, D.K.: Polymorphic effect systems. In: Proceedings of the 15th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 1988, pp. 47–57. ACM, New York (1988)CrossRefGoogle Scholar
  14. 14.
    Marino, D., Millstein, T.: A generic type-and-effect system. In: Proceedings of the 4th International Workshop on Types in Language Design and Implementation, TLDI 2009, pp. 39–50. ACM, New York (2009)Google Scholar
  15. 15.
    Mikhailova, A., Romanovsky, A.: Supporting evolution of interface exceptions, pp. 94–110. Springer-Verlag New York, Inc., New York (2001)Google Scholar
  16. 16.
    Odersky, M.: The Scala language specification (2011),
  17. 17.
    Odersky, M., Moors, A.: Fighting bit rot with types (experience report: Scala collections). In: Kannan, R., Narayan Kumar, K. (eds.) IARCS Annual Conference on Foundations of Software Technology and Theoretical Computer Science (FSTTCS 2009). Leibniz International Proceedings in Informatics (LIPIcs), vol. 4, pp. 427–451. Schloss Dagstuhl–Leibniz-Zentrum für Informatik, Dagstuhl (2009)Google Scholar
  18. 18.
    Pearce, D.J.: JPure: A Modular Purity System for Java. In: Knoop, J. (ed.) CC 2011. LNCS, vol. 6601, pp. 104–123. Springer, Heidelberg (2011), doi:10.1007/978-3-642-19861-8_7CrossRefGoogle Scholar
  19. 19.
    Rytz, L., Odersky, M.: Lightweight polymorphic effects - proofs. Technical report, EPFL (2012)Google Scholar
  20. 20.
    Syme, D., Petricek, T., Lomov, D.: The F# Asynchronous Programming Model. In: Rocha, R., Launchbury, J. (eds.) PADL 2011. LNCS, vol. 6539, pp. 175–189. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  21. 21.
    Talpin, J.-P., Jouvelot, P.: Polymorphic type, region and effect inference. Journal of Functional Programming 2(3), 245–271 (1992)MathSciNetzbMATHCrossRefGoogle Scholar
  22. 22.
    van Dooren, M., Steegmans, E.: Combining the robustness of checked exceptions with the flexibility of unchecked exceptions using anchored exception declarations. In: Proceedings of the 20th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2005, pp. 455–471. ACM, New York (2005)CrossRefGoogle Scholar
  23. 23.
    Wadler, P., Thiemann, P.: The marriage of effects and monads. ACM Trans. Comput. Logic 4, 1–32 (2003)MathSciNetCrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Lukas Rytz
    • 1
  • Martin Odersky
    • 1
  • Philipp Haller
    • 1
  1. 1.EPFLSwitzerland

Personalised recommendations