引用T-R · 2018-10
“linear types are on their way[1], with exactly this usecase in mind.”
说明 Haskell 的线性类型正为这一用途推进
把线性性挂在函数箭头上,让线性类型兼容地融入 GHC
论文设计了一个线性类型系统,目标是向后兼容并让库代码同时服务线性与非线性用户:不把类型分成线性与非线性两套,而是把线性性附着在函数箭头上。作者在 GHC 中实现了该系统,并展示两类应用:带纯接口的可变数据,以及在 I/O 函数中强制执行协议。
评论者把它当作 Haskell 线性类型的设计依据来引用,用于资源清理与资源安全等场景,并指出具体章节(线性值与 monad、borrow 机制)来解答细节问题。
“linear types are on their way[1], with exactly this usecase in mind.”
“"Linear Haskell", Linear Haskell”
“This Haskell extension uses linear types for resource safety and scoped effects [4].”
“see Section 2.7 (and the last paragraph of Section 6.1) of Linear Haskell for details.”
“See "borrow" in Section 7.2, page 5:26 of Linear Haskell”