Acta Informatica

, Volume 48, Issue 3, pp 191–211 | Cite as

Refined typing to localize the impact of forced strictness on free theorems

Original Article


Free theorems establish interesting properties of parametrically polymorphic functions, solely from their types, and serve as a nice proof tool. For pure and lazy functional programming languages, they can be used with very few preconditions. Unfortunately, in the presence of selective strictness, as provided in languages like Haskell, their original strength is reduced. In this paper we present an approach for overcoming this weakness in specific situations. Employing a refined type system which tracks the use of enforced strict evaluation, we rule out unnecessary restrictions that otherwise emerge. Additionally, we provide (and implement) an algorithm determining all refined types for a given term.


Derivation Tree Typing Rule Typing Environment Denotational Semantic Typing Derivation 
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.
    Augustsson, L.: Putting Curry-Howard to work (Invited talk). At: Approaches and Applications of Inductive Programming (2009)Google Scholar
  2. 2.
    Bernardy J.-P., Jansson P., Claessen K.: Testing polymorphic properties. In: Gordon, A. (ed.) European Symposium on Programming, Proceedings, volume 6012 of LNCS, pp. 125–144. Springer, Heidelberg (2010). doi: 10.1007/978-3-642-11957-6_8 Google Scholar
  3. 3.
    Crary, K.: Logical relations and a case study in equivalence checking. In: [22], chapter6, pp. 223–244 (2005)Google Scholar
  4. 4.
    Day, N., Launchbury, J., Lewis, J.: Logical abstractions in Haskell. In: Meijer, E. (ed.) Haskell Workshop, Proceedings. Technical Report UU-CS-1999-28, Utrecht University (1999)Google Scholar
  5. 5.
    Dyckhoff R.: Contraction-free sequent calculi for intuitionistic logic. J. Symb. Log. 57(3), 795–807 (1992). doi: 10.2307/2275431 CrossRefMATHMathSciNetGoogle Scholar
  6. 6.
    Fernandes J., Pardo A., Saraiva J.: A shortcut fusion rule for circular program calculation. In: Keller, G. (ed.) Haskell Workshop, Proceedings, pp. 95–106. ACM, New York (2007). doi: 10.1145/1291201.1291216 CrossRefGoogle Scholar
  7. 7.
    Gill A., Launchbury J., Peyton Jones S.: A short cut to deforestation. In: Arvind, (ed.) Functional Programming Languages and Computer Architecture, Proceedings, pp. 223–232. ACM, New York (1993). doi: 10.1145/165180.165214 CrossRefGoogle Scholar
  8. 8.
    Holdermans S., Hage J.: Making “stricterness” more relevant. In: Gallagher, J., Voigtländer, J. (eds) Partial Evaluation and Program Manipulation, Proceedings, pp. 121–130. ACM, New York (2010). doi: 10.1145/1706356.1706379 Google Scholar
  9. 9.
    Hudak P., Hughes R., Peyton Jones S., Wadler P.: A history of Haskell: being lazy with class. In: Ryder, B., Hailpern, B. (eds) History of Programming Languages, Proceedings, pp. 12-1–12-55. ACM, New York (2007). doi: 10.1145/1238844.1238856 Google Scholar
  10. 10.
    Hughes R.: Strictness detection in non-flat domains. In: Ganzinger, H., Jones, N. (eds) Programs as Data Objects 1985, Proceedings, volume 217 of LNCS, pp. 112–135. Springer, Heidelberg (1986). doi: 10.1007/3-540-16446-4_7 Google Scholar
  11. 11.
    Johann P.: Short cut fusion is correct. J. Funct. Program. 13(4), 797–814 (2003). doi: 10.1017/S0956796802004409 CrossRefMATHMathSciNetGoogle Scholar
  12. 12.
    Johann P.: On proving the correctness of program transformations based on free theorems for higher-order polymorphic calculi. Math. Struct. Comput. Sci. 15(2), 201–229 (2005). doi: 10.1017/S0960129504004578 CrossRefMATHMathSciNetGoogle Scholar
  13. 13.
    Johann P., Voigtländer J.: Free theorems in the presence of seq. In: Leroy, X. (ed.) Principles of Programming Languages, Proceedings, volume 39(1) of ACM SIGPLAN Not., pp. 99–110. ACM, New York (2004). doi: 10.1145/982962.964010 Google Scholar
  14. 14.
    Johann P., Voigtländer J.: The impact of seq on free theorems-based program transformations. Fundam. Inform. 69(1–2), 63–102 (2006)MATHGoogle Scholar
  15. 15.
    Launchbury J., Paterson R.: Parametricity and unboxing with unpointed types. In: Riis Nielson, H. (ed.) European Symposium on Programming, Proceedings, volume 1058 of LNCS, pp. 204–218. Springer, Heidelberg (1996). doi: 10.1007/3-540-61055-3_38 Google Scholar
  16. 16.
    Mycroft A.: The theory and practice of transforming call-by-need into call-by-value. In: Robinet, B. (ed.) Colloque International sur la Programmation, Proceedings, volume 83 of LNCS, pp. 269–281. Springer, Heidelberg (1980). doi: 10.1007/3-540-09981-6_19 Google Scholar
  17. 17.
    Nielson F., Riis Nielson H.: Type and effect systems. In: Olderog, E.-R., Steffen, B. (eds) Festschrift to Hans Langmaack: Correct System Design, Recent Insight and Advances, volume 1710 of LNCS, pp. 114–136. Springer, Heidelberg (1999). doi: 10.1007/3-540-48092-7_6 Google Scholar
  18. 18.
    Oliveira B., Schrijvers T., Cook W.: EffectiveAdvice: disciplined advice with explicit effects. In: Jézéquel, J.-M., Südholt, M. (eds) Aspect-Oriented Software Development, Proceedings, pp. 109–120. ACM, New York (2010). doi: 10.1145/1739230.1739244 Google Scholar
  19. 19.
    Peyton Jones S.: The Implementation of Functional Programming Languages. Prentice-Hall, Englewood Cliffs (1987)MATHGoogle Scholar
  20. 20.
    Peyton Jones, S. (ed.): Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, Cambridge (2003). doi: 10.2277/0521826144 Google Scholar
  21. 21.
    Pierce B.: Types and Programming Languages. MIT Press, Cambridge (2002)Google Scholar
  22. 22.
    Pierce, B. (ed.): Advanced Topics in Types and Programming Languages. MIT Press, London (2005)MATHGoogle Scholar
  23. 23.
    Pitts, A.: Typed operational reasoning. In: [22], chapter 7, pp. 245–289 (2005)Google Scholar
  24. 24.
    Plasmeijer, R., van Eekelen, M.: Clean version 2.1 language report (2002).
  25. 25.
    Reynolds J.: Towards a theory of type structure. In: Robinet, B. (ed.) Colloque sur la Programmation, Proceedings, volume19 of LNCS, pp. 408–423. Springer, Heidelberg (1974)Google Scholar
  26. 26.
    Reynolds J.: Types, abstraction and parametric polymorphism. In: Mason, R. (ed.) Information Processing, Proceedings, pp. 513–523. Elsevier, Amsterdam (1983)Google Scholar
  27. 27.
    Schmidt D.: Denotational Semantics: A Methodology for Language Development. Allyn and Bacon, Boston (1986)Google Scholar
  28. 28.
    Seidel, D., Voigtländer, J.: Taming selective strictness. Technical report TUD-FI09-06, Technische Universität Dresden (2009).
  29. 29.
    Seidel D., Voigtländer J.: Taming selective strictness. In: Dosch, W., Hanus, M. (eds) Arbeitstagung Programmiersprachen, Proceedings, volume 154 of LNI, pp. 2916–2930. Gesellschaft für Informatik, Bonn (2009)Google Scholar
  30. 30.
    Seidel D., Voigtländer J.: Automatically generating counterexamples to naive free theorems. In: Blume, M., Vidal, G. (eds) Functional and Logic Programming, Proceedings, volume 6009 of LNCS, pp. 175–190. Springer, Heidelberg (2010). doi: 10.1007/978-3-642-12251-4_14 CrossRefGoogle Scholar
  31. 31.
    Svenningsson J.: Shortcut fusion for accumulating parameters & zip-like functions. In: Peyton Jones, S. (ed.) International Conference on Functional Programming, Proceedings, volume 37(9) of ACM SIGPLAN Not., pp. 124–132. ACM, New York (2002). doi: 10.1145/583852.581491 Google Scholar
  32. 32.
    Voigtländer J.: Much ado about two: a pearl on parallel prefix computation. In: Wadler, P. (ed.) Principles of Programming Languages, Proceedings, volume 43(1) of ACM SIGPLAN Not., pp. 29–35. ACM, New York (2008). doi: 10.1145/1328897.1328445 Google Scholar
  33. 33.
    Voigtländer J.: Proving correctness via free theorems: the case of the destroy/build-rule. In: Glück, R., de Moor, O. (eds) Partial Evaluation and Semantics-Based Program Manipulation, Proceedings, pp. 13–20. ACM, New York (2008). doi: 10.1145/1328408.1328412 Google Scholar
  34. 34.
    Voigtländer J.: Semantics and pragmatics of new shortcut fusion rules. In: Garrigue, J., Hermenegildo, M. (eds) Functional and Logic Programming, Proceedings, volume 4989 of LNCS, pp. 163–179. Springer, Heidelberg (2008). doi: 10.1007/978-3-540-78969-7_13 CrossRefGoogle Scholar
  35. 35.
    Voigtländer J.: Bidirectionalization for free!. In: Pierce, B. (ed.) Principles of Programming Languages, Proceedings, volume 44(1) of ACM SIGPLAN Not., pp. 165–176. ACM, New York (2009). doi: 10.1145/1594834.1480904 Google Scholar
  36. 36.
    Voigtländer J.: Free theorems involving type constructor classes. In: Tolmach, A. (ed.) International Conference on Functional Programming, Proceedings, volume 44(9) of ACM SIGPLAN Not., pp. 173–184. ACM, New York (2009). doi: 10.1145/1631687.1596577 Google Scholar
  37. 37.
    Voigtländer J., Hu Z., Matsuda K., Wang M.: Combining syntactic and semantic bidirectionalization. In: Weirich, S. (ed.) International Conference on Functional Programming, Proceedings, volume 45(9) of ACM SIGPLAN Not., pp. 181–192. ACM, New York (2010). doi: 10.1145/1932681.1863571 Google Scholar
  38. 38.
    Wadler P.: Theorems for free!. In: MacQueen, D. (ed.) Functional Programming Languages and Computer Architecture, Proceedings, pp. 347–359. ACM, New York (1989). doi: 10.1145/99370.99404 Google Scholar
  39. 39.
    Wadler, P., Blott, S.: How to make ad-hoc polymorphism less ad hoc. In: Principles of Programming Languages, Proceedings, pp. 60–76. ACM, New York (1989). doi: 10.1145/75277.75283

Copyright information

© Springer-Verlag 2011

Authors and Affiliations

  1. 1.Institute for Computer ScienceUniversity of BonnBonnGermany

Personalised recommendations