How to compare two functions for extensional equivalence, as in (λx.2*x) == (λx.x+x)?

It’s pretty well-known that general function equality is undecidable in general, so you’ll have to pick a subset of the problem that you’re interested in. You might consider some of these partial solutions: Presburger arithmetic is a decidable fragment of first-order logic + arithmetic. The universe package offers function equality tests for total functions with … Read more

How does currying work?

Understanding higher-order functions Haskell, as a functional language, supports higher-order functions (HOFs). In mathematics HOFs are called functionals, but you don’t need any mathematics to understand them. In usual imperative programming, like in Java, functions can accept values, like integers and strings, do something with them, and return back a value of some other type. … Read more

Does Haskell have return type overloading?

Well, one way to look at it is that Haskell translates the return type polymorphism that you’re thinking of into parametric polymorphism, using something called the dictionary-passing translation for type classes. (Though this is not the only way to implement type classes or reason about them; it’s just the most popular.) Basically, fromInteger has this … Read more