人們可以在伊德里斯函數返回一個類型,例如有沒有一種很好的方式來直接使用` - >`作爲Idris中的一個函數?
t : Type -> Type -> Type
t a b = a -> b
但是現在的情況上來,我想用->
摺疊類型列表(用寫一些解析器實驗時),即
typeFold : List Type -> Type
typeFold = foldr1 (->)
這樣typeFold [String, Int]
會給String -> Int : Type
。這不,雖然編譯:
error: no implicit arguments allowed
here, expected: ")",
dependent type signature,
expression, name
typeFold = foldr1 (->)
^
但是這工作得很好:
t : Type -> Type -> Type
t a b = a -> b
typeFold : List Type -> Type
typeFold = foldr1 t
有沒有更好的方式與->
工作,如果沒有是值得提高的功能提出要求?
然後可以使用'typeFold = foldr1(〜>) – 2016-12-27 14:26:10