Core Haskell rules
Bazel

Core Haskell rules


haskell_binary

haskell_binary(**kwargs)

Build an executable from Haskell source.

haskell_binary(
name = "hello",
srcs = ["Main.hs", "Other.hs"],
deps = ["//lib:some_lib"]
)

Every haskell_binary target also defines an optional REPL target that is not built by default, but can be built on request. The name of the REPL target is the same as the name of binary with "@repl" added at the end. For example, the target above also defines main@repl.

You can call the REPL like this (requires Bazel 0.15 or later):

$ bazel run //:hello@repl

Attributes

**kwargs

Unknown; Optional


haskell_test

haskell_test(**kwargs)

Build a test suite.

Additionally, it accepts all common bazel test rule fields. This allows you to influence things like timeout and resource allocation for the test.

Attributes

**kwargs

Unknown; Optional


haskell_library

haskell_library(**kwargs)

Build a library from Haskell source.

haskell_library(
name = "hello-lib",
srcs = glob(["src/**/*.hs"]),
src_strip_prefix = "src",
deps = [
"//hello-sublib:lib",
],
reexported_modules = {
"//hello-sublib:lib": "Lib1 as HelloLib1, Lib2",
},
)

Every haskell_library target also defines an optional REPL target that is not built by default, but can be built on request. It works the same way as for haskell_binary.

Attributes

**kwargs

Unknown; Optional


haskell_import

haskell_import(name, deps, hdrs, haddock_html, haddock_interfaces, id, includes, linkopts, shared_libraries, static_libraries, static_profiling_libraries, version)

Attributes

name

Name; Required

A unique name for this rule.

deps

List of labels; Optional; Default is []

hdrs

List of labels; Optional; Default is []

haddock_html

Label; Optional

haddock_interfaces

List of labels; Optional; Default is []

id

String; Optional; Default is ''

includes

List of strings; Optional; Default is []

linkopts

List of strings; Optional; Default is []

shared_libraries

List of labels; Optional; Default is []

static_libraries

List of labels; Optional; Default is []

static_profiling_libraries

List of labels; Optional; Default is []

version

String; Optional; Default is ''


haskell_toolchain_library

haskell_toolchain_library(name, package)

Import packages that are prebuilt outside of Bazel.

Use this rule to make dependencies that are prebuilt (supplied as part of the compiler toolchain) available as targets.

Attributes

name

Name; Required

A unique name for this rule.

package

String; Optional; Default is ''

The name of a GHC package not built by Bazel. Defaults to the name of the rule.

Examples

haskell_toolchain_library(
    name = "base_pkg",
    package = "base",
)

haskell_library(
    name = "hello-lib",
    srcs = ["Lib.hs"],
    deps = [
        ":base_pkg",
        "//hello-sublib:lib",
    ],
)