At yesterday’s meeting of the Seattle Area Haskell Users’ Group, I talked briefly about my very recent experimentation with Haskell’s new module system, namely Backpack. I’ll briefly discuss what I’ve done so far right here.

The main thrust of my experimentation was to work through Edward Yang’s “Try Backpack” tutorial. For reasons that I gave up trying to figure out, I could not compile Edward’s examples, so I wrote my own from scratch. Here are the contents of the project and a brief description of each file:

foo.bkp : the Backpack file itself

This describes four units:

foo-indef : defines the signature Str and a module Foo that implements a function theLength in terms of Str

: defines the signature and a module that implements a function in terms of foo-int : defines a concrete implementation of the Str signature in terms of Int

: defines a concrete implementation of the signature in terms of foo-string : defines a concrete implementation of the Str signature in terms of String

: defines a concrete implementation of the signature in terms of main : defines the Main module that consumes theLength using both foo-int and foo-string

Makefile : the build definition

Since Stack does not yet support Backpack, I opted to use Stack just to manage the GHC compiler installation, and to describe the build of the project using a good old-fashioned Makefile.

To build the project:

make

stack.yaml : the Stack configuration file

This specifies which resolver and compiler version to use.

To install the correct version of GHC:

stack setup

The project also contains basic documentation about how to build on Windows, Linux and macOS.

I have a few questions about Backpack which I’ve not found any answers to yet:

How do I move my Haskell code out of the .bkp file and into separate .hs files?

file and into separate files? How am I really supposed to build this kind of project?

Happy Backpacking!