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 条
  • [31] Multiple Pattern Matching
    Fulwider, Stephen
    Mukherjee, Amar
    PROCEEDINGS OF THE SECOND INTERNATIONAL CONFERENCES ON PERVASIVE PATTERNS AND APPLICATIONS (PATTERNS 2010), 2010, : 78 - 83
  • [32] Pattern Matching in MOLA
    Sostaks, Agris
    DATABASES AND INFORMATION SYSTEMS, 2010, : 309 - 324
  • [33] Outsourced pattern matching
    Sebastian Faust
    Carmit Hazay
    Daniele Venturi
    International Journal of Information Security, 2018, 17 : 327 - 346
  • [34] On Spatial Pattern Matching
    Fang, Yixiang
    Cheng, Reynold
    Cong, Gao
    Mamoulis, Nikos
    Li, Yun
    2018 IEEE 34TH INTERNATIONAL CONFERENCE ON DATA ENGINEERING (ICDE), 2018, : 293 - 304
  • [35] On Pattern Matching With Swaps
    Chedid, Fouad B.
    2013 ACS INTERNATIONAL CONFERENCE ON COMPUTER SYSTEMS AND APPLICATIONS (AICCSA), 2013,
  • [36] Outsourced Pattern Matching
    Faust, Sebastian
    Hazay, Carmit
    Venturi, Daniele
    AUTOMATA, LANGUAGES, AND PROGRAMMING, PT II, 2013, 7966 : 545 - 556
  • [37] Pattern Matching and Bisimulation
    Given-Wilson, Thomas
    Gorla, Daniele
    COORDINATION MODELS AND LANGUAGES, COORDINATION 2013, 2013, 7890 : 60 - 74
  • [38] Juggling with pattern matching
    Cardinal, J
    Kremer, S
    Langerman, S
    THEORY OF COMPUTING SYSTEMS, 2006, 39 (03) : 425 - 437
  • [39] Pattern matching with swaps
    Amir, A
    Aumann, Y
    Landau, GM
    Lewenstein, M
    Lewenstein, N
    JOURNAL OF ALGORITHMS-COGNITION INFORMATICS AND LOGIC, 2000, 37 (02): : 247 - 266
  • [40] Palindrome pattern matching
    Tomohiro, I
    Inenaga, Shunsuke
    Takeda, Masayuki
    THEORETICAL COMPUTER SCIENCE, 2013, 483 : 162 - 170