3
我在嘗試定義Idris類型內部的已驗證類別,但我的方法沒有鍵入檢查。在Idris中定義類別
class Cat ob (mor : ob -> ob -> Type) where
comp : {a : ob} -> {b : ob} -> {c : ob} -> mor a b -> mor b c -> mor a c
unit : (a : ob) -> mor a a
l : {a,b : ob} -> {f : mor a b} -> (comp (unit a) f) = f
ob
是對象的類型,mor a b
是態射的從a
到b
類型。 還有合適的單位和相關法律,但我的定義l
不起作用。它說:
When elaborating type of constructor of Main.Cat:
When elaborating an application of comp:
Can't unify
mor a13 b14 (Type of f)
with
mor b14 c (Expected type)
我覺得很困惑。 unit a
有類型mor a a
,f
有類型mor a b
,爲什麼comp (unit a) f
類型mor a b
以及?
class Cat ob (mor : ob -> ob -> Type) where
comp : {a : ob} -> {b : ob} -> {c : ob} -> mor a b -> mor b c -> mor a c
unit : (a : ob) -> mor a a
l : {a,b : ob} -> {f : mor a b} -> (comp {a=a} {b=a} {c=b} (unit a) f) = f
埃德溫·布雷迪在this issue,爲什麼指出:
你應該在Github上提出問題。有時候,這些東西都是bug。 – dfeuer
@dfeuer,謝謝你的鼓勵。我確實這樣做了,並在這裏發佈了埃德溫的答案。 – Turion