2

我有一个查询类型data Query a

鉴于Query没有构造函数,我如何定义eval类型的函数:

eval :: Query ~> H.ComponentDSL State Query Void m

我必须添加一个构造函数Query吗?

4

1 回答 1

0

使用type Query = Const Voideval = absurd << un Const

type Query= Const Void = data Query a,它们都有 type Kind -> Kind,并且没有构造函数。

对于eval = absurd <<< un Const匹配类型Query ~> H.ComponentDSL State Query Void mabsurd :: forall a. Void -> a确保返回类型匹配。un Const :: forall a b -> Const a b -> a确保输入类型匹配 ( forall a. Query a -> Void)

于 2018-10-23T01:44:44.103 回答