Created
December 22, 2020 22:03
-
-
Save Luiz-Monad/81128d3fab689af3954025a071c8dbf7 to your computer and use it in GitHub Desktop.
FSharp custom equality overload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Equality = | |
static member inline Mk = Unchecked.defaultof<Equality> | |
static member inline Eq (x: T1, y: T1) = (x.String = y.String) | |
static member inline Eq (x: T2, y: T2) = (x.Array = y.Array) | |
let inline liftEquals (c: ^C) x y = | |
let inline call (_: ^C, x: ^X, y: ^Y) = | |
((^C or ^X or ^Y): (static member Eq: 'X * 'Y -> bool) (x, y)) | |
call (c, x, y) | |
let inline (=) x y = liftEquals Equality.Mk x y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment