The linearity Monad

We introduce a technique for programming with domain-specific linear languages using the monad that arises from the theory of linear/non-linear logic. In this work we interpret the linear/non-linear model as a simple, effectful linear language embedded inside an existing non-linear host language. We implement a modular framework for defining these linear EDSLs in Haskell, allowing both shallow and deep embeddings. To demonstrate the effectiveness of the framework and the linearity monad, we implement languages for file handles, mutable arrays, session types, and quantum computing.

[1]  J. Garrett Morris The best of both worlds: linear functional programming without compromise , 2016, ICFP.

[3]  Thorsten Altenkirch,et al.  The Quantum IO Monad , 2006 .

[4]  Nick Benton,et al.  A Term Calculus for Intuitionistic Linear Logic , 1993, TLCA.

[5]  Frank Pfenning,et al.  Session Types as Intuitionistic Linear Propositions , 2010, CONCUR.

[6]  Stephanie Weirich,et al.  Visible Type Application , 2016, ESOP.

[7]  Neil J. Ross,et al.  ALGEBRAIC AND LOGICAL METHODS IN QUANTUM COMPUTATION , 2015, 1510.02198.

[8]  Jonathan Protzenko,et al.  Programming with permissions in Mezzo , 2013, ICFP.

[9]  Erik Barendsen,et al.  Conventional and Uniqueness Typing in Graph Rewrite Systems , 1993, FSTTCS.

[10]  P. Selinger,et al.  Quantum lambda calculus , 2010 .

[11]  Nobuko Yoshida,et al.  Effects as sessions, sessions as effects , 2016, POPL.

[12]  Sam Lindley,et al.  A Semantics for Propositions as Sessions , 2015, ESOP.

[13]  Jan Vitek,et al.  Flexible Alias Protection , 1998, ECOOP.

[14]  Philip Wadler,et al.  Linear logic, monads and the lambda calculus , 1996, Proceedings 11th Annual IEEE Symposium on Logic in Computer Science.

[15]  Marko C. J. D. van Eekelen,et al.  Concurrent Clean , 1991, PARLE.

[16]  Jennifer Paykin,et al.  QWIRE Practice: Formal Verification of Quantum Circuits in Coq , 2018, QPL.

[17]  Paul Blain Levy,et al.  Call-By-Push-Value: A Functional/Imperative Synthesis , 2003, Semantics Structures in Computation.

[18]  Jeff Polakow Embedding a full linear Lambda calculus in Haskell , 2015, Haskell.

[19]  Isaac L. Chuang,et al.  Quantum Computation and Quantum Information (10th Anniversary edition) , 2011 .

[20]  Benoît Valiron,et al.  Quipper: a scalable quantum programming language , 2013, PLDI.

[21]  Riccardo Pucella,et al.  Haskell session types with (almost) no class , 2008, Haskell '08.

[22]  Dominic R. Verity,et al.  ∞-Categories for the Working Mathematician , 2018 .

[23]  Steve Zdancewic,et al.  Lolliproc: to concurrency from classical linear logic via curry-howard and control , 2010, ICFP '10.

[24]  Sam Lindley,et al.  Embedding session types in Haskell , 2016, Haskell.

[25]  Simon Peyton Jones,et al.  Retrofitting linear types , 2017 .

[26]  Nicholas D. Matsakis,et al.  The rust language , 2014, HILT '14.

[27]  Paul Blain Levy,et al.  Call-by-Push-Value: A Subsuming Paradigm , 1999, TLCA.

[28]  Jennifer Paykin,et al.  QWIRE: a core language for quantum circuits , 2017, POPL.

[29]  Richard A. Eisenberg,et al.  Promoting functions to type families in Haskell , 2014, Haskell '14.

[30]  Conor McBride,et al.  I Got Plenty o' Nuttin' , 2016, A List of Successes That Can Change the World.

[31]  Nick Benton,et al.  A Mixed Linear and Non-Linear Logic: Proofs, Terms and Models (Extended Abstract) , 1994, CSL.

[32]  Steve Zdancewic,et al.  Lightweight linear types in system f° , 2010, TLDI '10.

[33]  Conor McBride,et al.  A List of Successes That Can Change the World , 2016, Lecture Notes in Computer Science.

[34]  Paul Hudak,et al.  Rolling your own mutable ADT—a connection between linear types and monads , 1997, POPL '97.

[35]  Philip Wadler,et al.  Linear Types can Change the World! , 1990, Programming Concepts and Methods.

[36]  Philip Wadler Propositions as sessions , 2014, J. Funct. Program..

[37]  J. Gregory Morrisett,et al.  Linear Regions Are All You Need , 2006, ESOP.

[38]  Mark P. Jones,et al.  Type Classes with Functional Dependencies , 2000, ESOP.