idris - 如何在 Idris2 中编​​写 CV-Coalgebra?

标签 idris recursion-schemes

在 Haskell 中,我可以写

data CoAttr f a
  = Automatic a
  | Manual (f (CoAttr f a))
但 Idris 似乎不允许这种带有 data 的定点类型。 .他们确实与 record 合作,即我可以写
record CoAttrWithoutAutomatic (f : Type -> Type) where
    constructor Manual
    out : f (CoAttrWithoutAutomatic f)
但是如果我理解正确的话,我不能有多个变体。有解决办法吗?

最佳答案

明白了——我错过了定义数据类型的一般形式:

data CoAttr : (f : Type -> Type) -> (a : Type) -> Type where
  Automatic : a -> CoAttr f a
  Manual : (f (CoAttr f a)) -> CoAttr f a

CVCoalgebra : (f: Type -> Type) -> (a: Type) -> Type
CVCoalgebra f a = a -> f (CoAttr f a)

关于idris - 如何在 Idris2 中编​​写 CV-Coalgebra?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65362653/

相关文章:

haskell - 在 catamorphism 中组合 f-代数的规则是什么

Haskell 高阶函数

haskell - 使用 catamorphisms 链接值

对类型构造函数参数具有接口(interface)约束的 Idris 相关记录

haskell - *** CPSZ : mean in Cabal build log when building Idris? 是什么意思

haskell - 通过效果进行通用编程

idris - Idris 中的常量

haskell - 为什么 GHC Haskell 不支持重载记录参数名称?

javascript - 将专门用于列表的 future 态表示为命令式循环

Haskell:使用算法 W 用类型信息标记 AST