Skip to main content
Log in

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

  • Original Article
  • Published:
Acta Informatica Aims and scope Submit manuscript

Abstract

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.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Institutional subscriptions

Similar content being viewed by others

References

  1. Augustsson, L.: Putting Curry-Howard to work (Invited talk). At: Approaches and Applications of Inductive Programming (2009)

  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. Crary, K.: Logical relations and a case study in equivalence checking. In: [22], chapter6, pp. 223–244 (2005)

  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)

  5. Dyckhoff R.: Contraction-free sequent calculi for intuitionistic logic. J. Symb. Log. 57(3), 795–807 (1992). doi:10.2307/2275431

    Article  MATH  MathSciNet  Google Scholar 

  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

    Chapter  Google Scholar 

  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

    Chapter  Google Scholar 

  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. 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. 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. Johann P.: Short cut fusion is correct. J. Funct. Program. 13(4), 797–814 (2003). doi:10.1017/S0956796802004409

    Article  MATH  MathSciNet  Google Scholar 

  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

    Article  MATH  MathSciNet  Google Scholar 

  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. Johann P., Voigtländer J.: The impact of seq on free theorems-based program transformations. Fundam. Inform. 69(1–2), 63–102 (2006)

    MATH  Google Scholar 

  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. 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. 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. 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. Peyton Jones S.: The Implementation of Functional Programming Languages. Prentice-Hall, Englewood Cliffs (1987)

    MATH  Google Scholar 

  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. Pierce B.: Types and Programming Languages. MIT Press, Cambridge (2002)

    Google Scholar 

  22. Pierce, B. (ed.): Advanced Topics in Types and Programming Languages. MIT Press, London (2005)

    MATH  Google Scholar 

  23. Pitts, A.: Typed operational reasoning. In: [22], chapter 7, pp. 245–289 (2005)

  24. Plasmeijer, R., van Eekelen, M.: Clean version 2.1 language report (2002). http://clean.cs.ru.nl/download/Clean20/doc/CleanLangRep.2.1.pdf

  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. Reynolds J.: Types, abstraction and parametric polymorphism. In: Mason, R. (ed.) Information Processing, Proceedings, pp. 513–523. Elsevier, Amsterdam (1983)

    Google Scholar 

  27. Schmidt D.: Denotational Semantics: A Methodology for Language Development. Allyn and Bacon, Boston (1986)

    Google Scholar 

  28. Seidel, D., Voigtländer, J.: Taming selective strictness. Technical report TUD-FI09-06, Technische Universität Dresden (2009). http://www.iai.uni-bonn.de/jv/TUD-FI09-06.pdf

  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. 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

    Chapter  Google Scholar 

  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. 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. 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. 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

    Chapter  Google Scholar 

  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. 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. 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. 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. 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

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Janis Voigtländer.

Additional information

An earlier version of this paper appeared under the title “Taming Selective Strictness” in the electronic proceedings of the “4. Arbeitstagung Programmiersprachen”, volume 154 of Lecture Notes in Informatics, pages 2916–2930, Gesellschaft für Informatik, 2009.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Seidel, D., Voigtländer, J. Refined typing to localize the impact of forced strictness on free theorems. Acta Informatica 48, 191–211 (2011). https://doi.org/10.1007/s00236-011-0136-9

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00236-011-0136-9

Keywords

Navigation