Declarative Pearl: Deriving Monadic Quicksort

被引:2
作者
Mu, Shin-Cheng [1 ]
Chiang, Tsung-Ju [2 ]
机构
[1] Acad Sinica, Taipei, Taiwan
[2] Natl Taiwan Univ, Taipei, Taiwan
来源
FUNCTIONAL AND LOGIC PROGRAMMING, FLOPS 2020 | 2020年 / 12073卷
关键词
Monads; Program derivation; Equational reasoning; Nondeterminism; State; Quicksort;
D O I
10.1007/978-3-030-59025-3_8
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
To demonstrate derivation of monadic programs, we present a specification of sorting using the non-determinism monad, and derive pure quicksort on lists and state-monadic quicksort on arrays. In the derivation one may switch between point-free and pointwise styles, and deploy techniques familiar to functional programmers such as pattern matching and induction on structures or on sizes. Derivation of stateful programs resembles reasoning backwards from the postcondition.
引用
收藏
页码:124 / 138
页数:15
相关论文
共 14 条
  • [11] Kiselyov O., 2013, How to restrict a monad without breaking it: the winding road to the Set monad
  • [12] Freer Monads, More Extensible Effects
    Kiselyov, Oleg
    Ishii, Hiromi
    [J]. ACM SIGPLAN NOTICES, 2015, 50 (12) : 94 - 105
  • [13] MOGGI E, 1989, FOURTH ANNUAL SYMPOSIUM ON LOGIC IN COMPUTER SCIENCE, P14
  • [14] Handling Local State with Global State
    Pauwels, Koen
    Schrijvers, Tom
    Mu, Shin-Cheng
    [J]. MATHEMATICS OF PROGRAM CONSTRUCTION, 2019, 11825 : 18 - 44