4 ms·
Shouldn’t the type constraint on multiplication be existence of an operator: (*) : ^c * ^c -> ^b ?
by occamrazor 4y ago
Shouldn’t the type constraint on multiplication be existence of an operator:
(*) : ^c * ^c -> ^b ?
- shirogane86x 4y agoF# 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
- occamrazor 4y agoI see, but in this case the multiplication is “b * b”, which has type “^c * ^c”.