Is it possible to somehow use a pipeline to pass in the last argument of a method with tupled parameters?
An example:
// Member to call
static member Property (expr:Expr<'a -> string>, cfg:EntityInfo<'a>) = cfg.Property expr
// My curry function
let curry f x y = f (x,y)
// My EntityInfo<FileUpload>
let entityInfo = EF.Entity<FileUpload> modelBuilder
I want to be able to call it like:
entityInfo |> curry EF.Property <@ fun z -> z.Path @>
instead of
EF.Property(<@ fun z -> z.Path @>, entityInfo)
I believe that this is a simplified version of your problem (although you’re excluding too much code to be sure):
As Brian mentions, overloading doesn’t play nicely with type inference. In particular, since F#’s type inference works left-to-right, the compiler does not use the fact that
1is anintwhen trying to do the member lookup forS.Method, which means that it can’t identify the correct overload. As I see it, you have a few options:Propertyto refer to multiple different operations? Would it be much worse to useStringProperty,IntProperty, etc. for each overload? In general, overloading makes life harder for the compiler (and often for human maintainers, too). As an aside, I don’t like the idea of naming a methodProperty, anyway…Use explicit type parameters on
curry, and specify them. E.g.Explicitly indicate the type of
EF.Property:Of course, these last two options aren’t very concise, so they may defeat the purpose of using the pipelined style.