I need a global counter, starting from 0, 1, 2, 3, .....
I kind of understand that this \"impure\" code should be separately implemented... I am just starting to understand
While State is fine, you don't need to inspect the counter while calculating, but just to increase it, so the Writer monad should be sufficient. See Learn you a Haskell for a (not too serious) introduction.