> You are mistaken. Monads do not involve mutation.
Indeed. IO and ST involve mutation. They just so happen to be instances of Monad, but that's tangential.
Indeed. IO and ST involve mutation. They just so happen to be instances of Monad, but that's tangential.
In reality they're implemented in a mutation-heavy way for performaance reasons, but on the language level absolutely no mutation happens ( it's the whole World -> (Result, World) analogy)
putStrLn "What is your name?"
>> getLine >>=
\name -> putStrLn ("Hi, " ++ name ++ "!")
It's just a giant chain of instructions, each previous result feeding into the next. Nowhere do we assign anything, modify anything, etc. No mutation.