Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么';F#编译器是否支持嵌套函数中的excplicit类型?_F# - Fatal编程技术网

为什么';F#编译器是否支持嵌套函数中的excplicit类型?

为什么';F#编译器是否支持嵌套函数中的excplicit类型?,f#,F#,这是问题的后续部分 有关守则是: type BSCReply = { status: int message: string result: string } let private decodeResult<'a> (result: IRestResponse) = let deserialize content = try Ok (JsonConvert.Dese

这是问题的后续部分

有关守则是:

type BSCReply =
    {
        status:  int
        message: string
        result:  string
    }

let private decodeResult<'a> (result: IRestResponse) =
    let deserialize content =
        try
            Ok (JsonConvert.DeserializeObject<'b> content)
        with ex ->
            Error (HttpStatusCode.InternalServerError, ex.Humanize())

    match result.IsSuccessful with
    | true  ->  match deserialize<BSCReply> result.Content with
                | Ok r    -> deserialize<'a> r.result
                | Error e -> Error e
    | false ->  Error(result.StatusCode, result.ErrorMessage)
键入bscapy=
{
状态:int
消息:string
结果:字符串
}
让私人解码(结果内容)
使用ex->
错误(HttpStatusCode.InternalServerError,例如人性化())
匹配结果。IsSuccessful与
|true->匹配反序列化结果。内容为
|Ok r->反序列化内容=
,我也尝试内联它,但没有效果

我的问题是:


为什么编译器不允许这样做?有没有具体的原因?或者在设计时没有提出足够的用例?

Does
JsonConvert.DeserializeObjective我会将类型传递给反序列化函数,以便json concert调用中的泛型具有该类型,但是编译器不允许我将其添加到反序列化内部函数中。我再次阅读了代码,现在明白了您要做的事情。我认为问题在于内部函数实际上被编译为对象(因为外部函数的参数在范围内)。允许编译器将闭包编译为泛型闭包可能花费了太多的精力,但希望从更权威的来源获得信息。