Skip to content

fcolavecchia/fp-course-public

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Make F# your first functional programming language

From outside Argentina, you can

Buy Me A Coffee

En Argentina (⭐️⭐️⭐️)

Invitame un café en cafecito.app

Si te interesa el contenido en español, mirá LEEME.md

About the course

These guides are oriented to those programmers interested in learning some concepts on functional programming, from a practical perspective. F# is an excelent first functional programming language: it is functional (of course), it has a clean and readable syntax (not a lot of fancy symbols and stuff), it is flexible (in case you need to grasp some other paradigm in the middle of your code) and it is concise enough to express your ideas with clarity.

Learning a new language and a new programming paradigm is a wonderful adventure. You do not need any special preparation, although I assume that the reader has some background in at least one popular language (let us say C, Python, Java or JavaScript, for example).

This guides are entirely written as Jupyter Notebooks. Yes, it is possible to run F# in a Jupyter notebook interactive environment, which is fantastic for learning.

The path of the course starts at functional programming, then delves into F# and finally .NET is introduced as a vast, resourceful library. No experience in the .NET ecosystem is needed! The course is aimed to the understanding of the functional side of F#. I purposedly left aside many possibilities that the language offers, but drift apart from this core of the course. Hopefully so of them can be revisited in more advanced lessons.

If you need the course in other language, you can use nbTranslate, a Jupyter notebook extension that creates multilanguage notebooks by translating the content using google translate. Follow the instructions in those sites to get it work.

I tried to reference all the material to their respective authors. If you find some of your work unreferenced, drop me a line and I will gladly include it.

Quick start

The course is structured as a collection of Polyglot Jupyter Notebooks. A Jupyter Notebook is a simple application that enables one to run chucks of code in cells, that can be intertwined with text, plots, math, etc. The notebook attaches itself to a kernel, that takes care of executing the code in a web browser. The most popular language used in notebooks is Python, however, many different languages can be used. A polyglot notebook includes the chance to run many different languages, F# among them.

To run the lessons as is, just open this repo in MyBinder:

Binder

Give it a little time, and this will open the notebooks in your web browser.

Open the one of your choice, check that the Kernel on the right is properly selected:

It automatically detects .NET C#,

I do not want C#

but that is not the language you are looking for:

This is it

and you are good to go.

Fork it

If you want to play around the guides, make the exercises, etc., it is better to get your own copy of this repo by forking it.

Using Binder to run your repo

Once you fork the repo, go to MyBinder. You will land into this page:

Binder landing page

Copy the url of your forked repo into the GitHub field, and you can leave the Git ref and Path to a notebook empty. Click on launch and wait a while until My Binder works the magic.

One the binder is opened, click on the es (en español) or en (english version) directory in the panel at the left, and you will see all the available notebooks.

I do not want C#

Follow the instructions above to select the F# kernel.

Installing polyglot notebooks to run in your own computer

If you want to experience the notebooks at your own computer, you need to install the polyglot extension for VS Code. Follow the instructions there to get everything working offline.

I do not want to use the notebooks!

No problem! Simply copy/paste the codes from the notebooks in the repo into Fable REPL, which is an online F# compiler. Just write your code in the left pane, click the usual play button (or Alt+Enter) and that's it, you're programming in F#!

Content

Functions

Types

Control Flow

On collections

More on collections

Managing Errors

Intermezzo: A classic Kata

Intermezzo: Exercises

Input/Output

Processing structured data files

Welcome to .NET!

Tests

Coda: More exercises

This is an opinionated list of web resources and books that helped me with F#. These are books and sites I use frequently, for a more a complete list of resources, check the list of the F# Foundation and the learning resources in Microsoft .NET site.

Books

  • Stylish F# 6 by Kit Eason. Loved the first chapter about the sense of style in programming, and the next chapters follows that spirit.

  • Essential F#, by Ian Russell. With a big difference from other approaches, this book starts with a full example in F# that is througly discussed, and then presents the elements of the language in the next chapters.

  • Beginning F# 4.0, by Robert Pickering and Kit Eason. Just a little outdated (we are now at version 7.0), approaches the language from its different paradigms, from functional to object oriented to imperative programming.

  • Expert F# 4.0, by Don Syme, Adam Granicz, Antonio Cisternino. By the very same creator of the language, it also showcases the flexibility of F# to adopt different programming paradigms. The examples are advanced in general, but useful to understand deeply the inner works of F#.

Functional Programming with F#

Web Development resources

  • Fable, the amazing transpiler from F# to JavaScript (and lately, other languages. Is not just a compiler, but a way to use these languages together. Depending on the recipe you would like to prepare, add the ingredients at your own pleasure. Also, check Fable REPL, where you can sketch with F#, no installation of anything needed

  • Feliz is kind of hard to define, but basically it enables you to build and/or interact with React components directly in F#.

  • Feliz.Bulma is a wrapper around the well-known Bulma CSS framework, tailored to the Feliz DSL.

  • Html2Feliz enables you to translate plain HTML into Feliz.

  • SAFE Stack is a full fledged F# framework to build web applications. It takes care of the front end, the backend and even the deployment into the Azure cloud.

High performance F#

  • Topological sort in F# by Matthew Crews. In this fantastic series, Matthews starts with a pure functional version of a topological sort, and squeezes all the (rather advanced to me) features of F# to speed up the code.

Other interesting articles

fun stuff

The interview.

Interesting videos

A playlist of videos somewhat related to this content.

Some people to follow

Educational Resources

Misc stuff

  • Instructions on how to build .NET to work Binder here and copied config files from here, updated to .NET 7.