This question is a theoretical question about Haskell functions which can take arguments of any type. Is there a difference between the way functions with the type signatures of
a -> b -> a
and
c -> a -> c
are instantiated? Any help is appreciated.
There is no difference. Since a
, b
and c
start with a lowercase, these are variables. You can rename variables, and this remains the same, as long as two (or more) variables do not "clash".
Such clashes can happen if you rename a variable such that it has the same name as another variable, or when you rename two (or more) variables to the same new name. If you would rename the variable a
for example to b
in your first code fragment, then we would get b -> b -> b
, but that is not the same, since then we enforce that the first and second parameter are of the same type. Whereas in your type signature, we have the freedom to pick two types that can be the same, but that is not necessary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With