4
我定義我自己的Vect數據類型如下實現可摺疊的的Vect的用戶定義的版本與翻轉類型參數
data MyVect : (n : Nat) -> (t : Type) -> Type where
Nil : MyVect Z t
(::) : (x : t) -> (xs : MyVect n t) -> MyVect (S n) t
然後開始實施的數據類型
Foldable MyVect where
foldr = ?res2
的摺疊式接口
然而重新加載該文件時,伊德里斯投訴
When checking argument t to type constructor Prelude.Foldable.Foldable:
Type mismatch between
Nat -> Type -> Type (Type of MyVect)
and
Type -> Type (Expected type)
Specifically:
Type mismatch between
Nat
and
TypeUnification failure
劃傷後荷蘭國際集團我的頭一下,我猜我會服從伊德里斯的類型構造要求寫
Foldable (MyVect n) where
foldr = ?res2
然後,我開始想:「如果我曾與翻轉類型參數定義MyVect?......」
data MyVect : (t : Type) -> (n : Nat) -> Type where
Nil : MyVect t Z
(::) : (x : t) -> (xs : MyVect t n) -> MyVect t (S n)
是否有可能實施的MyVect
這個「參數翻轉的」版本的可摺疊的接觸? (?以及如何)
不知道這是如何工作0.12.3,但在1.0定義'FlippedVect'時,你得到一個「實現參數必須是類型或數據構造函數」錯誤的一切從那裏。 –
@AlexanderGryzlov個人而言,我同意,允許爲任何非數據或類型構造函數定義接口是不好的。沒有檢查它是否爲'1.0',但我很高興如果它是如此:) – Shersh