如何使用与抽象类型的合并?
How to use merge with abstract type?
我正在尝试实现一个将 merge
与抽象类型结合使用的通用过程,但它总是会因 ❰merge❱ expects a record of handlers
而失败,即使调用者传递记录类型也是如此:
let Keys
: Type
= < A | B >
let ConfigType
: Type
= { A : Text, B : Text }
let Renderer =
λ(configType : Type)
→ λ(config : configType)
→ λ(value : Keys)
→ merge config value
in Renderer ConfigType { A = "A", B = "B" } Keys.A
是否可以指示 configType 将是一个记录类型,以便可以解释此泛型方法?
不,目前在该语言中这是不可能的。
在接下来的 GitHub 期中,我们讨论了向语言添加 Row
种类以区分记录类型与其他类型:
https://github.com/dhall-lang/dhall-lang/issues/434
...但最终以不同的方式解决了原始问题。
我正在尝试实现一个将 merge
与抽象类型结合使用的通用过程,但它总是会因 ❰merge❱ expects a record of handlers
而失败,即使调用者传递记录类型也是如此:
let Keys
: Type
= < A | B >
let ConfigType
: Type
= { A : Text, B : Text }
let Renderer =
λ(configType : Type)
→ λ(config : configType)
→ λ(value : Keys)
→ merge config value
in Renderer ConfigType { A = "A", B = "B" } Keys.A
是否可以指示 configType 将是一个记录类型,以便可以解释此泛型方法?
不,目前在该语言中这是不可能的。
在接下来的 GitHub 期中,我们讨论了向语言添加 Row
种类以区分记录类型与其他类型:
https://github.com/dhall-lang/dhall-lang/issues/434
...但最终以不同的方式解决了原始问题。