Skip to main content
×
Home
    • Aa
    • Aa

No value restriction is needed for algebraic effects and handlers*

  • OHAD KAMMAR (a1) (a2) and MATIJA PRETNAR (a3)
Abstract
Abstract

We present a straightforward, sound, Hindley–Milner polymorphic type system for algebraic effects and handlers in a call-by-value calculus, which, to our surprise, allows type variable generalisation of arbitrary computations, and not just values. We first recall that the soundness of unrestricted call-by-value Hindley–Milner polymorphism is known to fail in the presence of computational effects such as reference cells and continuations, and that many programming examples can be recast to use effect handlers instead of these effects. After presenting the calculus and its soundness proof, formalised in Twelf, we analyse the expressive power of effect handlers with respect to state effects. We conjecture handlers alone cannot express reference cells, but show they can simulate dynamically scoped state, establishing that dynamic binding also does not need a value restriction.

Copyright
Linked references
Hide All

This list contains references from the content that can be linked to their source. For a full set of references and notes please see the PDF or HTML where available.

D. Ahman & S. Staton (2013) Normalization by evaluation and algebraic effects. Electr. Notes Theor. Comput. Sci. 298, 5169.

A. Bauer & M. Pretnar (2014) An effect system for algebraic effects and handlers. Log. Methods Comput. Sci. 10 (4:9), pp. 129.

A. Bauer & M. Pretnar (2015) Programming with algebraic effects and handlers. J. Log. Algebr. Meth. Program. 84 (1), 108123.

N. Benton , A. Kennedy & G. Russell (1998) Compiling standard ML to java bytecodes. In Proceedings of the 3rd ACM SIGPLAN International Conference on Functional Programming (ICFP '98), Baltimore, Maryland, USA, September 27–29, 1998, M. Felleisen , P. Hudak & C. Queinnec (eds), ACM, pp. 129140.

E. Brady (2013) Programming and reasoning with algebraic effects and dependent types. In Proceedings of ACM SIGPLAN International Conference on Functional Programming, ICFP'13, Boston, MA, USA, September 25–27, 2013, G. Morrisett & T. Uustalu (eds), ACM, pp. 133144.

L. Cardelli & J. C. Mitchell (1991) Operations on records. Math. Struct. Comput. Sci. 1 (1), 348.

R. Cartwright & M. Felleisen (1994) Extensible denotational language specifications. In Proceedings of International Conference TACS '94 on Theoretical Aspects of Computer Software, Sendai, Japan, April 19–22, 1994, M. Hagiya & J. C. Mitchell (eds). Lecture Notes in Computer Science, vol. 789. Springer pp. 244272.

M. Felleisen (1991) On the expressive power of programming languages. Sci. Comput. Program. 17 (1–3), 3575.

A. Filinski (1994) Representing monads. In Conference Record of POPL'94: 21st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Portland, Oregon, USA, January 17–21, 1994, H.-J. Boehm , B. Lang & D. M. Yellin (eds), ACM Press, pp. 446457.

J. Garrigue (2015) A certified implementation of ML with structural polymorphism and recursive types. Math. Struct. Comput. Sci. 25 (4), 867891.

M. J. C. Gordon , R. Milner & C. P. Wadsworth (1979) Edinburgh LCF. Lecture Notes in Computer Science, vol. 78. Berlin: Springer.

C. A. Gunter , D. Rémy & J. G. Riecke (1995) A generalization of exceptions and control in ML-like languages. In FPCA. ACM, pp. 1223

P. Hancock & A. Setzer (2000) Interactive programs in dependent type theory. In Proceedings of the 14th Annual Conference of the EACSL on Computer Science Logic, Fischbachau, Germany, August 21–26, 2000, P. Clote & H. Schwichtenberg (eds), Lecture Notes in Computer Science, vol. 1862. Springer, pp. 317331

R. Harper & M. Lillibridge (1993b) Polymorphic type assignment and CPS conversion. Lisp Symbolic Comput. 6 (3–4), 361380.

R. Harper & J. C. Mitchell (1993) On the type structure of standard ML. ACM Trans. Program. Lang. Syst. 15 (2), 211252.

D. Hillerström & S. Lindley (2016) Liberating effects with rows and handlers. In Proceedings of the 1st International Workshop on Type-Driven Development, September 2016, J. Chapman & W. Swierstra (eds), ACM, pp. 1527.

M. Hyland , G. D. Plotkin & J. Power (2006) Combining effects: Sum and tensor. Theor. Comput. Sci. 357 (1–3), 7099.

G. Jaber & N. Tzevelekos (2016) Trace semantics for polymorphic references. In Proceedings of the 31st Annual ACM/IEEE Symposium on Logic in Computer Science (LICS '16). ACM, New York, NY, USA, 585594. DOI: https://doi.org/10.1145/2933575.2934509

S. Katsumata (2013) Relating computational effects by ⊤⊤-lifting. Inf. Comput. 222, 228246.

S. Katsumata (2014) Parametric effect monads and semantics of effect systems. In Proceedings of the 41st Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL '14, San Diego, CA, USA, January 20–21, 2014, S. Jagannathan & P. Sewell (eds), ACM, pp. 633646.

O. Kiselyov & H. Ishii (2015) Freer monads, more extensible effects. In Proceedings of the 8th ACM SIGPLAN Symposium on Haskell, Haskell 2015, Vancouver, BC, Canada, September 3–4, 2015, B. Lippmeier (ed), ACM, pp. 94105.

P. J. Landin (1964) The mechanical evaluation of expressions. Comput. J. 6 (4), 308320.

D. Leijen (2017) Type directed compilation of row-typed algebraic effects. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL 2017), Gordon A. D. (ed), ACM, New York, NY, USA, pp. 486499.

P. B. Levy , J. Power & H. Thielecke (2003) Modelling environments in call-by-value programming languages. Inf. Comput. 185 (2), 182210.

M. Lillibridge (1999) Unchecked exceptions can be strictly more powerful than call/cc. Higher-Order Symbol. Comput. 12 (1), 75104.

S. Lindley & J. Cheney (2012) Row-based effect types for database integration. In TLDI. ACM, pp. 91102.

S. Lindley , C. McBride & C. McLaughlin (2017) Do be do be do. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL 2017), A. D. Gordon (ed), ACM, New York, NY, USA, pp. 500514.

