F#
F# is a cross-platform, open-source functional programming language that runs on the .NET platform. It features strong type inference, pattern matching, and a concise syntax that also supports object-oriented and imperative programming styles.
In LiveCodes, F# code is compiled to JavaScript using Fable, an F# to JavaScript compiler. The compiled code runs in the result page, giving it access to the page DOM and browser APIs.
LiveCodes also supports running F# on the real .NET runtime using a WebAssembly-based F# compiler. Read documentation here.
Usage
Demo
JavaScript Interoperability
Since F# code is compiled to JavaScript and runs in the context of the result page, it can interact with the page DOM and browser APIs using Fable's browser bindings (e.g. the Browser.Dom module).
Check the starter template for another example.
Language Info
Name
fsharp
Aliases / Extensions
fs, fsx, fsharp
Editor
script
Compiler
Fable, the F# to JavaScript compiler.
Version
Fable v3.8.0 (targeting F# 8)
Code Formatting
Not supported.
Example Usage
module Hello
open Browser.Dom
let main () =
let name = document.querySelector("#name")
name.textContent <- "F#"
printfn "Hello from F#!"
The starter template shows a more complete example that demonstrates DOM access and event handling.
Starter Template
https://livecodes.io/?template=fsharp
Links
- F#
- F# documentation
- Fable
- F# (Wasm) in LiveCodes