ghci tells us
add :: Num a => (a -> a -> a) -> a -> a -> a
modulo is some class type noise, since the second argument add requires an instance of Eq (you check for equality with 0 )
When we apply fix to add , the signature for fix becomes
fix :: ((a -> a -> a) -> (a -> a -> a)) -> (a -> a -> a)
Remember that a in fix :: (a -> a) -> a can be of any type. In this case, they are of type (a -> a -> a)
So fix add :: Num a => a -> a -> a , which is exactly the right type to add two a s.
You can work with signatures like Haskell very algebraically; variable substitution works just as you expected. In fact, theres a direct translation between types and algebra.
source share