Working with F# projects in VSCode

Working with F# projects in VSCode

Introduction

Visual Studio Code is a lightweight but powerful source code editor which runs on your desktop and is available for Windows, OS X and Linux. It comes with built-in support for JavaScript, TypeScript and Node.js and has a rich ecosystem of extensions for other languages (C++, C#, Python, PHP) and runtimes. The F# support for VSCode is provided by Ionide - set of extensions adding F# support, as well as Paket and FAKE.

If you’re new VSCode user installing extensions is pretty easy - press extensions button on left panel, search for Ionide, press install for all Ionide extensions, wait untill all are installed and restart VSCode.

Ionide-FSharp provides wide set of features useful for F# developer - from simple autocomplete and tooltips, through F# Interactive integration, to navigating to symbols or finding all usages of symbol.

It also comes with decent support for F# projects (defined using .fsproj file).

read more

Creating custom project file for F#

Creating custom project file for F#

Introduction

Let’s imagine a world where F# is independent language, with cross-platform tooling making life of every F# developer easier. In this world, after we’ve fixed dependency management problem with Paket, we could go one step further… and fix project file format and building. We would use same principles as Paket - very simple, human readable, file format which can be edited without any other tooling, and command line tool responsible for building such project.

In such world I’ve decided to create new open-source project called Chris

File format

For our hypothetical project file (called project.chris) I’ve decided to use toml. In this very simple file we would just specify few properties, files of our project, GAC references and external NuGet packages. It would look like as follows:

[Info]
Name = "Fancy_Test_Project"
Author = "Lambda Factory"
Git = ""

[Stuff]
References = ["mscorlib", "System", "System.Core", "System.Numerics"]
Files = ["Message.fs", "Test.fs"]
Packages = []

read more

Getting started with Fable and Webpack

Getting started with Fable and Webpack

Introduction

Fable is new F# to JavaScript compiler created by Alfonso Garcia-Caro. In this post I’ll go, step by step, through process of creating client-side (browser) applications using it.

This post is targeted at F# developers without lot of knowladge about Node.js and JS ecosystem and it should let any F# developer to get started with Fable.

Requirements

Fable requires having both F# 4 and node 4.4 or bigger installed in your computer.

read more

Creating VS Code plugins with F# and Fable

Creating VS Code plugins with F# and Fable

Introduction

EDIT 22.03.2016 Thanks to Alfonso’s help I was able to remove postbuild step fixing JS.

VS Code is new text editor (or rather lightweight IDE) created by Microsoft. Because it is product based on Electron - cross platform engine allowing developers to write desktop applications using web technologies - its plugin system supports JavaScript (and TypeScript). Unfortunately both those languages are not nice choice for someone using statically typed functional programming languages like F#. Up to this moment in my VS Code extensions I was using F# library called FunScript which compiles F# code to JavaScript. Whereas it sounds nice, library has some problems which makes writing code using it not nice experience. Fortunately recently, Alfonso Garcia-Caro, one of contributors to FunScript, has decided to create new project compiling F# to JS (with Babel as middle step) called Fable which hopefully will solve some of the FunScript’s problems. I have decided to investigate how this new library can be used to create VS Code plugins… using VS Code to code and compile those plugins.

read more

Using Node.js and NPM with Paket and FAKE

Using Node.js and NPM with Paket and FAKE

Introduction

Web development is great fit for F# and Functional Programming . Libraries like Suave or Freya makes it easy to create well-architectures, composable web applications. But that’s backend part of story. Nowadays most web applications are required to have lot of user interactions and logic on the front-end side - in the browser.

Two important tools for front-end JavaScript development are Node.js (JS backend server, used for running many JS development tools) and npm - package manager for Node.js. Those 2 tools are often installed globally on developer PC, are used to define dependencies for front-end application, and define build pipeline for it.

But, using different build tools for backend and front-end development in one application can get annoying and tiresome for developer, so it would be nice to use one build pipeline for all tasks. And it is possible with Paket and FAKE.

read more