P.-A. Melliès (2010) Segal condition meets computational effects. In Proceedings of the 25th Annual IEEE Symposium on Logic in Computer Science, LICS 2010, 11–14 July 2010, Edinburgh, United Kingdom. IEEE Computer Society, pp. 150159.

R. Milner (1978) A theory of type polymorphism in programming. J. Comput. Syst. Sci. 17 (3), 348375.

E. Moggi (1991) Notions of computation and monads. Inf. Comput. 93 (1), 5592.

L. Moreau (1998) A syntactic theory of dynamic binding. Higher-order and Symbolic Computation 11 (3), 233279.

G. Munch-Maccagnoni (2009) Focalisation and classical realisability. In Computer Science Logic '09, E. Grädel & R. Kahle (eds), Lecture Notes in Computer Science, vol. 5771. Heidelberg: Springer, pp. 409423.

A. Ohori (1989) A simple semantics for ML polymorphism. In Proceedings of the 4th International Conference on Functional Programming Languages and Computer Architecture, FPCA 1989, London, UK, September 11–13, 1989, J. E. Stoy (ed), ACM, pp. 281292.

A. Ohori (1992) A compilation method for ML-style polymorphic record calculi. In Proceedings of the 19th ACM SIGPLAN-SIGACT symposium on Principles of programming languages (POPL '92), January 19–22, 1992, R. Sethi (ed), ACM, New York, NY, USA, pp. 154165.

A. Ohori (1995) A polymorphic record calculus and its compilation. ACM Trans. Program. Lang. Syst. 17 (6), 844895.

G. D. Plotkin (1977) LCF considered as a programming language. Theor. Comput. Sci. 5 (3), 223255.

G. D. Plotkin & J. Power (2003) Algebraic operations and generic effects. Appl. Categorical Struct. 11 (1), 6994.

G. D. Plotkin & M. Pretnar (2013) Handling algebraic effects. Logical Methods in Comput. Sci. 9 (4).

M. Pretnar (2014) Inferring algebraic effects. Log. Methods Comput. Sci. 10 (3).

M. Pretnar (2015) An introduction to algebraic effects and handlers. invited tutorial paper. Electr. Notes Theor. Comput. Sci. 319, 1935.

J. C. Reynolds (1974) Towards a theory of type structure. In Programming Symposium, Proceedings Colloque Sur La Programmation. London, UK: Springer-Verlag, pp. 408423.

J. C. Reynolds (1984) Polymorphism is not set-theoretic. In Proceedings of Semantics of Data Types, International Symposium, Sophia-Antipolis, France, June 27–29, 1984, G. Kahn , D. B. MacQueen & G. D. Plotkin (eds), Lecture Notes in Computer Science, vol. 173. Springer. pp. 145156.

D. S. Scott (1993) A type-theoretical alternative to ISWIM, CUCH, OWHY. Theor. Comput. Sci. 121 (1&2), 411440.

R. Sethi (ed). (1992) Proceedings of the 19th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. January 19–22, 1992. ACM, New York, NY, USA.

C.-C. Shan (2007) A static simulation of dynamic delimited control. Higher-Order Symbol. Comput. 20 (4), 371401.

S. Staton (2009) Two cotensors in one: Presentations of algebraic theories for local state and fresh names. Electr. Notes Theor. Comput. Sci. 249, 471490.

S. Staton (2015) Algebraic effects, linearity, and quantum programming languages. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2015, Mumbai, India, January 15–17, 2015, S. K. Rajamani & D. Walker (eds), ACM, pp. 395406.

W. Swierstra (2008) Data types à la carte. J. Funct. Program. 18 (4), 423436.

M. Tofte (1990) Type inference for polymorphic references. Inf. Comput. 89 (1), 134.

A. P. Tolmach (1998) Optimizing ML using a hierarchy of monadic types. In Proceedings of the 2nd International Workshop on Types in Compilation, TIC '98, Kyoto, Japan, March 25–27, 1998, X. Leroy & A. Ohori (eds), Lecture Notes in Computer Science, vol. 1473. Springer, pp. 97115.

P. Wadler (1992) The essence of functional programming. In Proceedings of the 19th ACM SIGPLAN-SIGACT symposium on Principles of programming languages (POPL '92), January 19–22, 1992, R. Sethi (ed), ACM, New York, NY, USA, pp. 114.

P. Wadler & P. Thiemann (2003) The marriage of effects and monads. ACM Trans. Comput. Log. 4 (1), 132.

J. B. Wells (1999) Typability and type checking in System F are equivalent and undecidable. Ann. Pure Appl. Logic 98 (1–3), 111156.

A. K. Wright (1995) Simple imperative polymorphism. Lisp Symbol. Comput. 8 (4), 343355.

Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *
×
Type Description Title
UNKNOWN
Supplementary Materials

Kammar and Pretnar supplementary material
Kammar and Pretnar supplementary material 1

 Unknown (38 KB)
38 KB

Metrics

Full text views

Total number of HTML views: 0
Total number of PDF views: 18 *
Loading metrics...

Abstract views

Total abstract views: 125 *
Loading metrics...

* Views captured on Cambridge Core between 24th January 2017 - 26th March 2017. This data will be updated every 24 hours.