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 条
  • [41] Focusing on Pattern Matching
    Krishnaswami, Neelakantan R.
    ACM SIGPLAN NOTICES, 2009, 44 (01) : 366 - 378
  • [42] Pattern matching in hypertext
    Amir, A
    Lewenstein, M
    Lewenstein, N
    ALGORITHMS AND DATA STRUCTURES, 1997, 1272 : 160 - 173
  • [43] Optimizing pattern matching
    Le Fessant, F
    Maranget, L
    ACM SIGPLAN NOTICES, 2001, 36 (10) : 26 - 37
  • [44] Refactoring pattern matching
    Wang, Meng
    Gibbons, Jeremy
    Matsuda, Kazutaka
    Hu, Zhenjiang
    SCIENCE OF COMPUTER PROGRAMMING, 2013, 78 (11) : 2216 - 2242
  • [45] Constrained Pattern Matching
    Choi, Yongwook
    Szpankowski, Wojciech
    ACM TRANSACTIONS ON ALGORITHMS, 2011, 7 (02)
  • [46] Extending AgreementMakerLight to Perform Holistic Ontology Matching
    Silva, Marta Contreiras
    Faria, Daniel
    Pesquita, Catia
    SEMANTIC WEB: ESWC 2022 SATELLITE EVENTS, 2022, 13384 : 31 - 35
  • [47] Extending Matching Model for Semantic Web Services
    Zohali, Alireza
    Zamanifar, Kamran
    Nematbakhsh, Naser
    2009 INTERNATIONAL CONFERENCE ON COMPUTER ENGINEERING AND TECHNOLOGY, VOL I, PROCEEDINGS, 2009, : 276 - +
  • [48] Facet Annotation by Extending CNN with a Matching Strategy
    Wu, Bei
    Wei, Bifan
    Liu, Jun
    Guo, Zhaotong
    Zheng, Yuanhao
    Chen, Yihe
    NEURAL COMPUTATION, 2018, 30 (06) : 1647 - 1672
  • [49] ANALYZING THE PERFORMANCE DIFFERENCES BETWEEN PATTERN MATCHING AND COMPRESSED PATTERN MATCHING ON TEXTS
    Erdogan, Cihat
    Bulus, H. Nusret
    Diri, Banu
    2013 INTERNATIONAL CONFERENCE ON ELECTRONICS, COMPUTER AND COMPUTATION (ICECCO), 2013, : 135 - 138
  • [50] When are enriched strong monads double exponential monads?
    Townsend, Christopher
    BULLETIN OF THE BELGIAN MATHEMATICAL SOCIETY-SIMON STEVIN, 2016, 23 (02) : 311 - 319