A lot of the time, when we discuss the effect, we usually talk about side-effect. However, as I study more and more into functional programming and reading more and more functional programming books, I noticed many times “Effect” or “Effectful” had been widely said in the FP community when describing abstract things.
I dig a little deeper into what an “Effect” or “Effectful” means and put that in this blog post for a note to my future self.
Usually, what they meant for “Effect” or “Effectful” is no side effect (sometimes it does). It is Main Effect.
A type category is a Math Structure to abstract out representation for all the different fields in Math. When designing a program, we can think in the properties of that program before writing code instead of the other way around. For example, a function sum
can be empty (identity law), has the property of combined operation and needs to be associative. (1+2 is equal to 2+1). We can characterize them as and restrict input function to be a Monoid. This way, we can create a solution in a systematic approach that generates fewer bugs.
Within Type Category is a fancy word for a wrapper that produces an “effect” on a given type. I will quote the statement that Alvin Alexander mentioned in Functional and Reactive Domain Modeling:
Those statements can be rewritten as:
Similarly:
An effect can be said of what the monad handles.
Quoting from Rob Norris in Functional Programming with Effects — an effectual function returns F[A]
rather than A
.
#scala #programming #functional-programming #effect #side-effects