So I am reading Paul Hudak's book "The Haskell School of Expression" and am stuck on an exercise in there.
Here it goes
Suppose function fix is defined as
fix f = f (fix f)
What is the principal type of fix
? That one I know, it's b -> b -> b
But I don't understand the way fix
is defined, won't it go into an infinite recursion?
Also, let the remainder
function be defined as
remainder :: Integer -> Integer -> Integer
remainder a b = if a < b then a
else remainder (a - b) b
Rewrite remainder
using fix
so that it is non-recursive.