Original Post
This is a question that's been bothering me for some time. I've played with Haskell mainly, and read what I could find in the internet, but I've never found a complete answer. So I'm hoping for some functional-programming gurus here to help me out. Basically, I keep reading that functional programming eliminate the need for states, and thus it solves problems without introducing side-effects. I can understand how that solves some problems, but I'm completely baffled on how it works for others. Does functional programming really solves all problems without using the concept of 'state', or it just solves those that don't need that concept and just doesn't deal with ones that do need it? For instance, let's take the simplest example: We want a function that updates a database. I'm completely lost on how this can work together with 'no state' and 'no side-effects'. Isn't a database a 'state'? And isn't updating/writing/deleting records of a database a side-effect? How would a (pure) functional language handle a simple program of 'Allow the user to update records'? If we use monads, like in Haskell, we essentially re-introduce the concept of 'state' and 'side-effect'. So how is it done without all that? Thanks in advance. If you also could provide an example in a functional language on how what I ask(updating a database) would be achieved, I would be forever grateful :)