The recent notion of graded modal types provides a framework for extending type theories with fine-grained data-flow reasoning. The Granule language explores this idea in the context of linear types. In this practical setting, we observe that the presence of graded modal types can introduce an additional impediment when programming: when composing programs, it is often necessary to 'distribute' data types over graded modalities, and vice versa. In this paper, we show how to automatically derive these distributive laws as combinators for programming. We discuss the implementation and use of this automated deriving procedure in Granule, providing easy access to these distributive combinators. This work is also applicable to Linear Haskell (which retrofits Haskell with linear types via grading) and we apply our technique there to provide the same automatically derived combinators. Along the way, we discuss interesting considerations for pattern matching analysis via graded linear types. Lastly, we show how other useful structural combinators can also be automatically derived.
翻译:最近分级模式类型的概念为扩展类型理论提供了一个框架, 并带有细微区分的数据流推理。 Granule 语言在线性类型的背景下探索了这一想法。 在这种实际环境下, 我们观察到, 分级模式类型的存在可能会在编程中带来额外的障碍: 当编程时, 往往有必要将数据类型“ 分布” 用于分级模式, 而反之亦然。 在本文中, 我们展示了如何自动生成这些分配法作为编程的组合器。 我们讨论了Granule 中这种自动生成程序的实施和使用, 提供了对这些分流组合器的方便访问 。 这项工作也适用于Linear Haskell (通过分级将Haskell 转换成线性类型), 我们在那里应用我们的技术来提供相同的自动生成的调试器。 顺便一提一下, 我们讨论通过分级线型线型类型进行模式匹配分析的有趣考虑。 最后, 我们展示了其他有用的结构梳子如何被自动生成 。