In coursera course Functional Program Design in Scala Martin Odersky show a sample FRP implementation. You can see the summary here.
At the end of the lecture 4.3 some ideas for improvements where given :
There's actually another possible solution, which is much cleaner and that is to simply pass down the current caller into all the signal-valued expressions. Now if we do that explicitly, it would produce a lot of overhead. Essentially, every signal-valued expression has to have another parameter and these parameters have to be threaded through everything. But if you make the parameter implicit, then a lot of that burden can actually be avoided. So the idea is that instead of maintaining a thread-local variable, we pass its current value into a signal expression as an implicit parameter. And it's purely functional, but it currently requires still some more boiler plate than the thread-local solution because essentially expressions have to close, have to take this implicit value as a parameter. Future versions of Scala might actually solve that problem, so we're currently tinkering with some ideas how that could be streamlined.
The idea was demonstrated in this talk "Plain Functional Programming" by Martin Odersky at Devoxx 2017
This dotty feature is called Context queries. (previously named implicit function types)
This WIP is an attempt to implement a Sodium FRP implementation with implicit function types.
- Comparative demo from the transaction use case mentioned in the announce blog post by Martin Odersky (with a Reddit discussion).
- Example code in dotty-example-project.
- The paper "Simplicitly: Foundations and Applications of Implicit Function Types" and some rants from Edmund A. Noble.
- Most recent talk "Simplicitly: Foundations and Applications of Implicit FunctionTypes" by Martin Odersky at POPL 2018