-2

This is not a simple question I understand that. Hence, pointers would be well appreciated (or enough)

I have tried to decipher multiple posts on here e.g.

that explain how the overaching principle of FRP "among other" solve the issue that the observer try to solve. I suspect i would need to study how library like ZIO or fs2 actually solve the issue in a purely functional way.

But i wonder if before diving into the implementation detail, there is not a way, to reduce this to its essence and give the general idea that solve the main drawback of the observer pattern to achieve event driven code.

An intuition that i have so far is that FRP "among other" decouple the Observer and observee basically via for example a queue, which can be hidden behind the concept of MailBox in akka stream for example.

So in short my question is: "In Essence" what approach does FP take to solve the issue that the observer pattern solve in OOP. I'm not asking explanation about how the Observer does not match FP with for example by being side-effecting in essence. This is well documented all over, but rather what is the "Essence" of the solution taken in FP (independent of how complicated it is to implement it)

MaatDeamon
  • 7,821
  • 5
  • 46
  • 96
  • 3
    You are using the terms "functional programming" and "functional reactive programming" interchangeably. Or at least, it reads this way. Can you clarify or correct this? – ziggystar Apr 30 '21 at 11:06
  • I know but in fact my assumption here is that the FR approach is to use the FRP principle. I’m interested in how FR does it indeed. – MaatDeamon Apr 30 '21 at 11:07
  • Can you suggest some correction to help maybe ? – MaatDeamon Apr 30 '21 at 11:09
  • Maybe begin with the question. Do you want to write FP or FRP there? – ziggystar Apr 30 '21 at 11:09
  • I don't think there is necessarily **the** FRP approach - there are different [formulations](https://en.wikipedia.org/wiki/Functional_reactive_programming#Formulations_of_FRP), implementations, etc – Carsten Apr 30 '21 at 11:09
  • Those post that I share talks about FRP where really the question is how FR handle it. – MaatDeamon Apr 30 '21 at 11:10
  • 1
    Read [Oderski's paper](https://stackoverflow.com/questions/11619680/why-should-the-observer-pattern-be-deprecated) referenced in the post you linked to. It's 18 pages long, but you can skim over :) There are concrete examples (as in code snippets) there illustrating the idea. – Dima Apr 30 '21 at 11:11
  • Scala will *handle* it differently then Haskell (and with it I mean -something like observer-pattern- or -someform of FRP-ish library-) - I guess if you don't get Conan or Eliot to answer here this will be more or less *opinionated* – Carsten Apr 30 '21 at 11:12
  • Ok let me think about it a bit and change that appropriately – MaatDeamon Apr 30 '21 at 11:12
  • btw: that's the link to [Oderski's paper](https://infoscience.epfl.ch/record/148043/files/DeprecatingObserversTR2010.pdf) in case you don't want to detour via the SO question and go directly to source – Carsten Apr 30 '21 at 11:15
  • humm, thank you for the pointers, but i still think that there is room for a focused answer. This question should not be closed. We should allow, someone to be able to reduce to the essence the 18 page long answer, or other such as in the haskell world. This question focus on the solution, not the problem, and hence is worth having it answered i think – MaatDeamon Apr 30 '21 at 11:16
  • The first page or two of Oderski's paper describe the problem. Remaining 15 discuss _the solution_ :) – Dima Apr 30 '21 at 12:13
  • Alright guys. Thanks for the input. Will do my homework :) – MaatDeamon Apr 30 '21 at 12:14

0 Answers0