4 ms·
>For IO what you would need to learn is that all IO actions are values of the `IO` type and they can be sequenced together for guaranteed ordering using the `do
by crimsonalucard 9y ago
>For IO what you would need to learn is that all IO actions are values of the `IO` type and they can be sequenced together for guaranteed ordering using the `do` notation. That's it. No monads. We can introduce monads after we show using the same `do` notation for lists, `Maybe`s, and `IO`.
This is an awkward teaching approach. Forcing learners to use advanced concepts without fully understanding them. Why can't haskell just have a print function that returns a void? How come when I use haskell with input it starts polluting the input with this IO thing? This all seems stupid initially and it takes a lot of learning to understand why things are done this way.... I mean that person I know thinks javascript is better than haskell because console.log("hello") is ten times more straightforward.
- yawaramin 9y agoI disagree that it's forcing learners to use advanced concepts. It's giving them syntax sugar and a fairly clear introductory explanation (IO is done only with the `IO` type for safety reasons) and giving them all the capabilities of IO in other languages straight from day one. Forgetting about types for a second, can you really say that `putStrLn "hello"` is harder to understand than `console.log("hello")`? Trust me when I say this, plenty of people have taught Haskell to kids and the result has always been that they pick it up easily. Programmers from other backgrounds worry away too much of their mental capacity thinking about monads. Stop worrying about it and just hack away.
- crimsonalucard 9y agoUnderstanding a pattern is different from copying a pattern. Our disagreement lies not with kids copying a pattern but with people fully comprehending the philosophy and true nature of the monad abstraction. This is not easy for a beginner. Allow me to elucidate: Here is a an example of a trivial operation in imperative programming that becomes a bit more complicated in Haskell: Create a function that prints everything in an array: naive implementation in haskell (won't work): printElements arrayOfStrings= map putStrLn arrayOfStrings main = printElements ["Hello", "World"] True implementation: printElements [] = return () printElements x:xs = (putStrLn x) >> (printElements xs) main = printElements ["Hello", "World"] The second implementation requires understanding of types and the IO monad while the first implementation is a naive and broken implementation that most people turn to when learning Haskell. It is not trivial to explain to a person why it must be done the second way... All of this and all we were doing was printing something to the console! It's too much! Monads aren't even a required part of functional programming. Haskell is not a great language to learn about functional programming.
- tome 9y agoActually the "true" implementation is printElements arrayOfStrings = traverse putStrLn arrayOfStrings main = printElements ["Hello", "World"] but the difference between map and traverse is sufficient for your point to still hold water.
- yawaramin 9y agoI think we would actually use `mapM_` rather than `traverse`.
- Retra 9y agoJava requires you to understand class and public static void main (and classpath crap) before you can print to console, but that doesn't seem too hard for anyone to learn.
- crimsonalucard 9y agoThe concept of an object is trivial compared to a monad. Objects in the computing world have real world equivalents. The real world equivalent of a monad is a burrito.