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# 如何为提供的方法生成curried参数?_F#_Type Providers_F# 3.0 - Fatal编程技术网

F# 如何为提供的方法生成curried参数?

F# 如何为提供的方法生成curried参数?,f#,type-providers,f#-3.0,F#,Type Providers,F# 3.0,我想在签名a->B->C 但我只能生成A*B->C: ProvidedMethod(name, [ ProvidedParameter("A", aType); ProvidedParameter("B", bType) ], cType, IsStaticMethod = true) 我不能手动进行转换,因为函数类型在类型提供程序中不能正常工作,只能在委托类型中工作。有没有其他我不知道的方法,或者根本不支持的方法?我怀疑你不能简单地使用提供的方法来做咖喱。但是,您可以让您的方法返回一个封装参

我想在签名
a->B->C

但我只能生成
A*B->C

ProvidedMethod(name, [ ProvidedParameter("A", aType); ProvidedParameter("B", bType) ], cType, IsStaticMethod = true)

我不能手动进行转换,因为函数类型在类型提供程序中不能正常工作,只能在委托类型中工作。有没有其他我不知道的方法,或者根本不支持的方法?

我怀疑你不能简单地使用提供的方法来做咖喱。但是,您可以让您的方法返回一个封装参数应用程序的函数

public Func<A, Func<B, C>> Curry<A, B, C>(Func<A, B, C> func)
{
   return a1 => a2 => func(a1, a2);
}
公共本币(Func Func)
{
返回a1=>a2=>func(a1,a2);
}
上面用C#给出的示例为了更明确地显示类型,在类型提供程序中,它将如下所示

let retType = typeof<('a -> ('b -> 'c)>
let ftype = typeof<('a -> 'b -> 'c>
let method = ProvidedMethod(name, [ProvidedParameter("Func", ftype)], retType)
let retType=typeof'c)>
设ftype=typeof'c>
let method=ProvidedMethod(名称,[ProvidedParameter(“Func”,ftype)],retType)

我现在手头没有F#编译器(我在iPad上),但希望这是一个正确的方向。

请注意,您可以在
a->B->C
中转换
a*B->C