Slide 8
Slide 8 text
FP? Haskell Side Effects Monads Bonus End Intro Type System Laziness Purity Currying
Polymorphism
The type system supports (multiple forms) of polymorphism:
• Parametric Polymorphism (similar to 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", "Objective-C", "C++"]
strLens = [1, 11, 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 Functional Programming / Haskell