In GHCI, if I use :t on each of the below functions, they differ.
:t test gives (Ord p, Num p) => p -> p -> p
:t testAsLambda gives Integer -> Integer -> Integer
Why does using a lambda to define the exact same function cause more restrictive type inference?
I understand that it might be silly to declare a named function as a lambda like this; I'm just trying to reason about Haskell's type inference here.
test x y =
let d = y - x in
if d > 0 then d
else 0
testAsLambda =
(\x y ->
let d = y - x in
if d > 0 then d
else 0)