Reputation: 21727
very simple examples:
let myfun x = x
let inline myfun x = x
^a
?let inline myfun (x: 'b) = x
let inline myfun (x: ^b) = x
Since the intellisense never shows ^b
, should I look for ^b
as an indicator of "statically resolved" in FSI?
Does inline
guarantee "statically resolved"?
Upvotes: 3
Views: 250
Reputation: 26174
Inline does allow but does not force statically resolved types, that's why in case 2. it remains the same as in case 1.
I think in most cases type inference is smart enough to guess if the type should really be statically resolved, even if you don't specify the ^
.
For example if you change your function body to sqrt x
in case 3. you'll get
> let inline myfun (x: 'b) = sqrt x;;
val inline myfun : ^b -> ^a when ^b : (static member Sqrt : ^b -> ^a)
I personally always try not to specify types explicitly at first try, then I check if I'm happy with the inference, if I'm not then I try adding inline, but not the hat types.
Why intellisense shows sometimes something different? that's probably a small bug.
Upvotes: 1