例如,可以在 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
有没有更好的使用方法->
,如果没有,是否值得作为功能请求提出?