I've been considering how you would write a business application in only F# with WPF. Here's my thinking of a general outline of how to go about it, but I'm looking for whether or not it will work:
- Start with ADO.NET Entities to automatically generate a data access layer.
- Since F# doesn't support partial classes, use F# Extension Methods to create a BLL that extends the entity objects with extra members (these will have to mutate the entities)
- Instead of writing explicit ViewModels, write F# functions that build ViewModel objects on the fly using object expressions.
- Write an F# function that uses Active Patterns and Decision Trees to build WPF Views on the fly, given ViewModel objects as input. It would also take care of setting up bindings between the View and ViewModel objects.
So, opening a form or page would involve executing a function to generate a ViewModel object instance, and then passing that to the function that builds a View from the ViewModel, and then setting that as the content of your Window. From that point on, it executes in a normal "mutable" MVVM way.
My knowledge of F# is still limited, so I may be going down the wrong rabbit hole here.
Question(s):
- Will this work (in general), or not?
- Is there a better way that you know of?