Last active
September 25, 2021 17:52
-
-
Save palladin/e3a2d44688c7a451cc0f to your computer and use it in GitHub Desktop.
Overload resolution and inline trick
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 Term<'a>() = class end | |
type Tuples = Tuples with | |
static member inline (?<-) (_ : Tuples, _ : Term<_>, _ : Term<_>) = 0 | |
static member inline (?<-) (_ : Tuples, (_:Term<_>,_:Term<_>),(_:Term<_>, _:Term<_>)) = 2 | |
static member inline (?<-) (_ : Tuples, a:bool, b:bool) = 3 | |
let inline call_2 (t:^t,a:^a,b:^a) : int = | |
(t ? (a) <- b ) | |
let t = call_2 (Tuples,Term<int>(),Term<int>()) | |
let t2 = call_2 (Tuples,(Term<int>(),Term<int>()),(Term<int>(),Term<int>())) | |
let t3 = call_2 (Tuples, true, false) | |
let inline call a b : int = | |
call_2 (Tuples, a, b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Incidentally, if you remove the bool overload, again the
call
is properly generalized.