I have defined a record type with a unit of measure in a common library (LibRoot) that is used by both C# (LibC) and F# (LibF) code.
I then wrote a public API in the C# library (LibC) that the F# library (LibF) consumes. But any time i attempt to pass an object to this API F# complains that it must have a unit of measure.
//LibRoot - F#
type Vec2<[Measure] 'u> = {
X : int
Y : int
}
//LibC - C#
public static class Funcs
{
public void DoWork(Vec2 vec) { //no measure needed in C#
....
}
}
//LibF - F#
open LibC
let myVec : Vec2<1> = { X = 123; Y = 456 }
DoWork(myVec) //FS0001
error FS0001: Type mismatch. Expecting a 'Vec2' but given a 'Vec2<1>' The tuples have differing lengths of 0 and 1
I've tried:
Vec2<1>: FS0001Vec2<0>: Invalid Literal in typeVec2<()>: Unexpected ')' in typeVec2<_>: FS0001Vec2<unit>: Expected unit of measure, not type(Vec2) myVec: No constructors available for type 'Vec2<'u>
Does anybody know a way to construct a measured record type in an interop friendly way?