论文标题
功能语言中流利的API(完整版)
Fluent APIs in Functional Languages (full version)
论文作者
论文摘要
Fluent API是面向对象的图案,用于优雅的API和嵌入式DSL。智能流利的API可以在编译时强制执行API协议或DSL语法。由于流利的API设计通常依赖于功能过载,因此在功能编程语言中很难实现它们。我们展示了如何使用参数多态性和类型推理而不是过载来编写功能流利的API。我们的设计支持所有常规和确定性的无上下文API协议及其他方面。
Fluent API is an object-oriented pattern for elegant APIs and embedded DSLs. A smart fluent API can enforce the API protocol or DSL syntax at compile time. As fluent API designs typically rely on function overloading, they are hard to realize in functional programming languages. We show how to write functional fluent APIs using parametric polymorphism and type inference instead of overloading. Our designs support all regular and deterministic context-free API protocols and beyond.