We have made it to the beginning! With a solid understanding, or at least a better understanding we are ready to tackle I/O, aka side effects!
It as dawned on me as I have tried to find a better way to number, categorize this episodes, that each unit has about a dozen lessons. So Unit 4, that we’ll cover now are lessons 20-23.
This prevents it from clouding up or haskell environment of purity.
Even as I write out the samples I had to search for the following
Data constructor is not in scope?
build random, not included in the main lib since 7.2
./call it. 🙄
-hso see if you can figure it out.
IO () type. Which appears to be an innvoced function! NOPE
putStrLndoes that return a value ?
And my favorite curveball, A backwords arrow
<- from getLine
String, but a
Like Maybe, IO describes a context for their parameters rather than a container.
IOactions are not functions. I repeat, not functions. Just a tuple with with Zero elements.
IO, the nothing is our return value! 😵
the empty tuple is the best way to communicate the nothing/empty return value
bc of this Main isn’t a function, it must return a value. So we refer to it as an
IO Action that action being a side effect!
IO Actionsmight return a value, but not take a init value or doesn’t always return the same value. whatever it might be, it will violate 1 of the 3 rules that that a function must follow in Haskell.
IO Actiontoo. Ah ha!!!