Advertisement
Guest User

F# Statically Resolved Type Parameters and call syntax

a guest
May 18th, 2015
397
0
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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement