The Haskell Dojo can be set up in several ways, depending on your learning goals:
- With Jambhala Cardano Development Suite -- recommended for Cardano developers
- With Gitpod (cloud-based browser editing) -- recommended for sampling Haskell
- With a local Haskell installation (GHCup) -- recommended for non-Cardano developers learning Haskell long-term
This repository can be used as an add-on to the Jambhala Cardano Development Suite. This allows aspiring Cardano developers to complete this Haskell course within the same fully pre-configured environment they'll use to learn cardano-cli
and Plutus afterward.
If you intend to use Jambhala for learning Cardano development, follow these steps to get started with Haskell Dojo in Jambhala:
- Fork this repository.
Note: keep the name
haskell-dojo
as the name/URL slug for your fork: using this name is required for integration with Jambhala. - Install Jambhala by following the instructions in the official README.
- After completing the installation, navigate to the
jambhala
directory in your terminal and runjcode
to open Jambhala's integrated VS Codium editor:
cd jambhala
jcode
- Open the
.env
file in the Jambhala root directory and add your Github username to theGITHUB_ID
variable. I.e.:
# jambhala/.env
GITHUB_ID="iburzynski"
- Enter
refresh
in your terminal session. Your forkedhaskell-dojo
should now automatically clone itself into thejambhala
directory (and will be ignored bygit
). Exit the editor and reopen it in thehaskell-dojo
directory by runningjcode haskell-dojo
(use this same command from thejambhala
directory in your terminal each time to ensure proper functioning).
This repository contains a preconfigured Gitpod Haskell development environment, allowing you to start coding in Haskell with zero installation using Gitpod and a browser-based version of VS Code.
If you're looking to dive into Haskell quickly and aren't ready to commit to a local installation, follow these steps to get started with Gitpod:
- Fork this repository
- Copy the link to your new repository and prefix it with "https://gitpod.io/#" in your browser
- Click
Continue with GitHub
andAuthorize gitpod-io
- Wait for the environment to build. This can take a while the first time.
- Select "VS Code Browser" as your editor.
This repository can also be used with a local Haskell toolchain installation through GHCup and either VS Codium or VS Code. This method may not be ideal for new Haskellers, as correct configuration to get Haskell to work properly in VS Code can be tricky and delay the process of actually learning Haskell. Having a system-wide Haskell installation can also occasionally cause conflicts with Haskell Nix development environments, such as used by Jambhala. For these reasons it is recommended to use the Jambhala suite (if you're learning Haskell for Cardano development) or Gitpod instead.
If you do choose to install Haskell globally on your machine, be sure to do so using GHCup, which is the canonical installation method for Haskell at the time of writing, and has good synergy with VS Codium/Code. Follow the official installation process at the link above.
If you have Haskell installed locally and don't intend to use Jambhala later, the Haskell Dojo code should compile and run with cabal
for most versions of GHC. After forking and cloning Haskell Dojo on your system, navigate to the directory in your terminal and run cabal run
to compile and run the program.
For IDE support in VS Codium/Code:
- You must have Haskell Language Server installed. If you didn't choose to install this when you installed GHCup, you can do so in the
ghcup tui
interface. - You must have the Haskell VS Code extension installed.
Note: this should be installed after GHCUp to prevent duplicate Haskell binaries being created on your system, which can break functionality in VS Codium/Code.
Complete the 8 assignments in the assignments
directory sequentially, filling in the required Haskell code in the designated .hs
file mentioned at the top of each markdown file.
Try opening the markdown files on Github for better viewing. Alternatively you can right-click the markdown files and click
Open preview
to view them in your VS Codium/Code editor (then open a split window).
Note: be sure to stage, commit, and push the changes you make to your fork (using the
Source Control
tab in VS Codium/Code, or a source control method of your choice). If you are using Gitpod this is especially important, as any changes you make will be lost when you close your browser session unless they are pushed to your fork!
Haskell Dojo provides a special empty file called Sandbox.hs
in the src/
directory.
You can use this file as a scratchpad to:
- practice/experiment with writing arbitrary Haskell code
- test this practice code in GHCi
The provided sbox
script launches GHCi with the Sandbox
module open:
./sbox
You can use this GHCi session to experiment and test simple code directly in the interpreter, or run any code you've saved in src/Sandbox.hs
.
Use the :r
(:reload
) command in GHCi to reload the Sandbox
contents after making changes.
Note:
Sandbox.hs
is a module of our larger Cabal project, which means we can use it to test functions from libraries our project is using besides the Haskell standard library (base
), such asrandom
anddirectory
. This isn't possible in an ordinary GHCi session. However, this also meansSandbox.hs
must always compile with no errors before we can run any other code inside the project. Correct or comment out any erroneous code in this file as needed to ensure successful compilation.