We're moving pass primitives and diving into types, types, types. I've really struggle with this in previous Haskell attempts, this is usually the part where I get frustrated and bail, but not this time!!!
->is used to separate arguments and return value
functions with multiple arguments
types for first class functions
ifEven :: (Int -> Int) -> Int -> Int
simple :: a -> awith a definition of
simple x = x
ahere is literally a variable for any kind of type, which one? doesn’t matter. You want to know, I want to know. But this is important, it doesn’t matter. What does matter is that whatever type it is that you pass as an argument to simple, you are guaranteed that you will get the same type back, in this case
a. Give it a Int, you get an Int back…
f1 : : a -> a
f2 : : a -> b
a -> brepresents a much broader behavior, this function can take type a and return not only a different value, but a different type!! Here’s the part I’ve missed before, BUT IT DOESN’T HAVE TO
dataas a key work for creating a new type.
the data constructor is used to create a concrete instance of the type
key :: type
->we might see this
( + ) : : Num a => a -> a -> a
and there’s a super cool type class roadmap we’ll look through next week!