question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fabulous with Incremental/Adaptive Views

See original GitHub issue

In “Data Driven UIs Incrementally” (Strangeloop 2018 talk) Yaron Minsky goes through how they built a diff+patch approach on top of functional data structures using incremental to structure the process of updating the model in the Elmish architecture as an incremental computation.

But I still think this falls short of what could potentially be achieved by integrating all of these pieces into a compositional primitive to make it a lot easier to build and extend reactive user interfaces in F#. An abstraction similar to Active Expressions should be possible, although the underlying implementation would be built on an incremental computation model.

If Fabulous was extended to support this kind of architecture maybe it would make sense to decouple that from Xamarin.Forms? Xamarin.Forms would still be the canonical implementation, but if someone wanted to plug in say Avalonia instead it would be amenable to it.

Further Reference

Blog Posts

Papers

Repos

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:14
  • Comments:22 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
dsymecommented, Sep 25, 2019

A quick update: we are working on an incremental/adaptive data library for F#, based on the core of the Aardvark adaptive data implementation, which is tried and tested

https://github.com/fsprojects/FSharp.Data.Adaptive

Early days yet, but I’d like to next experiment next with an adaptive-data version of Fabulous ViewElements. I’ll post here if/when I make progress.

See also https://github.com/krauthaufen/aardvark.web/blob/master/src/Aardvark.UI.Web/DomNode.fs#L13 for an adaptive DOM node type

See also https://github.com/aardworx/aardvark.web/blob/master/src/Aardvark.UI.Web/Ui.fs for the web of reader/updater objects that sit on top of the adaptive data and propagate changes to the DOM

3reactions
dsymecommented, Jul 8, 2019

Watching through Minsky’s excellent talk, I notice the following:

First, from about 25min in, I see F# immutable maps should support a “symmetric diff” operation with signature such as

val symmetricDiff: Map<'K,'V> -> Map<'K,'V> -> ('V -> 'V -> bool) -> seq<'K * Choice<'V, 'V, ('V * 'V)>>

It is necessary to implement this on the core tree of the Map data structure to allow pointer-equality on the internal Map structure to be used as a way of detecting “no change” within incrementally derived maps.

Next, I wonder if there is scope to experiment with a quotation-based “incrementalization” of Fabulous programs. My thinking is that we put ReflectedDefinition on all the MVU code, and then

mkIncrementalProgram <@ init @> <@ update @> <@ view @>

does a somewhat sophisticated derivation of an incrementalized version of the MVU program. This would include an incrementalized model type under the hood (not made explicit to the programmer). For example, if the model contains

type Model = { Value : int }

and the update function (unsurprisingly) does incremental updates to Value for some messages, then the incrementalized program uses a model

type Model' = { Value: Incremental<int> }

in either a Gjallahorn or Self-adjusting computation version of incrementalized or reactive computation. The update function would be rewritten to be Model' -> Model' and the view function would be rewritten to be an incrementalized view Model' -> dispatch -> Incremental<View'>. The process of consuming the incremental view would then be ultra-fast, and would not involve re-evaluating the whole view.

The Model' type would not be explicit to the user and might not actually be generated as a class (it would exist logically in the implementation of mkIncrementalProgram but not otherwise).

The approach might be extended to allow the use of any data structures in the model that support “diff” and “patch” operations with respect to an underlying incremental-friendly representation, and the ability to correlate those with the actual canonical update code.

This would be a bit of a research agenda but feels somewhat tractable - it is effectively rediscovering the Xaml/Gjallahorn-style binding structure from the static structure of the code where possible, and would resort to dynamic view re-execution where not possible. An advantage over the OCaml-style code presented by Minsky is that the user would not have to program explicitly using Incremental nor Rx-style combinators but can just program in the naive functional programming way. One disadvantage is that the user may not understand which parts of the code are executing incrementally and which are executing using view re-evaluation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fabulous with Incremental/Adaptive Views · Issue #258
Forms with another UI Framework (Avalon, Uno, native Android/iOS, etc.) is a recurring question. I think nothing prevents to decouple Xamarin.
Read more >
How to become a Fabulous developer | Timothé Larivière
The F# compiler will be there to help you. Virtual views and incremental updates. For performance reasons, the views you write don't directly ......
Read more >
Adaptive Views - Axure Docs
Adaptive view sets contain a series of views organized into a chain of inheritance. The first link in that chain, the view from...
Read more >
Some links I like on adaptive methods like PDIA
PDIA suggests that a more adaptive approach is required to do development when complex challenges are being faced. The approach emphasizes ...
Read more >
Incremental Innovation: Long-Term Impetus for Design ...
This framework has academic and business ramifications: it can provide guidance and ideas to other design teams looking to execute their design business...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found