Hacker News new | ask | show | jobs
by shirogane86x 1463 days ago
F# will always assume that the types can be heterogeneous, there's nothing in F# that gives (*) or (+) any sort of special behaviour, so it doesn't conform to an interface. Operators will usually always have an (inline) type of form

    ^x * ^y -> ^z 
because you could technically define a

    static member (*) (a: int) (b: float): double = ... 
and there's nothing saying that you can't. in that case:

   (*) : ^a * ^c -> ^b //^a = int, ^c = float, ^b = double
   (*) : ^c * ^c -> ^b //^c = int, ^c = float, ^b = double. 
and the second one won't work, because ^c =/= ^c
1 comments

I see, but in this case the multiplication is “b * b”, which has type “^c * ^c”.