函数式语言中的流畅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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。