Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a difference between type signatures a -> b -> a and c -> a -> c?

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.

like image 401
Dreana Avatar asked Oct 27 '19 19:10

Dreana


1 Answers

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.

like image 81
Willem Van Onsem Avatar answered Oct 12 '22 23:10

Willem Van Onsem