Choreographic programming is an emerging paradigm for programming distributed systems. In choreographic programming, the programmer describes the behavior of the entire system as a single, unified program -- a choreography -- which is then compiled to individual programs that run on each node, via a compilation step called endpoint projection. We present a new model for functional choreographic programming where choreographies are expressed as computations in a monad. Our model supports cutting-edge choreographic programming features that enable modularity and code reuse: in particular, it supports higher-order choreographies, in which a choreography may be passed as an argument to another choreography, and location-polymorphic choreographies, in which a choreography can abstract over nodes. Our model is implemented in a Haskell library, HasChor, which lets programmers write choreographic programs while using the rich Haskell ecosystem at no cost, bringing choreographic programming within reach of everyday Haskellers. Moreover, thanks to Haskell's abstractions, the implementation of the HasChor library itself is concise and understandable, boiling down endpoint projection to its short and simple essence.
翻译:编舞编程是一种新兴的分布式系统编程范式。在编舞编程中,程序员将整个系统的行为描述为单一统一的程序——即"编舞",随后通过称为"端点投影"的编译步骤,将该程序编译为在每个节点上运行的独立程序。我们提出了一种新的函数式编舞编程模型,其中编舞被表达为单子(Monad)中的计算。该模型支持前沿的编舞编程特性,能够实现模块化与代码复用:特别地,它支持高阶编舞(编舞可作为参数传递给另一编舞)和位置多态编舞(编舞可对节点进行抽象)。我们的模型以Haskell库HasChor实现,使程序员能够利用丰富的Haskell生态系统编写编舞程序(无需额外成本),从而让编舞编程为日常Haskell使用者所触手可及。此外,得益于Haskell的抽象机制,HasChor库自身的实现简洁且易于理解,将端点投影归结为简短而本质的核心。