I've been playing with using reflex for a new CLI app, and I figured I'll document my learnings along the way. I'll use this topic as a dumping group for the various little things, before compiling a proper series of blog posts.
I struggled a bit to model my CLI behaviour in FRP style yesterday, but with a bit of experimentation and learning it is certainly possible to internalize it.
Oh, and this blog post indicates what it would look like to rewrite shake-based ghcide using reflex. It uses some advanced reflex concepts, like Incremental and PatchMap, that I probably wouldn't need for my project.
Funny how during the first attempt I ended up writing code in traditional FP manner, instead of using FRP. Now I'm gonna rewrite the bulk of it. Just like imperative->functional, it takes explicit effort to rewire your mind to think in terms of the new paradigm.
In particular, defining events and behaviours declaratively in terms of one another - rather than building state and updating using functions from all over.
Okay, first step is to learn it properly myself!
I'm writing a FRP-based CLI app.
Initial attempt: I ended up (unknowingly) using "traditional" FP model.
Now rewriting the bulk of it using events and behaviours.
Like FP, writing FRP has an initial "getting used to" period. https://twitter.com/sridca/status/1308989316731985923
Sridhar Ratnakumar said:
Looks like there has been enough interest.
I've been playing with using reflex for a new CLI app, and I figured I'll document my learnings along the way. I'll use this topic as a dumping group for the various little things, before compiling a proper series of blog posts.
The first thing we need is
runHeadlessApp
, which provides a simple reflex host for running basic stuff.I struggled a bit to model my CLI behaviour in FRP style yesterday, but with a bit of experimentation and learning it is certainly possible to internalize it.
Oh, and this blog post indicates what it would look like to rewrite shake-based ghcide using reflex. It uses some advanced reflex concepts, like Incremental and PatchMap, that I probably wouldn't need for my project.
https://mpickering.github.io/posts/2020-03-16-ghcide-reflex.html
Funny how during the first attempt I ended up writing code in traditional FP manner, instead of using FRP. Now I'm gonna rewrite the bulk of it. Just like imperative->functional, it takes explicit effort to rewire your mind to think in terms of the new paradigm.
In particular, defining events and behaviours declaratively in terms of one another - rather than building state and updating using functions from all over.
Details: https://twitter.com/sridca/status/1312062194968924161
Okay, first step is to learn it properly myself! I'm writing a FRP-based CLI app. Initial attempt: I ended up (unknowingly) using "traditional" FP model. Now rewriting the bulk of it using events and behaviours. Like FP, writing FRP has an initial "getting used to" period. https://twitter.com/sridca/status/1308989316731985923
- naiveté - the most liberal condition ever possible (@sridca)