Meet Falco.

Falco is a toolkit for building secure, fast, functional-first and fault-tolerant web applications using F#.

Blazing Fast

Built on the high-performance primitives of ASP.NET.
Learn More

Easy to Learn

Designed for getting up to speed quickly.
Get Started

Native View Engine

Markup is written in F# and compiled.
See Examples


Seamlessly integrates with existing libraries.
Explore How

Hello, Falco!

Believe it or not, this is a complete Falco application. It does exactly what you'd expect. Upon compiling and running the program, if you visit https://localhost:5001/Falco, you would be greeted with:
Hello, Falco!
If you visit without specifying a {name}, "world" will be substituted in place of the name. Resulting in "Hello, world". This simple, but illustrative program demonstrates Falco's modular design, in this case specifically request interaction and response writing.
open Falco
open Falco.Routing
open Falco.HostBuilder

let helloHandler : HttpHandler =       
    let routeBinder (r : RouteCollectionReader) =
        r.GetString "name" "world" |> sprintf "Hello, %s!"
    Request.mapRoute routeBinder Response.ofPlainText 

webHost [||] {
    endpoints [ get "/{name?}" helloHandler ]

Markup? Check!

A core feature of Falco is the XML markup module. It can be used to produce any form of angle-bracket markup (i.e. HTML, SVG, XML etc.), most notably HTML. Most of the standard HTML tags & attributes have been built into the markup module, which are pure functions composed into well-formed markup at run time. HTML tag functions are found in the Elem module, attributes in the Attr module. For string literal output there are several functions available in the Text module.
The benefits of using the Falco markup module as an HTML engine include:
  • Writing your views in plain F#, directly in your assembly.
  • Markup is compiled alongside the rest of your code, leading to improved performance and ultimately simpler deployments.
Since views are plain F# they can easily be made strongly-typed, and more interestingly combined to create complex output.
open Falco
open Falco.Markup

type Person = { First : string; Last  : string }

let master (title : string) (content : XmlNode list) =
    Elem.html [ Attr.lang "en" ] [
        Elem.head [] [ Elem.title [] [ Text.raw title ] ]
        Elem.body [] content 

let divider = [ Attr.class' "divider" ]

let personView (p : Person) =     
    master "Sample App" [                     
        Elem.main [] [   
            Elem.h1 [] [ Text.raw "Your name is:" ]
            Elem.p  [] [ Text.rawf "%s %s" p.First p.Last ] 

Magic-free model binding.

Reflection-based approaches to binding at IO boundaries work well for simple use cases. But as the complexity of the input rises it becomes error-prone and often involves tedious workarounds. This is especially true for an expressive, algebraic type system like F#. As such, it is often advisable to take back control of this process from the runtime.
We can make this simpler by creating a uniform API to obtain typed values from IFormCollection, IQueryCollection, RouteValueDictionary, IHeaderCollection and IRequestCookieCollection. These readers exist as derivatives of StringCollectionReader which is an abstraction intended to make it easier to work with the various string-based key/value collections within ASP.NET.
open Falco

type CardType = Visa | MasterCard | AmericanExpress
type CreditCard = { Type : CardType; Number : int; Cvd : int option }

let handleMapForm : HttpHandler = 
    let formMap (f : FormCollectionReader) =        
        let cardType = 
            match f.GetString "card_type" "visa" with
            | "MasterCard"      -> MasterCard
            | "AmericanExpress" -> AmericanExpress
            | _                 -> Visa
        let cardNum = f.GetInt32 "card_number" 0
        let cardCvd = f.TryGetInt32 "cvd"

        { Type = cardType; Number = cardNumber; Cvd = cardCvd }

    Request.mapForm formMap Response.ofJson