Most Haskell tutorials teach the use of do-notation for IO.
I also started with the do-notation, but that makes my code look more like an imperative language more th
do
notation is just a syntactic sugar. It can be avoided in all cases. However, in some cases replacing do
with >>=
and return
makes code less readable.
So, for your questions:
"Shall we avoid the Do statement in any case?".
Focus on making your code clear and better readable. Use do
when it helps, avoid it otherwise.
And I had another question, why most tutorials will teach IO with do?
Because do
makes IO code better readable in many cases.
Also, the majority of people who starts learning Haskell have imperative programming experience. Tutorials are for beginners. They should use style that is easy to understand by newcomers.