Is there a way to do somehow overload a function?
Let’s take those 3 functions:
// Returns StringPropertyInfo
let stringProperty (expr:Expr<'a -> string>) (cfg:EntityInfo<'a>) =
cfg.Property expr
// Returns DatePropertyInfo
let dateProperty (expr:Expr<'a -> System.DateTime>) (cfg:EntityInfo<'a>) =
cfg.Property expr
// Returns BytePropertyInfo
let byteProperty (expr:Expr<'a -> System.Byte>) (cfg:EntityInfo<'a>) =
cfg.Property expr
is there a way to merge them all into just:
let property expr cfg = ....
if not, whats the most neat way to accomplish something similar?
Short answer, no. There’s another question dealing with this here.
You can however overload methods in classes etc. otherwise the .NET integration wouldn’t work too well. This is one possible solution albeit not in my eyes, a pretty one.
You could put them in different sub-modules.
Perhaps you could make a generic function and decide the return type through one of the parameters. I’m too much of a newbie when it comes to the type inference to say for certain though.