Fable is a compiler that lets you write your web UI in F# and change it to Javascript. This has development benefits of immutability, static types, and discriminated unions (Sum Types). These benefits alone make for more predictable functions and fewer bugs. There is also a library that let’s us use an Elm like architecture for added stability and fun.
Prerequisites
We need to install a few things before we can create the project:
- .Net Core 2
- NodeJS
- Yarn (package manager)
Installing the .Net Core Templates
In your console, enter the commands:
> dotnet new -i Fable.Template
> dotnet new -i Fable.Template.Elmish.React
Creating and Running Our Elmish App
After the templates are installed we can create and run our Elmish app by using the commands:
> dotnet new fable-elmish-react -n MyProjectName
> cd MyProjectName
> dotnet restore
> cd src
> yarn install
With all the dependencies installed we can now run the app using:
> dotnet fable yarn-run start
Open your browser and navigate to localhost:8080.
If we just want to build the app:
> dotnet fable yarn-run build