这适用于 F#4.0:
type Something<'a, 'b when 'b :> seq<'b>>() =
这不会:
type Something<'b when 'b :> seq<'b>, 'a>() =
Unexpected symbol ',' in type name. Expected '>' or other token.
类型约束的顺序很重要的原因是什么?
最佳答案
因为它在规范中 - 相关部分是这样的(从第 5 节开始):
typar-defns:= < typar-defn, ..., typar-defn typar-constraints_opt>
约束需要最后消除。
在此
typar-constraints
必须始终以 when
开头并且不能出现在其他任何地方。
关于f# - F#中类型约束的顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37544976/