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 itselfThis describes four units:
foo-indef
: defines the signature Str
and a module Foo
that implements a function theLength
in terms of Str
foo-int
: defines a concrete implementation of the Str
signature in terms of Int
foo-string
: defines a concrete implementation of the Str
signature in terms of String
main
: defines the Main
module that consumes theLength
using both foo-int
and foo-string
Makefile
: the build definitionSince 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 fileThis 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:
.bkp
file and into separate .hs
files?Happy Backpacking!
Content © 2024 Richard Cook. All rights reserved.