I assume the answer is “you can’t” because I couldn’t get anything to work, and there are no examples I could get google to find.
Then the question is … why not?
My tendency was to go for structs because I have that idea in my toolkit, but I’m starting to think structs are for a special cases, being for optimising … ?
type point =
struct
val x : int
val y : int
end
new(a,b) =
{
x = a
y = b
}
let p = point(1,2)
let q = point(2,1)
match p with
| point(1,2) -> printf "yes it matched\n"
| _ -> printf "No it didn't"
gives error
/home/jon/fsharp/test1/Program.fs(16,3): error FS0039: The pattern discriminator 'point' is not defined. [/home/jon/fsharp/test1/test1.fsproj]
The build failed. Fix the build errors and run again.