The excerpt below from Gentle Intro to Haskell implies that head's type can be seen as a->a. Is it me who does not understand something or is this a typo?
Probably its just me but then how can head's type be a->a ?
An expression's or function's principal type is the least general type that, intuitively, "contains all instances of the expression". For example, the principal type of head is [a]->a; [b]->a, a->a, or even a are correct types, but too general, whereas something like [Integer]->Integer is too specific.
There are several hundred types of headaches, but there are four very common types: sinus, tension, migraine, and cluster. Headaches are always classified as either primary or secondary.
A head is the part of an organism which usually includes the ears, brain, forehead, cheeks, chin, eyes, nose, and mouth, each of which aid in various sensory functions such as sight, hearing, smell, and taste.
Conditions that might cause nonprimary chronic daily headaches include: Inflammation or other problems with the blood vessels in and around the brain, including stroke. Infections, such as meningitis. Intracranial pressure that's either too high or too low.
This is a typo, I believe they meant
head :: b -> a
since b
is just a random type variable which would unify with [a]
.
So in order of increasing specificity,
head :: [a] -> a
head :: foo -> a
head :: a
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