Functional Web Development with Suave

One of the myths about F# and functional programming is that it is only good for complex mathematics. This could not be further from truth. A web server is essentially a function from a request to a response and so functional programming is a perfect fit for it.

In this one-day workshop, you'll learn all you need to get started with building web applications in F# using the Suave.io server. We'll start with an walkthrough that introduces the basic F# concepts and constructs and uses them to build a simple interactive web site. By the end of the workshop, you'll write a application that accesses multiple external data sources asynchronously, uses agent-based programming model and WebSockets to send data to the client and can be easily deployed to Azure or Heroku.

Takeaways

The course requires no prior functional programming knowledge, but if you have done some F# before, we have many fun bonus problems for you. You will learn:

  • How to model domain using functional types and write functions that work with it
  • How to use type providers to access JSON-based REST services, CSV and XML data
  • How to write web applications using Suave & deploy them to Heroku and Azure
  • Writing reactive web applications using web sockets, asynchronous workflows and agent-based concurrency with MailboxProcessor

Course structure and requirements

A brief theoretical introduction to every concept will be followed by numerous practical demos and exercises. At the end of the workshop, you'll leave with a complete real-world F# application.

The course doesn't require prior experience with F# or functional programming. You will need a laptop with F# installed.

Course outline

In the course, you get to work on one or more sample projects. After explaining the basic Suave concepts, we'll give you a basic template with a plenty of fun exercises that gradually introduce the library and the F# language. Here is a list of sample projects that we did in the past.

Pollz: Simple polling web site

Create a simple polling site that reads poll information from JSON data, lets the users vote in different polls, saves the results and even visualizes results of polls using charts.

As a bonus problem, you can also monitor the poll status using WebSockets and refresh the results whenever another user votes.

WhatsF#app: The $900 million chat

In this demo, you get to create a simple chatting site (be it WhatsApp or Slack). Users can enter one or more chatrooms, send messages to the rooms and see what is happening. On the backend, agent-based architecture using F# MailboxProcessor is used to handle requests in a scaleable way.

MoonBot: Cortana's stupid little brother

Write a question. Get an answer. Or maybe not, because MoonBot is not as clever. But if you program it, it will be! The idea is to write a bot that can find interesting information such as news, weather forecasts, stock prices or even Urban Dictionary definitions. This is a great way to learn how to call services and access a variety of data sources.

What attendees say