Haskell on Bash/WSL



I’ve recently received a couple of questions asking when Haskell support would be added to WSL, and was surprised since I thought Bash/WSL users were aware of the fact that Haskell has been working for the last few weeks, ever since #14986 in fact, but it appears that we’d not explicitly communicated the fact, so … here we are! 🙂

Haskell now runs in Bash on Windows!*

** You’ll need to be running Windows 10 Insider build #14986 or later.*


Haskell is a popular and powerful functional programming language which wasn’t able to run on Bash/WSL in Anniversary Update or earlier Insider builds, because WSL had not yet implemented the timer_create() syscall. Now that WSL builds >= #14986 do support timer_create() we can run Haskell and many other tools (e.g. Elm, Cabal, Pandoc, Agda, etc.) 🙂

Note: You can, as with most modern dev tools, also run Haskell very happily on Windows, although you may find some packages and add-ons require Linux, which is where the ability to run on Bash/WSL comes in!

Hello World in Haskell

Let’s create a Haskell Hello World sample:

First, install the Glasgow Haskell Compiler:

$ sudo apt install ghc

While we could run the Haskell interactive REPL, the GHC compiler can, of course, also compile Linux executables:

Open your favorite Linux editor (mine is Vim) creating a new hello.hs file

Now enter the following Haskell code:

This declares a main function whose implementation calls putStrLn that writes “Hello World” to stdout.

After exiting your editor (:wq[Enter] in Vim ;)), compile this file by typing the following:

This will generate a Linux ELF64 binary file called hello, along with hello.hi and hello.o, which are just intermediate compilation files. You can check the hello binary using the file tool:

You can now run the binary (note: the ./ prefix is required when executing a local binary):

Congratulations, you’re now on your way to being a Haskell guru 🙂


Rich Turner

Sr. Program Manager, Windows Console & Command-Line

Follow Rich   


    Leave a comment