在接受函数的接口中约束函数参数的语法是什么?我试过了:
interface Num a => Color (f : a -> Type) where
defs...
Run Code Online (Sandbox Code Playgroud)
但它说 Name a is not bound in interface...
你interface实际上有两个参数:a和f.但f应该足够选择implementation:
interface Num a => Color (a : Type) (f : a -> Type) | f where
Run Code Online (Sandbox Code Playgroud)
f这里称为决定参数.
这是一个荒谬的完整例子:
import Data.Fin
interface Num a => Color (a : Type) (f : a -> Type) | f where
foo : (x : a) -> f (1 + x)
Color Nat Fin where
foo _ = FZ
x : Fin 6
x = foo {f = Fin} 5
Run Code Online (Sandbox Code Playgroud)