I have an application that displays piano sheets, and therefore I have to abstract some musical notations in the recording. To preserve some typing, I sometimes add a member FromTupleto some record types.
I also introduced an operator !>that takes a tuple and returns the corresponding tuple. However, I have the following problem:
FS0332: The ambiguity inherent in using the FromTuple statement at or near this program point could not be resolved. Consider using type annotations to eliminate ambiguity.
I cannot find the actual source of my error (at first I thought that some record field names could be defined / used in several record types, but this does not seem to be the case).
Type Definitions:
type xyz =
{
Field1 : int
Field2 : bool
Field3 : string * string
}
with
static member FromTuple (a, b, c) = { Field1 = a; Field2 = b; Field3 = c }
[<AutoOpen>]
module Globals =
let inline (!>) x = (^b : (static member FromTuple : ^a -> ^b) x)
Invalid line (in a separate file):
let my_xyz : xyz = !> (315, false, ("foo", "bar"))
source
share