Reflex for CLI apps - Haskell

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

Sridhar Ratnakumar

Sridhar Ratnakumar said:

https://twitter.com/sridca/status/1308989316731985923

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.

Sridhar Ratnakumar

The first thing we need is runHeadlessApp, which provides a simple reflex host for running basic stuff.

Sridhar Ratnakumar

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.

Sridhar Ratnakumar

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

Sridhar Ratnakumar

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.

Sridhar Ratnakumar

Details: https://twitter.com/sridca/status/1312062194968924161