4 ms·
That's not true and never has been. Want to do I/O? main = do putStrLn "Who are you?" name <- readLn putStrLn ("Hello, " ++ name)
by kqr 5y ago
That's not true and never has been. Want to do I/O?
main = do
putStrLn "Who are you?"
name <- readLn
putStrLn ("Hello, " ++ name)
There. Do you really need to know something about monads to understand that example? No.
Do you need to know how do syntax and the assignment operator <- works? Sure. But that has nothing to do with category theory. That's just syntax.
- d3nj4l 5y agoCunningham's law in action, everyone!
- quickthrower2 5y agoTo be fair, once you get a compiler error you’ll at least need to know: a. do notation is converted to haskell b. what the bind and return functions do, for IO So you can figure out; c. Why your types are not lining up To understand Haskell in general you need to realise do, bind and return are generic and can be used for not just IO but say for Maybe, List etc. Basically you need to know most practical things about monads! I had a bad time writing Haskell do notation until I understood monads. I used to write imperative code, try =, try <-, always undo typing back to known working states etc. to try and magic the code into compiling.
- kqr 5y agoThat's a good point. It was long enough since I learned this stuff that I mentally translate "Monad m => m a" into "IO String" for example in type errors, to the point of not even noticing how cryptic the generic types can be!