Equivalent of fst and snd for F# struct tuples?

There's a ToTuple() extension method in System.TupleExtensions for ValueTuple<T1, T2...>.

You could just call:

plot (point.ToTuple())

As for fst, snd, they're bound to System.Tuple<>, so maybe you could define an alternative:

let fstv struct (a,_) =  a
let sndv struct (_,b) =  b

In F# 4.7, you must add another line to decompose the tuple.

let plot(x: int, y: int) = ()
let point = struct (3, 4)
let struct (x, y) = point
plot(x, y)

Tags:

F#