In Haskell, uppercase types are concrete types ( Int , Bool ) or type constructors ( Maybe , Either ), and lowercase types are type variables. The function is implicitly common to all type variables that it uses, so this is:
contains :: Int -> [(Int, a)] -> [a]
Is a shorthand for this *:
contains :: forall a. Int -> [(Int, a)] -> [a]
In C ++ forall is written template :
template<typename a> list<a> contains(int, list<pair<int, a>>);
In Java and C #, it is written using angle brackets:
list<a> contains<a>(int, list<pair<int, a>>);
Of course, in these languages ββgeneral type variables are often called T , U , V , and in Haskell theyre often called a , b , c . This is just a difference of convention.
* This syntax is activated by the -XExplicitForAll flag in the GHC, as well as other extensions.
source share