Re:C#: IEnumerable, yield return, and lazy evaluation
by occamrazor on Friday June 17, 2022 @05:41AM
(#31775996)
Shouldn’t the type constraint on multiplication be existence of an operator:
[ Parent
| on HN ]
Re:C#: IEnumerable, yield return, and lazy evaluation
by shirogane86x on Friday June 17, 2022 @05:52AM
(#31776053)
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
Re:C#: IEnumerable, yield return, and lazy evaluation
by occamrazor on Friday June 17, 2022 @01:24PM
(#31781386)
I see, but in this case the multiplication is “b * b”, which has type “^c * ^c”.