How to Keep Your Neighbours in Order

被引:6
|
作者
McBride, Conor [1 ]
机构
[1] Univ Strathclyde, Glasgow, Lanark, Scotland
来源
ICFP'14: PROCEEDINGS OF THE 2014 ACM SIGPLAN INTERNATIONAL CONFERENCE ON FUNCTIONAL PROGRAMMING | 2014年
关键词
dependent types; Agda; ordering; balancing; sorting;
D O I
10.1145/2628136.2628163
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
I present a datatype-generic treatment of recursive container types whose elements are guaranteed to be stored in increasing order, with the ordering invariant rolled out systematically. Intervals, lists and binary search trees are instances of the generic treatment. On the journey to this treatment, I report a variety of failed experiments and the transferable learning experiences they triggered. I demonstrate that a total element ordering is enough to deliver insertion and flattening algorithms, and show that (with care about the formulation of the types) the implementations remain as usual. Agda's instance arguments and pattern synonyms maximize the proof search done by the typechecker and minimize the appearance of proofs in program text, often eradicating them entirely. Generalizing to indexed recursive container types, invariants such as size and balance can be expressed in addition to ordering. By way of example, I implement insertion and deletion for 2-3 trees, ensuring both order and balance by the discipline of type checking.
引用
收藏
页码:297 / 309
页数:13
相关论文
共 7 条
  • [1] How to Keep Your Neighbours in Order
    McBride, Conor
    ACM SIGPLAN NOTICES, 2014, 49 (09) : 297 - 309
  • [2] How to name and order convex polyhedra
    Voytekhovsky, Yury L.
    ACTA CRYSTALLOGRAPHICA A-FOUNDATION AND ADVANCES, 2016, 72 : 582 - 585
  • [3] How do people order stimuli?
    Simon Kemp
    Randolph C. Grace
    Attention, Perception, & Psychophysics, 2014, 76 : 1847 - 1859
  • [4] How do people order stimuli?
    Kemp, Simon
    Grace, Randolph C.
    ATTENTION PERCEPTION & PSYCHOPHYSICS, 2014, 76 (06) : 1847 - 1859
  • [5] Efficient sorting in an inverse order picking considering how to consolidate apparel items
    Yoda J.
    Irohara T.
    Hamada M.
    Ikeda D.
    Kawai W.
    Aoki T.
    Journal of Japan Industrial Management Association, 2020, 71 (01) : 35 - 46
  • [6] Compiling Higher-Order Specifications to SMT Solvers: How to Deal with Rejection Constructively
    Daggitt, Matthew L.
    Atkey, Robert
    Kokke, Wen
    Komendantskaya, Ekaterina
    Arnaboldi, Luca
    PROCEEDINGS OF THE 12TH ACM SIGPLAN INTERNATIONAL CONFERENCE ON CERTIFIED PROGRAMS AND PROOFS, CPP 2023, 2023, : 102 - 120
  • [7] How Product Order Affects Market Identity: Repertoire Ordering in the U.S. Opera Market
    Kim, Bo Kyung
    Jensen, Michael
    ADMINISTRATIVE SCIENCE QUARTERLY, 2011, 56 (02) : 238 - 256