If the hopeless hacks do not bother you, you can do:
///functionize constructor taking one arg let inline New< ^T, ^U when ^T : (static member ``.ctor`` : ^U -> ^T)> arg = (^T : (static member ``.ctor`` : ^U -> ^T) arg) type MyInt(i: int) = member xi = i [0..9] |> List.map New<MyInt, _>
EDIT: As kvb pointed out, a simpler (and less hacker) signature could be used:
let inline New x = (^t : (new : ^u -> ^t) x)
Note that this switches the args type around, so it becomes New<_, MyInt>
.
source share