Guest User

Untitled

a guest
Jul 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. > 3. + 4.;;
  2. val it : float = 7.0
  3. > (+);;
  4. val it : (int -> int -> int) = <fun:it@8-2>
  5.  
  6. let inline add a b = a + b
  7. add 1 2 //works
  8. add 1.0 2.0 //also works
  9.  
  10. let inline (+) (x:int) (y:int) = (# "add" x y : int #)
  11.  
  12. let inline (+) (x: ^T) (y: ^U) : ^V =
  13. AdditionDynamic<(^T),(^U),(^V)> x y
  14. when ^T : int32 and ^U : int32 = (# "add" x y : int32 #)
  15. when ^T : float and ^U : float = (# "add" x y : float #)
  16. when ^T : float32 and ^U : float32 = (# "add" x y : float32 #)
  17. ...
  18.  
  19. (# "add" 1 2 : int32 #)
Add Comment
Please, Sign In to add comment