If you are confident, that you will not need the counter state at the end and
that you will not combine blocks of code using the counter
(where the second block needs the state at the end of the first block),
you can enforce a more strict scheme of usage.

1.3 Safety

This page addresses an aspect of Haskell style, which is to some extent a matter of taste. Just pick what you find appropriate for you and ignore the rest.

With

do

notation we have kept alive a dark side of the C programming language:

The silent neglect of return values of functions.
In an imperative language it is common to return an error code and provide the real work by side effects.
In Haskell this cannot happen, because functions have no side effects.
If you ignore the result of a Haskell function the function will even not be evaluated.

The situation is different for

IO

:
While processing the

IO

you might still ignore the contained return value.

You can write

dogetLineputStrLn"text"

and thus silently ignore the result of

getLine

.

The same applies to

do System.Cmd.system "echo foo >bar"

where you ignore the

ExitCode

.

Is this behaviour wanted?

In safety oriented languages there are possibilities to explicitly ignore return values
(e.g. EVAL in Modula-3).
Haskell does not need this, because you can already write

do_<- System.Cmd.system "echo foo >bar"return()

Writing

_<-

should always make you cautious whether ignoring the result is the right thing to do.
The possibility for silently ignoring monadic return values is not entirely the fault of the

do

notation.
It would suffice to restrict the type of the

(>>)

combinator to

(>>):: m ()-> m a -> m a

This way, you can omit

_<-

only if the monadic return value has type

()

.

New developments:

GHC since version 6.12 emits a warning when you silently ignore a return value