函数applyRule
应该提取类型为n
的隐式参数VVect
,该隐式参数用在它获得的另一个参数中。
data IVect : Vect n ix -> (ix -> Type) -> Type where -- n is here
Nil : IVect Nil b
(::) : b i -> IVect is b -> IVect (i :: is) b
VVect : Vect n Nat -> Type -> Type -- also here
VVect is a = IVect is (flip Vect a)
-- just for completeness
data Expression = Sigma Nat Expression
applyRule : (signals : VVect is Double) ->
(params : List Double) ->
(sigmas : List Double) ->
(rule : Expression) ->
Double
applyRule {n} signals params sigmas (Sigma k expr1) = cast n
在不引用{n}
的情况下,代码进行类型检查(如果cast n
更改为某个有效的double值)。但是,添加它会导致以下错误:
When checking left hand side of applyRule:
Type mismatch between
Double (Type of applyRule signals params sigmas rule)
and
_ -> _ (Is applyRule signals
params
sigmas
rule applied to too many arguments?)
这对我来说似乎没有意义,因为我没有对可能依赖于n
的任何参数进行模式匹配,因此我认为只需将其放在花括号中即可进入范围。
答案 0 :(得分:3)
如果data = ['build999.100', 'build999.0', 'buil998.100', 'build997.100', 'build996.100', 'build996.0']
d = {s.split('.')[0]: s for s in data}
out = list(d.values())
在某个地方定义(例如,作为参数中的变量),则只能将其带入范围。否则,很难弄清n
的来源-至少对于人类而言。
n