2016-04-22 88 views

回答

5

interface實際上有兩個參數:af。但是,f應該足夠挑implementation

interface Num a => Color (a : Type) (f : a -> Type) | f where 

f這裏被稱爲determining parameter

這裏有一個荒謬的完整的例子:

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 
+1

噢噢我有兩個參數的接口,但我沒有意識到我可以用'| f'強迫一個人來決定,這是非常好的。 – ScarletAmaranth