Polymorphic Functions
Polymorphic functions can be applied to many kinds of data -- easier to reuse!
length [1, 2, 3] 3
length ”abc” 3
length [”hi”, ”there”] 2
Polymorphic types contain variables:
length :: [a] -> Int
reverse :: [a] -> [a]
palindrome :: [a] -> Bool
Lower case
stands for a
type variable.
Föregående bild
Nästa bild
Tillbaka till första bilden
Visa grafisk version