hpack: An alternative format for Haskell packages

[ development, library, mit, program ] [ Propose Tags ]

Downloads

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

Candidates

  • No Candidates
Versions [RSS] 0.1.0, 0.1.1, 0.1.2, 0.2.0, 0.3.0, 0.3.1, 0.3.2, 0.4.0, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.6.0, 0.7.0, 0.7.1, 0.8.0, 0.9.0, 0.9.1, 0.10.0, 0.11.0, 0.11.1, 0.11.2, 0.12.0, 0.13.0, 0.14.0, 0.14.1, 0.15.0, 0.16.0, 0.17.0, 0.17.1, 0.18.0, 0.18.1, 0.19.0, 0.19.1, 0.19.2, 0.19.3, 0.20.0, 0.21.0, 0.21.1, 0.21.2, 0.22.0, 0.23.0, 0.24.0, 0.25.0, 0.26.0, 0.27.0, 0.28.0, 0.28.1, 0.28.2, 0.29.0, 0.29.1, 0.29.2, 0.29.3, 0.29.4, 0.29.5, 0.29.6, 0.29.7, 0.30.0, 0.31.0, 0.31.1, 0.31.2, 0.32.0, 0.33.0, 0.33.0.1, 0.33.1, 0.34.0, 0.34.1, 0.34.2, 0.34.3, 0.34.4, 0.34.5, 0.34.6, 0.34.7, 0.35.0, 0.35.1, 0.35.2, 0.35.3, 0.35.4, 0.35.5, 0.36.0 (info)
Dependencies aeson (>=0.11 && <1.6), base (>=4.7 && <4.20), base-compat (>=0.8), bytestring, containers, deepseq, directory, filepath, Glob (<0.9), hpack, text, unordered-containers, yaml [details]
License MIT
Author
Maintainer Simon Hengel <sol@typeful.net>
Revised Revision 3 made by SimonHengel at 2023-11-24T17:14:09Z
Category Development
Home page https://github.com/sol/hpack#readme
Bug tracker https://github.com/sol/hpack/issues
Source repo head: git clone https://github.com/sol/hpack
Uploaded by SimonHengel at 2017-01-11T01:41:09Z
Distributions Arch:0.35.2, Debian:0.34.2, Fedora:0.35.2, LTSHaskell:0.36.0, NixOS:0.36.0, Stackage:0.36.0
Reverse Dependencies 10 direct, 5 indirect [details]
Executables hpack
Downloads 73571 total (340 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-01-11 [all 1 reports]

Readme for hpack-0.16.0

[back to package description]

hpack: An alternative format for Haskell packages

Examples

Documentation

Getting started

One easy way of getting started is to use hpack-convert to convert an existing cabal file into a package.yaml.

Quick-reference

Top-level fields

Hpack Cabal Default Notes Example
name name
version version 0.0.0
synopsis synopsis
description description
category category
stability stability
homepage homepage If github given, <repo>#readme
bug-reports bug-reports If github given, <repo>/issues
author author May be a list
maintainer maintainer May be a list
copyright copyright May be a list
license license
license-file license-file LICENSE if file exists
tested-with tested-with
build-type build-type Simple Must be Simple, Configure, Make, or Custom
cabal-version >= 1.10 or >= 1.21 >= 1.21 if library component has reexported-modules field
extra-source-files extra-source-files Accepts glob patterns
data-files data-files Accepts glob patterns
github source-repository head Accepts user/repo or user/repo/subdir github: foo/bar
git source-repository head No effect if github given git: https://my.repo.com/foo
flags flag <name> Map from flag name to flag (see Flags)
library library See Library fields
executables executable <name> Map from executable name to executable (see Executable fields)
tests test-suite <name> Map from test name to test (see Test fields)
benchmarks benchmark <name> Map from benchmark name to benchmark (see Benchmark fields)

Global top-level fields

These fields are merged with all library, executable, test, and benchmark components.

Hpack Cabal Default Notes
source-dirs hs-source-dirs
default-extensions default-extensions
other-extension other-extensions
ghc-options ghc-options
ghc-prof-options ghc-prof-options
cpp-options cpp-options
cc-options cc-options
c-sources c-sources
extra-lib-dirs extra-lib-dirs
extra-libraries extra-libraries
include-dirs include-dirs
install-includes install-includes
ld-options ld-options
buildable buildable May be overridden by later stanza
dependencies build-depends
build-tools build-tools
when Accepts a list of conditionals (see Conditionals)

Library fields

Hpack Cabal Default Notes
exposed exposed
exposed-modules exposed-modules All modules in source-dirs less other-modules
other-modules other-modules All modules in source-dirs less exposed-modules
reexported-modules reexported-modules
default-language Haskell2010

Executable fields

Hpack Cabal Default Notes
main main-is
other-modules other-modules
default-language Haskell2010

Test fields

Hpack Cabal Default Notes
type exitcode-stdio-1.0
main main-is
other-modules other-modules
default-language Haskell2010

Benchmark fields

Hpack Cabal Default Notes
type exitcode-stdio-1.0
main main-is
other-modules other-modules
default-language Haskell2010

Flags

Hpack Cabal Default Notes
description description Optional
manual manual Required (unlike Cabal)
default default Required (unlike Cabal)

Conditionals

Conditionals with no else branch:

  • Must have a condition field
  • May have any number of other fields

For example,

when:
  - condition: os(darwin)
    extra-lib-dirs: lib/darwin

becomes

if os(darwin)
  extra-lib-dirs:
    lib/darwin

Conditionals with an else branch:

  • Must have a condition field
  • Must have a then field, itself an object containing any number of other fields
  • Must have a else field, itself an object containing any number of other fields
  • All other top-level fields are ignored

For example,

when:
  - condition: flag(fast)
    then:
      ghc-options: -O2
    else:
      ghc-options: -O0

becomes

if flag(fast)
  ghc-options: -O2
else
  ghc-options: -O0

File globbing

At place where you can specify a list of files you can also use glob patterns. Glob patters and ordinary file names can be freely mixed, e.g.:

extra-source-files:
  - static/*.js
  - static/site.css

Glob patterns are expanded according to the following rules:

  • ? and * are expanded according to POSIX (they match arbitrary characters, except for directory separators)
  • ** is expanded in a zsh-like fashion (matching across directory separators)
  • ?, * and ** do not match a . at the beginning of a file/directory

Slides

Vim integration

To run hpack automatically on modifications to package.yaml add the following to your ~/.vimrc:

autocmd BufWritePost package.yaml silent !hpack --silent