Giter Club home page Giter Club logo

uom-plugin's Introduction

Units of measure as a GHC typechecker plugin

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.

Installation

Grab the source.

> git clone https://github.com/adamgundry/uom-plugin.git
> cd uom-plugin

Then build and run with any of these methods:

  • With Cabal new-build

> cabal new-build all
> cabal new-exec Examples
  • With Nix and Cabal

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
...
  • Within a Cabal Sandbox

> 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
  • With Stack

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

Continuous Integration

Build Status

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

uom-plugin's People

Contributors

adamgundry avatar philderbeast avatar erikd avatar expipiplus1 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.