Extending Monads with Pattern Matching

被引:0
|
作者
Petricek, Tomas [1 ]
Mycroft, Alan [1 ]
Syme, Don
机构
[1] Univ Cambridge, Cambridge CB2 1TN, England
关键词
D O I
暂无
中图分类号
TP3 [计算技术、计算机技术];
学科分类号
0812 ;
摘要
Sequencing of effectful computations can be neatly captured using monads and elegantly written using do notation. In practice such monads often allow additional ways of composing computations, which have to be written explicitly using combinators. We identify joinads, an abstract notion of computation that is stronger than monads and captures many such ad-hoc extensions. In particular, joinads are monads with three additional operations: one of type m a -> m b -> m (a, b) captures various forms of parallel composition, one of type m a -> m a -> m a that is inspired by choice and one of type m a -> m (m a) that captures oliasing of computations. Algebraically, the first two operations form a near-semiring with commutative multiplication. We introduce docase notation that can be viewed as a monadic version of case. Joinad laws imply various syntactic equivalences of programs written using docase that are analogous to equivalences about case. Examples of joinads that benefit from the notation include speculative parallelism, waiting for a combination of user interface events, but also encoding of validation rules using the intersection of parsers.
引用
收藏
页码:1 / +
页数:3
相关论文
共 50 条
  • [1] Extending Monads with Pattern Matching
    Petricek, Tomas
    Mycroft, Alan
    Syme, Don
    ACM SIGPLAN NOTICES, 2011, 46 (12) : 1 - 12
  • [2] Monads for the formalization of a pattern matching procedure
    Zhozhikashvili, A. V.
    PROGRAMMING AND COMPUTER SOFTWARE, 2014, 40 (03) : 117 - 127
  • [3] Monads for the formalization of a pattern matching procedure
    A. V. Zhozhikashvili
    Programming and Computer Software, 2014, 40 : 117 - 127
  • [4] Extending XQuery with a Pattern Matching Facility
    Fischer, Peter M.
    Garg, Aayush
    Esmaili, Kyumars Sheykh
    DATABASE AND XML TECHNOLOGIES, 2010, 6309 : 48 - 57
  • [5] Extending Graph Pattern Matching with Regular Expressions
    Wang, Xin
    Wang, Yang
    Xu, Yang
    Zhang, Ji
    Zhong, Xueyan
    DATABASE AND EXPERT SYSTEMS APPLICATIONS, DEXA 2020, PT II, 2020, 12392 : 111 - 129
  • [6] Qualitative research: extending the range with flexible pattern matching
    Ricarda B. Bouncken
    Yixin Qiu
    Noemi Sinkovics
    Wolfgang Kürsten
    Review of Managerial Science, 2021, 15 : 251 - 273
  • [7] Qualitative research: extending the range with flexible pattern matching
    Bouncken, Ricarda B.
    Qiu, Yixin
    Sinkovics, Noemi
    Kuersten, Wolfgang
    REVIEW OF MANAGERIAL SCIENCE, 2021, 15 (02) : 251 - 273
  • [8] Extending the matching facilities of Linda
    Wells, G
    Chalmers, A
    Clayton, P
    COORDINATION MODELS AND LANGUAGES, PROCEEDINGS, 2002, 2315 : 380 - 388
  • [9] Monads at the bottom, monads at the top, monads all over
    Nachtomy, Ohad
    BRITISH JOURNAL FOR THE HISTORY OF PHILOSOPHY, 2018, 26 (01) : 197 - 207
  • [10] PROBABILITY MONADS AS CODENSITY MONADS
    VAN BELLE, R. U. B. E. N.
    THEORY AND APPLICATIONS OF CATEGORIES, 2022, 38 : 811 - 842