The uom-plugin
library adds support for units of measure to GHC using the new experimental facility for typechecker plugins, which is available in GHC 7.10
and later. See Data.UnitsOfMeasure.Tutorial for an introduction to the library, and the accompanying paper for more background. An example of a package that uses the library is given in uom-plugin-examples.
The library has been tested with GHC 7.10.3
, 8.0.2
& 8.2.2
.
Grab the source.
> git clone https://github.com/adamgundry/uom-plugin.git
> cd uom-plugin
Then build and run with any of these methods:
> cabal new-build all
> cabal new-exec Examples
The default compiler is set in ./nix/config.nix
as compiler ? "ghc822"
;
> nix-shell
[nix-shell:]$ cabal new-build all
Resolving dependencies...
Up to date
With GHC > 8.2.2
only the plugin itself builds, not its tests or the
examples. There are conditionals for this in the package.yaml
files;
# package.yaml
when:
- condition: impl(ghc > 8.2.2)
buildable: false
# .cabal
if impl(ghc > 8.2.2)
buildable: False
If the conditions were not in place then what they do is equivalent to;
> nix-shell -p haskell.compiler.ghc843 -p haskell.packages.ghc843.cabal-install
[nix-shell:]$ cabal new-build uom-plugin --disable-tests
Resolving dependencies...
Build profile: -w ghc-8.4.3 -O1
...
> cabal sandbox init
(cd uom-plugin && cabal sandbox init --sandbox=../.cabal-sandbox && cabal install)
> cd uom-plugin-examples/
uom-plugin-examples> cabal sandbox init --sandbox=../.cabal-sandbox
uom-plugin-examples> cabal build
uom-plugin-examples> dist/build/Examples/Examples
From the set of stack-<ghc-version>.yaml
provided files, picking the one that
corresponds to ghc-8.2.2;
> stack build --stack-yaml=stack-8.2.2.yaml
> stack exec Examples --stack-yaml=stack-8.2.2.yaml
If installing tooling from the master branch of haskell-ci then generate the
.travis.yml
setup with;
> make-travis-yml --output=.travis.yml --config=cabal.haskell-ci cabal.project
If installing tooling from the package branch of haskell-ci then generate the
.travis.yml
setup with;
> haskell-ci --output=.travis.yml --config=cabal.haskell-ci cabal.project