小编adH*_*ush的帖子

Idris - 自定义依赖数据类型的映射函数失败

我对idris和依赖类型相对较新,我遇到了以下问题 - 我创建了一个类似于矢量的自定义数据类型:

infixr 1 :::

data TupleVect : Nat -> Nat -> Type -> Type where
    Empty : TupleVect Z Z a
    (:::) : (Vect o a, Vect p a) ->
            TupleVect n m a ->
            TupleVect (n+o) (m+p) a

exampleTupleVect : TupleVect 5 4 Int
exampleTupleVect = ([1,2], [1]) ::: ([3,4],[2,3]) ::: ([5], [4]) ::: Empty
Run Code Online (Sandbox Code Playgroud)

它通过添加向量元组并通过每个元组位置中的向量长度之和进行索引来归纳构造.

我试图为我的数据类型实现一个map函数:

tupleVectMap : ((Vect k a, Vect l a) -> (Vect k b, Vect l b)) ->
               TupleVect n m a …
Run Code Online (Sandbox Code Playgroud)

tuples vector dependent-type idris map-function

2
推荐指数
1
解决办法
157
查看次数

标签 统计

dependent-type ×1

idris ×1

map-function ×1

tuples ×1

vector ×1