Type-level web APIs with Servant: an exercise in domain-specific generic programming

Alp Mestanogullari, Sönke Hahn, Julian K. Arni, Andres Löh
{"title":"Type-level web APIs with Servant: an exercise in domain-specific generic programming","authors":"Alp Mestanogullari, Sönke Hahn, Julian K. Arni, Andres Löh","doi":"10.1145/2808098.2808099","DOIUrl":null,"url":null,"abstract":"We describe the design and motivation for Servant, an extensible, type-level DSL for describing Web APIs. Servant APIs are Haskell types. An API type can be interpreted in several different ways: as a server that processes requests, interprets them and dispatches them to appropriate handlers; as a client that can correctly query the endpoints of the API; as systematic documentation for the API; and more. Servant is fully extensible: the API language can be augmented with new constructs, and new interpretations can be defined. The key Haskell features making all this possible are data kinds, (open) type families and (open) type classes. The techniques we use are reminiscent of general-purpose generic programming. However, where most generic programming libraries are interested in automatically deriving programs for a large class of datatypes from many different domains, we are only interested in a small class of datatypes that is used in the DSL for describing APIs.","PeriodicalId":423582,"journal":{"name":"Proceedings of the 11th ACM SIGPLAN Workshop on Generic Programming","volume":"23 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2015-08-30","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"9","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Proceedings of the 11th ACM SIGPLAN Workshop on Generic Programming","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/2808098.2808099","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 9

Abstract

We describe the design and motivation for Servant, an extensible, type-level DSL for describing Web APIs. Servant APIs are Haskell types. An API type can be interpreted in several different ways: as a server that processes requests, interprets them and dispatches them to appropriate handlers; as a client that can correctly query the endpoints of the API; as systematic documentation for the API; and more. Servant is fully extensible: the API language can be augmented with new constructs, and new interpretations can be defined. The key Haskell features making all this possible are data kinds, (open) type families and (open) type classes. The techniques we use are reminiscent of general-purpose generic programming. However, where most generic programming libraries are interested in automatically deriving programs for a large class of datatypes from many different domains, we are only interested in a small class of datatypes that is used in the DSL for describing APIs.
带有Servant的类型级web api:特定领域泛型编程的练习
我们描述了Servant的设计和动机,这是一种用于描述Web api的可扩展类型级DSL。服务api是Haskell类型。API类型可以以几种不同的方式解释:作为处理请求的服务器,解释它们并将它们分派给适当的处理程序;作为能够正确查询API端点的客户端;作为API的系统文档;和更多。Servant是完全可扩展的:API语言可以用新的结构进行扩展,并且可以定义新的解释。使这一切成为可能的关键Haskell特性是数据类型、(开放)类型族和(开放)类型类。我们使用的技术让人想起通用泛型编程。然而,大多数泛型编程库都对从许多不同领域自动派生大量数据类型的程序感兴趣,而我们只对DSL中用于描述api的一小类数据类型感兴趣。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术官方微信