ats-pkg: A build tool for ATS

[ ats, bsd3, development, library, program ] [ Propose Tags ]

A collection of scripts to simplify building ATS projects.

[Skip to Readme]


Manual Flags


Enable `-Werror`


Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS],,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, (info)
Dependencies ansi-wl-pprint, ats-pkg, ats-setup, base (<0), binary, bytestring, composition-prelude (>=, dependency, dhall, directory, http-client, http-client-tls, lens, optparse-applicative, parallel-io, process, shake (<0.18.4), shake-ats (>=, shake-ext (>=, tar, temporary, text, unix, zip-archive, zlib [details]
License BSD-3-Clause
Copyright Copyright: (c) 2018 Vanessa McHale
Author Vanessa McHale
Revised Revision 2 made by vmchale at 2019-12-15T21:46:44Z
Category Development, ATS
Home page
Source repo head: git clone
Uploaded by vmchale at 2018-02-09T03:18:23Z
Executables atspkg
Downloads 94464 total (332 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-02-09 [all 1 reports]

Readme for ats-pkg-

[back to package description]


Build Status

This is a build system for ATS written in Haskell and configured with Dhall. It is not yet stable.


The easiest way to install is via a script, viz.

curl -sSl | bash -s

Alternately, you can download Cabal and GHC and install with

cabal new-install ats-pkg --symlink-bindir ~/.local/bin --happy-options='-gcsa' --alex-options='-g'

Note that $HOME/.local/bin will need to be on your PATH.


atspkg is configured with Dhall. You may wish to read the Dhall tutorial first, but you do not need to fully understand everything to get started.

Project Templates

You can use pi with the builtin ats template as follows:

pi new ats cool-project

You can then build with atspkg build or install with atspkg install.

Alternately, you can start with a templated Haskell library calling ATS code:

pi git vmchale/haskell-ats ambitious-project

which can be built with atspkg build followed by cabal new-build.

Building a Binary Package

The minimal configuration for a package with a binary target is as follows:

let pkg =
let dbin =

in pkg //
  { bin =
    [ dbin //
      { src = "src/program.dats"
      , target = "target/program"

You need only specify the source file and the target; atspkg will parse your ATS source files and track them (it will not track included C).

Building a Haskell Library

You can see an example here. You can configure the ATS side of things as follows:

let pkg =

in pkg //
  { atsSource = [ "ats-src/ambitious-project.dats" ] }

This just tells atspkg to look for a source file called ats-src/ambitious-project.dats, which will be compiled to ambitious-project.c in the default directory (i.e. cbits). You can then call the generated code just as you would call C.

You may want to consider ats-setup as well if you are packaging the Haskell for distribution.

Calling Haskell from ATS

You can see a demo here. Currently, there is not generic Storable instance that works with ATS, so the process is a bit more involved than is ideal. atspkg has abilities similar to hs2ats, which means that you can usually generate ATS types based on the Haskell types.

The following is a minimal example of a configuration file:

let pkg =
let dbin =

in pkg //
  { bin =
      dbin //
      { src = "src/project.dats"
      , target = "target/project"
      , hsDeps = [ { cabalFile = "hs/foreign.cabal", objectFile = "hs/Foreign.o" } ]
      , hs2ats = [ { hs = "hs/Foreign.hs", ats = ".atspkg/hs2ats/gen.sats" } ]
    , ccompiler = "ghc-8.2.2"
    , cflags = ["-package-db", "hs/dist-newstyle/packagedb/ghc-8.2.2/", "-optc-O2", "-optc-flto", "-optc-mtune=native", "hs/Foreign"]