let makeElem
我在以下代码中得到值限制错误:
let elemCreator (doc: XmlDocument) =
fun name (value: obj) ->
let elem = doc.CreateElement(name)
match value with
| :? seq<#XmlNode> as childs ->
childs |> Seq.iter (fun c -> elem.AppendChild(c) |> ignore)
elem
| _ -> elem.Value <- value.ToString(); elem
let doc = new XmlDocument()
let makeElem = elemCreator doc
elemCreator
如果从返回的匿名函数没有任何泛型参数,为什么会出现值限制错误?
编译器声明 makeElem 的推断类型是(string -> 'a -> XmlNode)
. 但是为什么它推断出第二个参数就像'a
我已经声明它一样obj
?