Slide 7
Slide 7 text
FP? Haskell Side Effects Monads Resources End Intro Type System Laziness Purity Currying
Polymorphism
The type system supports (multiple forms) of polymorphism:
• Parametric Polymorphism (similar Swift, Java, .Net Generics)
-- Standard Functions
map :: (a -> b) -> [a] -> [b]
length :: [a] -> Int
odd :: Integral a => a -> Bool
-- 1: map as (String -> Int) -> [String] -> [Int]
strLens = map length ["C", "Swift", "C++"]
strLens = [1, 5, 3] -- the result
-- 2: map as (Int -> Bool) -> [Int] -> [Bool]
oddInts = map odd [1, 2, 3, 4, 5]
oddInts = [True,False,True,False,True] -- the result
Johannes Weiß Introduction to Haskell