Better HN
topnewbestaskshowjobs
Log inSign up

jbrownson

3 karma · joined Jun 14, 2026 (5mo ago) · 2 submissions

Submissions

comment 5mo ago · link · parent

Yeah higher kinded types, Mr. Freeman's Purview demonstrates the idea applied to UI: https://github.com/paf31/purescript-purview

I'm not referring to FRP, just a bunch of functions that can render a frame of UI if you pass in all the "internal state" like cursor position/selection/scroll in addition to the typical UI parameters. Xilem and others are doing a good job of making a lot of things modular, but I haven't seen one actually separate how the UI state is stored from the rendering of the UI.

comment 5mo ago · link · parent

Everyone seems to be converging on React/Elm arch for UI. I saw a paper years ago for incremental lambda calculus (https://inc-lc.github.io) that I feel addresses the fundamental problem here more honestly. It's mostly intended for optimizing repeated computations after small changes to the inputs, but I think it applies nicely to UI. Our data model needs to be a change structure along with our UI model. We write a function from our data model to the UI model just like React, but we also get a function from deltas on the data model to deltas on the UI model. The main thing missing that we would need for UI is since we get a stream of deltas on both the data model and UI model (scrolling, selecting, etc) we need to merge them.

This way we don't have to zipper together each "frame" of the output tree trying to figure out which bit goes to which other bit, we get an explicit delta saying "the 5th thing got deleted". You do probably need a language with HKT for this.

I mentioned this to Phil Freeman years ago and he did a prototype in Purescript, but I haven't seen it anywhere else: https://github.com/paf31/purescript-purview

Another thing I'd like to see is a _truly_ immediate mode framework where each widget is a pure function to render it given its state, and it's up to the user to manage the UI state (scroll position, text cursor location, etc), you can mix it in with/ your data model, or whatever. Even egui/etc aren't truly immediate as they need to keep some sort of stable identity for events, UI state and focus. You could of course build a React like thing on top of that, but it would be helpful to have that for experimentation with wildly different state models without having to reinvent the text box and everything yet again. I've started some experimentation w/ this in Haskell and it's going well so far.