skip to main content
article

The best of both worlds: linear functional programming without compromise

Published:04 September 2016Publication History
Skip Abstract Section

Abstract

We present a linear functional calculus with both the safety guarantees expressible with linear types and the rich language of combinators and composition provided by functional programming. Unlike previous combinations of linear typing and functional programming, we compromise neither the linear side (for example, our linear values are first-class citizens of the language) nor the functional side (for example, we do not require duplicate definitions of compositions for linear and unrestricted functions). To do so, we must generalize abstraction and application to encompass both linear and unrestricted functions. We capture the typing of the generalized constructs with a novel use of qualified types. Our system maintains the metatheoretic properties of the theory of qualified types, including principal types and decidable type inference. Finally, we give a formal basis for our claims of expressiveness, by showing that evaluation respects linearity, and that our language is a conservative extension of existing functional calculi.

References

  1. A. J. Ahmed, M. Fluet, and G. Morrisett. A step-indexed model of substructural state. In Proceedings of the 10th ACM SIGPLAN International Conference on Functional Programming, ICFP 2005, Tallinn, Estonia, September 26-28, 2005, pages 78–91, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. R. Atkey. Parameterised notions of computation. J. Funct. Program., 19(3-4):335–376, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. A. Barber and G. Plotkin. Dual intuitionistic linear logic. Technical Report LFCS-96-347, University of Edinburgh, 1996.Google ScholarGoogle Scholar
  4. J. Boyland. Checking interference with fractional permissions. In Static Analysis, 10th International Symposium, SAS 2003, San Diego, CA, USA, June 11-13, 2003, Proceedings, pages 55–72, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. L. Caires and F. Pfenning. Session types as intuitionistic linear propositions. In CONCUR. Springer, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. C. Chen and P. Hudak. Rolling your own MADT - A connection between linear types and monads. In Conference Record of POPL’97: The 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Papers Presented at the Symposium, Paris, France, 15-17 January 1997, pages 54–66, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. M. Fähndrich and R. DeLine. Adoption and focus: Practical linear types for imperative programming. In Proceedings of the 2002 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), Berlin, Germany, June 17-19, 2002, pages 13–24, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. A. Filinski. Linear continuations. In Conference Record of the Nineteenth Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Albuquerque, New Mexico, USA, January 19-22, 1992, pages 27–38, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. E. Gan, J. A. Tov, and G. Morrisett. Type classes for lightweight substructural types. In Proceedings Third International Workshop on Linearity, LINEARITY 2014, Vienna, Austria, 13th July, 2014, pages 34–48, 2014.Google ScholarGoogle Scholar
  10. S. J. Gay and V. T. Vasconcelos. Linear type theory for asynchronous session types. J. Funct. Program., 20(1):19–50, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. J. Girard. Linear logic. Theor. Comput. Sci., 50:1–102, 1987. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. J. Gustavsson and J. Svenningsson. A usage analysis with bounded usage polymorphism and subtyping. In M. Mohnen and P. W. M. Koopman, editors, Implementation of Functional Languages, 12th International Workshop, IFL 2000, Aachen, Germany, September 4- 7, 2000, Selected Papers, volume 2011 of Lecture Notes in Computer Science, pages 140–157. Springer, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. J. C. Guzmán and P. Hudak. Single-threaded polymorphic lambda calculus. In Proceedings of the Fifth Annual Symposium on Logic in Computer Science (LICS ’90), Philadelphia, Pennsylvania, USA, June 4-7, 1990, pages 333–343, 1990.Google ScholarGoogle ScholarCross RefCross Ref
  14. J. Hage, S. Holdermans, and A. Middelkoop. A generic usage analysis with subeffect qualifiers. In R. Hinze and N. Ramsey, editors, Proceedings of the 12th ACM SIGPLAN International Conference on Functional Programming, ICFP 2007, Freiburg, Germany, October 1- 3, 2007, pages 235–246. ACM, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. S. Holdermans and J. Hage. Making ”stricterness” more relevant. Higher-Order and Symbolic Computation, 23(3):315–335, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. K. Honda. Types for dyadic interaction. In CONCUR. Springer, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. M. P. Jones. Qualified Types: Theory and Practice. Cambridge University Press, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. M. P. Jones. Simplifying and improving qualified types. In Proceedings of the seventh international conference on Functional programming languages and computer architecture, FPCA ’95, pages 160– 169, La Jolla, California, USA, 1995. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. M. P. Jones. First-class polymorphism with type inference. In P. Lee, F. Henglein, and N. D. Jones, editors, Conference Record of POPL’97: The 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Papers Presented at the Symposium, Paris, France, 15-17 January 1997, pages 483–496. ACM Press, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. M. P. Jones. Type classes with functional dependencies. In Proceedings of the 9th European Symposium on Programming Languages and Systems, ESOP ’00, pages 230–244, Berlin, Germany, 2000. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. J. Launchbury and R. Paterson. Parametricity and unboxing with unpointed types. In H. R. Nielson, editor, Programming Languages and Systems - ESOP’96, 6th European Symposium on Programming, Linköping, Sweden, April 22-24, 1996, Proceedings, volume 1058 of Lecture Notes in Computer Science, pages 204–218. Springer, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. O. Lee and K. Yi. Proofs about a folklore let-polymorphic type inference algorithm. ACM Trans. Program. Lang. Syst., 20(4):707– 723, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. S. Lindley and J. G. Morris. A semantics for propositions as sessions. In J. Vitek, editor, Programming Languages and Systems - 24th European Symposium on Programming, ESOP 2015, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2015, London, UK, April 11-18, 2015. Proceedings, volume 9032 of Lecture Notes in Computer Science, pages 560–584. Springer, 2015.Google ScholarGoogle Scholar
  24. K. Mazurak, J. Zhao, and S. Zdancewic. Lightweight linear types in System F ◦. In TLDI, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. J. G. Morris. The best of both worlds: Linear functional programming without compromise (extended version). http://homepages.inf. ed.ac.uk/jmorri14/, 2016.Google ScholarGoogle Scholar
  26. G. Morrisett, A. J. Ahmed, and M. Fluet. L3: A linear language with locations. In P. Urzyczyn, editor, Typed Lambda Calculi and Applications, 7th International Conference, TLCA 2005, Nara, Japan, April 21-23, 2005, Proceedings, volume 3461 of Lecture Notes in Computer Science, pages 293–307. Springer, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. P. W. O’Hearn and D. J. Pym. The logic of bunched implications. Bulletin of Symbolic Logic, 5(2):215–244, 1999.Google ScholarGoogle ScholarCross RefCross Ref
  28. T. Petricek, D. A. Orchard, and A. Mycroft. Coeffects: a calculus of context-dependent computation. In J. Jeuring and M. M. T. Chakravarty, editors, Proceedings of the 19th ACM SIGPLAN international conference on Functional programming, Gothenburg, Sweden, September 1-3, 2014, pages 123–135. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. R. Pucella and J. A. Tov. Haskell session types with (almost) no class. In Proceedings of the 1st ACM SIGPLAN Symposium on Haskell, Haskell 2008, Victoria, BC, Canada, 25 September 2008, pages 25– 36. ACM, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. J. C. Reynolds. Syntactic control of interference. In A. V. Aho, S. N. Zilles, and T. G. Szymanski, editors, Conference Record of the Fifth Annual ACM Symposium on Principles of Programming Languages, Tucson, Arizona, USA, January 1978, pages 39–46. ACM Press, 1978. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. S. Smetsers, E. Barendsen, M. C. J. D. van Eekelen, and M. J. Plasmeijer. Guaranteeing safe destructive updates through a type system with uniqueness information for graphs. In H. J. Schneider and H. Ehrig, editors, Graph Transformations in Computer Science, International Workshop, Dagstuhl Castle, Germany, January 1993, Proceedings, volume 776 of Lecture Notes in Computer Science, pages 358–379. Springer, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. F. Smith, D. Walker, and J. G. Morrisett. Alias types. In G. Smolka, editor, Programming Languages and Systems, 9th European Symposium on Programming, ESOP 2000, Held as Part of the European Joint Conferences on the Theory and Practice of Software, ETAPS 2000, Berlin, Germany, March 25 - April 2, 2000, Proceedings, volume 1782 of Lecture Notes in Computer Science, pages 366–381. Springer, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. J. A. Tov and R. Pucella. Practical affine types. In T. Ball and M. Sagiv, editors, Proceedings of the 38th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2011, Austin, TX, USA, January 26-28, 2011, pages 447–458. ACM, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. V. T. Vasconcelos, S. J. Gay, and A. Ravara. Type checking a multithreaded functional language with session types. Theor. Comput. Sci., 368(1-2):64–87, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. P. Wadler. A taste of linear logic. In Mathematical Foundations of Computer Science 1993, 18th International Symposium, MFCS’93, Gdansk, Poland, August 30 - September 3, 1993, Proceedings, pages 185–210, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. P. Wadler. Propositions as sessions. J. Funct. Program., 24(2-3):384– 418, 2014.Google ScholarGoogle ScholarCross RefCross Ref
  37. D. Walker. Substructural type systems. In B. C. Pierce, editor, Advanced Topics in Types and Programming Languages, chapter 1. The MIT Press, 2004.Google ScholarGoogle Scholar
  38. D. Walker, K. Crary, and J. G. Morrisett. Typed memory management via static capabilities. ACM Trans. Program. Lang. Syst., 22(4):701– 771, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. The best of both worlds: linear functional programming without compromise

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 51, Issue 9
        ICFP '16
        September 2016
        501 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/3022670
        Issue’s Table of Contents
        • cover image ACM Conferences
          ICFP 2016: Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming
          September 2016
          501 pages
          ISBN:9781450342193
          DOI:10.1145/2951913

        Copyright © 2016 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 4 September 2016

        Check for updates

        Qualifiers

        • article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!