Системы эффектов как механизм управления контекстными свободными переменными: единый взгляд
https://doi.org/10.15514/ISPRAS-2026-38(4)-4
Аннотация
Системы эффектов поднимают сведения о вычислительных эффектах программы на уровень типов: они уточняют границы абстракций и позволяют компилятору проверять, что эффектное вычисление выполняется в поддерживающем его контексте. Тем не менее статическое отслеживание эффектов пока не стало повсеместной практикой: ведущие подходы – строки эффектов, возможности (capabilities) и модальные типы – обычно описываются с помощью различного технического аппарата, и проектировщику языка трудно увидеть общую картину пространства решений. Мы предлагаем объединяющий взгляд: система эффектов – это механизм управления контекстными свободными переменными вычисления – зависимостями, которые не передаются обычными аргументами, а должны разрешаться контекстом исполнения. Каждая такая переменная проходит жизненный цикл из двух фаз: она возникает ожидающей – с неразрешённым требованием к контексту; после разрешения зависимость может сохраниться внутри значения – либо буквально, посредством захвата свидетельства, либо в широком смысле, как зависимость от контекста построения. Семейства систем эффектов различаются тем, какие фазы и переходы этого цикла они поддерживают и как отражают их в типах. Классические строковые системы держат переменные ожидающими и не выражают захват. Системы на основе возможностей допускают захват, но удерживают захваченную переменную в предоставившем её контексте средствами escape-анализа. Модальные системы вместо запрета повторно освобождают утёкшую переменную, снова выставляя её в типе как требование к контексту. Сравнение семейств вдоль единой оси жизненного цикла показывает, что выбор поддерживаемых переходов предопределяет остальные черты дисциплины – от необходимого вида полиморфизма до мест сосредоточения аннотаций – и тем самым даёт проектировщику языка карту пространства решений.
Об авторе
Андрей Сергеевич СТОЯНРоссия
Аспирант департамента информатики Национального исследовательского университета «Высшая школа экономики» (Санкт-Петербург). Сфера научных интересов: проектирование языков программирования, системы типов, системы эффектов.
Список литературы
1. Kiselyov O., Sabry A., Swords C. Extensible effects: An alternative to monad transformers, ACM SIGPLAN Notices, 2013, vol. 48, no. 12, pp. 59-70. DOI: 10.1145/2578854.2503791.
2. Plotkin G.D., Pretnar M. Handling algebraic effects, Logical methods in computer science, 2013, vol. 9. DOI: 10.2168/LMCS-9(4:23)2013.
3. Sivaramakrishnan K.C., Leijen D., Pretnar M., Schrijvers T. Algebraic effect handlers go mainstream (dagstuhl seminar 18172). In Dagstuhl reports, Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik, 2018. DOI: 10.4230/DagRep.8.4.104.
4. Phipps-Costin L. et al. Continuing WebAssembly with effect handlers, Proceedings of the ACM on Programming Languages, 2023, vol. 7, no. OOPSLA2, pp. 460-485. DOI: 10.1145/3622814.
5. Leijen D. Structured asynchrony with algebraic effects. In Proceedings of the 2nd ACM SIGPLAN in-ternational workshop on type-driven development, 2017, pp. 16-29. DOI: 10.1145/3122975.3122977.
6. Liang S., Hudak P., Jones M. Monad transformers and modular interpreters. In Proceedings of the 22nd ACM SIGPLAN-SIGACT symposium on principles of programming languages, 1995, pp. 333-343. DOI: 10.1145/199448.199528.
7. Schrijvers T., Piróg M., Wu N., Jaskelioff M. Monad transformers and modular algebraic effects: What binds them together. In Proceedings of the 12th ACM SIGPLAN international symposium on haskell, 2019, pp. 98-113. DOI: 10.1145/3331545.3342595.
8. Berg B. van den, Schrijvers T. A framework for higher-order effects & handlers, Science of Comput-er Programming, 2024, vol. 234, p. 103086. DOI: 10.1016/j.scico.2024.103086.
9. Lucassen J.M., Gifford D.K. Polymorphic effect systems. In Proceedings of the 15th ACM SIGPLAN-SIGACT symposium on principles of programming languages, 1988, pp. 47-57. DOI: 10.1145/73560.73564.
10. Talpin J.-P., Jouvelot P. The type and effect discipline, Information and Computation, 1994, vol. 111, no. 2, pp. 245-296. DOI: 10.1006/inco.1994.1046.
11. Sivaramakrishnan K.C., Dolan S., White L., Kelly T., Jaffer S., Madhavapeddy A. Retrofitting effect handlers onto OCaml. In PLDI ’21: 42nd ACM SIGPLAN international conference on programming language design and implementation, ACM, 2021, pp. 206-221. DOI: 10.1145/3453483.3454039.
12. Leijen D. Koka: Programming with row polymorphic effect types. In Proceedings of the 5th work-shop on mathematically structured functional programming (MSFP 2014), 2014, pp. 100-126. DOI: 10.4204/EPTCS.153.8.
13. Brachthäuser J.I., Schuster P., Lee E., Boruch-Gruszecki A. Effects, capabilities, and boxes: From scope-based reasoning to type-based reasoning and back, Proceedings of the ACM on Programming Languages, 2022, vol. 6, no. OOPSLA1, pp. 1-30. DOI: 10.1145/3527320.
14. Boruch-Gruszecki A., Odersky M., Lee E., Lhoták O., Brachthäuser J. Capturing types, ACM Trans-actions on Programming Languages and Systems, 2023, vol. 45, no. 4, pp. 1-52. DOI: 10.1145/3618003.
15. Tang W., White L., Dolan S., Hillerström D., Lindley S., Lorenzen A. Modal effect types, Proceedings of the ACM on Programming Languages, 2025, vol. 9, no. OOPSLA1, pp. 1130-1157. DOI: 10.1145/3720476.
16. Odersky M., Boruch-Gruszecki A., Brachthäuser J.I., Lee E., Lhoták O. Safer exceptions for scala. In Proceedings of the 12th ACM SIGPLAN international symposium on scala, 2021, pp. 1-11. DOI: 10.1145/3486610.3486893.
17. Stoyan A. Modern effect systems overview. In 2024 Ivannikov ISPRAS OPEN conference (ISPRAS), IEEE, 2024, pp. 1-7. DOI: 10.1109/ISPRAS64596.2024.10899144.
18. Park Y.G., Goldberg B. Escape analysis on lists. In Proceedings of the ACM SIGPLAN 1992 confer-ence on programming language design and implementation, 1992, pp. 116-127. DOI: 10.1145/143095.143125.
19. Hannan J. A type-based escape analysis for functional languages, Journal of functional programming, 1998, vol. 8, no. 3, pp. 239-273. DOI: 10.1017/S0956796898003025.
20. Petricek T., Orchard D., Mycroft A. Coeffects: A calculus of context-dependent computation. In Pro-ceedings of the 19th ACM SIGPLAN international conference on functional programming (ICFP ’14), ACM, 2014, pp. 123-135. DOI: 10.1145/2628136.2628160.
21. Gaster B.R., Jones M.P. A polymorphic type system for extensible records and variants, Department of Computer Science, University of Nottingham, 1996. Available at: https://web.cecs.pdx.edu/~mpj/pubs/96-3.pdf, accessed 25.07.2026.
22. Gosling J., Joy B., Steele G., Bracha G. Java Language and Virtual Machine Specifications, Addison-Wesley Professional, 2000. Available at: https://docs.oracle.com/javase/specs/, accessed 25.07.2026.
23. Venners B., Eckel B., Hejlsberg A. The trouble with checked exceptions, 2003. Available at: https://www.artima.com/articles/the-trouble-with-checked-exceptions, accessed 27.07.2026.
24. Hillerström D., Lindley S. Liberating effects with rows and handlers. In Proceedings of the 1st inter-national workshop on type-driven development, 2016, pp. 15-27. DOI: 10.1145/2976022.2976033.
25. Madsen M., Pol J. van de Polymorphic types and effects with Boolean unification, Proceedings of the ACM on Programming Languages, 2020, vol. 4, no. OOPSLA, pp. 1-29. DOI: 10.1145/3428222.
26. Unison Computing Abilities in Unison, 2024. Available at: https://www.unison-lang.org/docs/fundamentals/abilities/, accessed 27.07.2026.
27. Biernacki D., Piróg M., Polesiuk P., Sieczkowski F. Binders by day, labels by night: Effect instances via lexically scoped handlers, Proceedings of the ACM on Programming Languages, 2020, vol. 4, no. POPL, pp. 1-29. DOI: 10.1145/3371116.
28. Zhang Y., Salvaneschi G., Beightol Q., Liskov B., Myers A.C. Accepting blame for safe tunneled ex-ceptions, ACM SIGPLAN Notices, 2016, vol. 51, no. 6, pp. 281-295. DOI: 10.1145/2980983.2908086.
29. Zhang Y., Salvaneschi G., Myers A.C. Handling bidirectional control flow, Proceedings of the ACM on Programming Languages, 2020, vol. 4, no. OOPSLA, pp. 1-30. DOI: 10.1145/3428207.
30. Xie N., Leijen D. Generalized evidence passing for effect handlers: Efficient compilation of effect handlers to c, Proceedings of the ACM on Programming Languages, 2021, vol. 5, no. ICFP, pp. 1-30. DOI: 10.1145/3473576.
31. Lewis J.R., Launchbury J., Meijer E., Shields M.B. Implicit parameters: Dynamic scoping with static types. In Proceedings of the 27th ACM SIGPLAN-SIGACT symposium on principles of programming languages, 2000, pp. 108-118. DOI: 10.1145/325694.325708.
32. Odersky M. et al. The scala language specification, Lausanne, Switzerland, 2004. Available at: https://www.scala-lang.org/files/archive/spec/, accessed 25.07.2026.
33. Brachthäuser J.I., Schuster P., Ostermann K. Effects as capabilities: Effect handlers and lightweight effect polymorphism, Proceedings of the ACM on Programming Languages, 2020, vol. 4, no. OOPSLA, pp. 1 30. DOI: 10.1145/3428194.
34. Osvald L., Essertel G., Wu X., Alayón L.I.G., Rompf T. Gentrification gone too far? Affordable 2nd-class values for fun and (co-) effect, ACM SIGPLAN Notices, 2016, vol. 51, no. 10, pp. 234-251. DOI: 10.1145/3022671.2984009.
35. Tofte M., Talpin J.-P. Region-based memory management, Information and Computation, 1997, vol. 132, no. 2, pp. 109-176. DOI: 10.1006/inco.1996.2613.
36. Matsakis N.D., Klock F.S. The Rust language. In Proceedings of the 2014 ACM SIGAda annual con-ference on high integrity language technology, 2014, pp. 103-104. DOI: 10.1145/2663171.2663188.
37. The ZIO contributors ZIO: Type-safe, composable asynchronous and concurrent programming for Scala, 2024. Available at: https://zio.dev/, accessed 27.07.2026.
38. Serrano A., Akhin M., Bobko N., Gorbunov I., Zarechenskii M., Zharkov D. Context parameters (KEEP-367), 2024. Available at: https://github.com/Kotlin/KEEP/blob/master/proposals/context-parameters.md, accessed 25.07.2026.
39. Oliveira B.C., Moors A., Odersky M. Type classes as objects and implicits, ACM Sigplan Notices, 2010, vol. 45, no. 10, pp. 341-360. DOI: 10.1145/1932682.1869489.
40. Lorenzen A., White L., Dolan S., Eisenberg R.A., Lindley S. Oxidizing OCaml with modal memory management, Proceedings of the ACM on Programming Languages, 2024, vol. 8, no. ICFP, pp. 485-514. DOI: 10.1145/3674642.
41. Akhin M., Belyaev M. Kotlin language specification, Kotlin Language Specification, 2021. Available at: https://kotlinlang.org/spec/, accessed 25.07.2026.
42. Tang W., Lindley S. Rows and capabilities as modal effects, Proc. ACM Program. Lang., 2026, vol. 10, no. POPL, pp. 923-950. DOI: 10.1145/3776674.
43. Nanevski A., Pfenning F., Pientka B. Contextual modal type theory, ACM Transactions on Computa-tional Logic, 2008, vol. 9, no. 3, pp. 1-49. DOI: 10.1145/1352582.1352591.
44. Zyuzin N., Nanevski A. Contextual modal types for algebraic effects and handlers, Proceedings of the ACM on Programming Languages, 2021, vol. 5, no. ICFP, pp. 1-29. DOI: 10.1145/3473580.
45. Lindley S., McBride C., McLaughlin C. Do be do be do. In Proceedings of the 44th ACM SIGPLAN symposium on principles of programming languages, 2017, pp. 500-514. DOI: 10.1145/3009837.3009897.
46. Convent L., Lindley S., McBride C., McLaughlin C. Doo bee doo bee doo, Journal of Functional Pro-gramming, 2020, vol. 30, p. e9. DOI: 10.1017/S0956796820000039.
47. Launchbury J., Peyton Jones S.L. State in Haskell, Lisp and symbolic computation, 1995, vol. 8, no. 4, pp. 293-341. DOI: 10.1007/BF01018827.
48. Xie N., Cong Y., Ikemori K., Leijen D. First-class names for effect handlers, Proceedings of the ACM on Programming Languages, 2022, vol. 6, no. OOPSLA2, pp. 30-59. DOI: 10.1145/3563289.
49. Odersky M., Boruch-Gruszecki A., Lee E., Brachthäuser J., Lhoták O. Scoped capabilities for poly-morphic effects, arXiv preprint arXiv:2207.03402, 2022. DOI: 10.48550/arXiv.2207.03402.
50. Müller M., Schuster P., Starup J.L., Ostermann K., Brachthäuser J.I. From capabilities to regions: Ena-bling efficient compilation of lexical effect handlers, Proceedings of the ACM on Programming Lan-guages, 2023, vol. 7, no. OOPSLA2, pp. 941-970. DOI: 10.1145/3622831.
51. Stoyan A.S. Type-based escape analysis with existential lifetimes, Trudy ISP RAN / Proc. ISP RAS, 2026, vol. 38, no. 1, pp. 71-78. DOI: 10.15514/ISPRAS-2026-38(1)-6.
52. Gaboardi M., Katsumata S., Orchard D., Breuvart F., Uustalu T. Combining effects and coeffects via grading. In Proceedings of the 21st ACM SIGPLAN international conference on functional program-ming (ICFP ’16), Association for Computing Machinery, New York, NY, USA, 2016, pp. 476-489. DOI: 10.1145/2951913.2951939.
53. Marino D., Millstein T. A generic type-and-effect system. In Proceedings of the 4th international workshop on types in language design and implementation (TLDI ’09), Association for Computing Machinery, New York, NY, USA, 2009, pp. 39-50. DOI: 10.1145/1481861.1481868.
54. Wadler P., Thiemann P. The marriage of effects and monads, ACM Transactions on Computational Logic (TOCL), 2003, vol. 4, no. 1, pp. 1-32. DOI: 10.1145/601775.601776.
Рецензия
Для цитирования:
СТОЯН А.С. Системы эффектов как механизм управления контекстными свободными переменными: единый взгляд. Труды Института системного программирования РАН. 2026;38(4):69-88. https://doi.org/10.15514/ISPRAS-2026-38(4)-4
For citation:
STOYAN A.S. Effect Systems as a Mechanism for Managing Contextual Free Variables: A Unifying Perspective. Proceedings of the Institute for System Programming of the RAS (Proceedings of ISP RAS). 2026;38(4):69-88. https://doi.org/10.15514/ISPRAS-2026-38(4)-4






