haskell - Lambda/ Anonymous function conceptual understanding -
i trying learn , understand design of haskell. on lambda / anonymous functions , wondering.
why aren't function types instances of eq class?
prelude> (\z -> z+5) == (+5)
on question, wondering if because z can , may free variable, in lambda functions, design flaw make lambda functions of type eq.
why arent function types instances of type class show?
prelude> (\q -> q-2)
i appreciate clarification.
many in advance!
are these functions same or different:
dbl1 :: int -> int dbl1 x = x + x dbl2 :: int -> int dlb2 x = 2 * x
?
for some functions it's "easy" compiler see contain same logic. functions extremely difficult compare. there functions logically different, behave same - dbl1
, dbl2
above. so, have make choice either test them against every possible value, or decide not equal. former impractical in cases. latter not desirable or intuitive. now, consider problem difficult solve, , throw in io
...
Comments
Post a Comment