I have this bit of code:
fun foldr2(f, x::xs) =
if xs = [] then
x
else
f(x, foldr2(f, xs))
With the type signature
(''a * ''a -> ''a) * ''a list -> ''a
Looks pretty straight-forward, it takes a function that works over equality types and a list of equality type as arguments, because of the xs = []
comparison. However, for some reason it works on input such as (op +, [2.3, 2.7, 4.0])
, when in SML/NJ reals are not an equality type. Can anyone help me shed some light on why this magic occurs?