Database operations are just state transformers, which are pure functions. It is the state you have to worry about, and you can wrap that state in a number of FP constructs.
Not trying to be snarky, but what is the difference between a state-transformer and a general side-effect.
The book in question gives the following explanation for what a side-effect is: "We'll be referring to effect as anything that occurs in our computation besides the calculation of a result."
This is in chapter 3, and they provide the following list for what is a possible side-effect:
- changing the file system
- inserting a record into a database
- making an http call
- mutations
- printing to the screen / logging
- obtaining user input
- querying the DOM
- accessing system state
With that in mind, there is not much I can do in my code and have a functional app without side-effects.
> With that in mind, there is not much I can do in my code and have a functional app without side-effects.
Not quite. Let's take one of those side effects as an example... say accessing system state.
You probably aren't just accessing system state. You probably want to update it in some way right? Your function to update it could easily be pure.
Take obtaining user input for example. Getting the user input is usually the most boring part of the program isn't it? The majority of what you do with that user input could very likely be pure functions.