Quantcast
Channel: Should do-notation be avoided in Haskell? - Stack Overflow
Viewing all articles
Browse latest Browse all 8

Answer by Sergey Bolgov for Should do-notation be avoided in Haskell?

$
0
0

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.


Viewing all articles
Browse latest Browse all 8

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>