Hacker News new | ask | show | jobs
by occamrazor 1465 days ago
Shouldn’t the type constraint on multiplication be existence of an operator:

    (*) : ^c * ^c -> ^b ?
1 comments

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
I see, but in this case the multiplication is “b * b”, which has type “^c * ^c”.