SHARE
TWEET

F# Statically Resolved Type Parameters and call syntax

a guest May 18th, 2015 262 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // this works as expected
  2. type Example() =
  3.   member __.F(i) = printfn "%d" i
  4.  
  5. let inline f (x : ^a) =
  6.   (^a : (member F : int -> unit) (x, 1))
  7.   (^a : (member F : int -> unit) (x, 2))
  8.  
  9. f (Example())
  10.  
  11. // this doesn't work
  12. let inline f (x : ^a when ^a : (member F : int -> unit)) =
  13.   // the compiler knows that there must be member F and its signature
  14.   // so the following should be possible
  15.   x.F(1)
  16.   x.F(2)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top