我为Vect提供了以下包装器
data Foo : (r : Nat) -> (t: Type) -> Type where
MkFoo : Vect r t -> Foo r t我想为Foo实现Functor,并在实现中使用r的值,但我无法对其进行编译。
Functor (Foo r) where
map f (MkFoo v) = MkFoo (ff v) where
ff : {r' : Nat} -> Vect r' a -> Vect r' b给出
Error: While processing right hand side of map. r is not accessible in this
context.
Foo.idr:61:28--61:32
|
61 | map f (MkFoo v) = MkFoo (ff v) where
| ^^^^这在IDRIS1中有效,但我不知道如何将其移植到Idris2。我试过让r不被擦除,用
Functor ({r : _} -> Foo r) where
map f (MkFoo v) = MkFoo (ff v) where
ff : {r' : Nat} -> Vect r' a -> Vect r' b但我得到了
Error: While processing type
of Functor implementation at Foo.idr:60:1--62:46. When
unifying Type -> Type and Type.
Mismatch between: Type -> Type and Type.
Foo.idr:60:21--60:26
|
60 | Functor ({r : _} -> Foo r) where
| ^^^^^发布于 2021-03-13 10:03:56
尝试:
{r : _} -> Functor (Foo r) where
map f (MkFoo v) = MkFoo (ff v) where
ff : {r' : Nat} -> Vect r' a -> Vect r' bhttps://stackoverflow.com/questions/66609163
复制相似问题