1

Motivation : "functional programs" focus on being "pure", and we all know what "pure" is : referential transparency, "no-effects", etc...

but the problem is that this only one side of the coin.

I have not yet seen a clear definition of what an effect is.

In Haskell for example practically every non trivial "Monad" can be considered as an "effect" and there gizillion types of specific monads out there ... the problem is I don't see what is the connection between them ?

Say : [] (List) Monad vs State monad vs IO monad vs Future monad etc... how are these all effects ?

What do they have in common ?

I understand intuitively that these are all "effects" but how ? Why ? What connects them ? When the values of these types (say [a]) are itself "effect-less"/pure/immutable ?

The answer I am looking for is not "anything that is not referentially transparent".

That is a "negative answer", I am looking for the opposite "type of answer", something that tells me what IS an effect and not what is it NOT.

Especially the question lies in : IO is the "ultimate" effect. Now, in what sense do we/can we/should we divide IO into "sub-effects" that are "non-interacting" => this brings us towards one possible answer: Monad Transformers. They try to solve the problem of composing effects BUT they do not themselves answer the question : what is an effect ? More importantly, how should I devide a "large/wide effect" (such as IO), into "smaller"/"narrower" effects, such as [], Future, Cont, Writer, Reader, State, Maybe etc... ?

The answer to the question : what is an effect should serve as a possible inspiration to solve problems such as the above "how to divide IO" into "sub"/simpler effects ?

Thanks.

jhegedus
  • 20,244
  • 16
  • 99
  • 167
  • Not sure if it has the precise/clear/short answer you are looking for, but here /r/haskell discusses "What is a side effect" https://www.reddit.com/r/haskell/comments/2p9cvz/noob_question_what_is_exactly_side_effect/ – Thilo Nov 22 '18 at 07:21
  • 3
    "Monads can be considered an effect" is a weird thing to say. The two concepts seem fairly orthogonal. As you say, monads provide an abstraction to deal with composition. Some monads (such as a List) have nothing to do with effects at all. Others (`IO`) provide a way to deal with effects in an otherwise pure world. – Thilo Nov 22 '18 at 07:24
  • 1
    (1) Do let us know if you think the suggested question does not suffice. (2) The suggested question does not discuss monad transformers, but I don't think that is essential: the broader notion of effect generalises to applicative functors, which do not need transformers to be composed. (3) @Thilo : On the matter of orthogonality, I'd say that "effect" has two meanings in common use -- a narrower meaning which is orthogonal, and a broader meaning that is not. My answer to the suggested question makes this case in some detail. – duplode Nov 22 '18 at 10:30
  • thanks for comments, just got home from work, gonna think about this a bit more and get back to your comments once I thought about this a bit more – jhegedus Nov 22 '18 at 18:08

0 Answers0