functional-mvvm icon indicating copy to clipboard operation
functional-mvvm copied to clipboard

A demo of a GUI application with an MVVM-like architecture where model and view model are purely functional.

functional-mvvm

This is a small demonstration of an MVVM architecture in FP style. Although the efforts of existing well-known F# projects dealing with MVVM and MVC are commendable, I personally wanted something more idiomatic. It is a shame not to aim for an architecture, where state and mutability is confined as much as possible to the layer which is inherently stateful and mutable -- the view.

A short search did not lead to any satisfying results, so I developed this architecture by combining the good properties of MVVM and the Elm architecture. One thing about the Elm architecture which I wanted to avoid is the same "problem" as with MVC: the model must contain state related to view-only considerations. A simple example of this is when data can be displayed sorted in various ways, while the model does not care about sorting, according to its domain definition. Thus, MVVM is the way to go, where the view model is, by definition, the place for such "noise".

The result is a small WPF application where both the view and view model (written in F#) are pure and only the view (written in C#) is unavoidably stateful. Comments, questions and suggestions are welcome (in the issue section).