Running

Now we will use our toolchain on a sample project.

1 Download sample project

Download or clone this GitHub repository. It contains a bare-bones project, configured for our toolchain.

git clone https://github.com/hmc-cs132/try-haskell

Cloning into ‘try-haskell’…
remote: Enumerating objects: 22, done.
remote: Counting objects: 100% (22/22), done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 22 (delta 1), reused 22 (delta 1), pack-reused 0 (from 0)
Receiving objects: 100% (22/22), 4.91 KiB | 4.91 MiB/s, done.
Resolving deltas: 100% (1/1), done.

2 Build the project

After you have downloaded the project, change to the directory that contains the project and use stack build to build the project.

cd try-haskell
stack build

try-haskell> configure (lib + exe)
Configuring try-haskell-0.0.0…
try-haskell> build (lib + exe) with ghc-9.6.7
Preprocessing library for try-haskell-0.0.0..
Building library for try-haskell-0.0.0..
[1 of 2] Compiling Lib
[2 of 2] Compiling Paths_try_haskell
Preprocessing executable ‘try-haskell-exe’ for try-haskell-0.0.0..
Building executable ‘try-haskell-exe’ for try-haskell-0.0.0..
[1 of 2] Compiling Main
[2 of 2] Compiling Paths_try_haskell
[3 of 3] Linking .stack-work/dist/x86_64-osx/ghc-9.6.7/build/try-haskell-exe/try-haskell-exe
try-haskell> copy/register
Installing library in /private/tmp/try-haskell/.stack-work/install/x86_64-osx/7023ad8f1b451b0bdec11ccfe3eb97b8bdcd0b9e81dcb4a54b3d2be771e02ae7/9.6.7/lib/x86_64-osx-ghc-9.6.7/try-haskell-0.0.0-8YMc50cPU6QJeahmRc5bxe
Installing executable try-haskell-exe in /private/tmp/try-haskell/.stack-work/install/x86_64-osx/7023ad8f1b451b0bdec11ccfe3eb97b8bdcd0b9e81dcb4a54b3d2be771e02ae7/9.6.7/bin
Registering library for try-haskell-0.0.0..

3 Run the project

Run the main program with stack run. You should see the output someFunc.

stack run

someFunc

4 Test the project

Run the (unimplemented) test suite with stack test.

The first time you run this command, stack will download and install libraries that are needed for testing.

stack test

…lots of output
try-haskell> test (suite: try-haskell-test)

Test suite not yet implemented



try-haskell> Test suite try-haskell-test passed
Completed 2 action(s).

Next, we will connect a text editor to our Haskell toolchain.