Multi target Haskell REPL.
Bazel

Multi target Haskell REPL.


haskell_repl

haskell_repl(name, deps, collect_data, experimental_from_binary, experimental_from_source, repl_ghci_args, repl_ghci_commands)

Build a REPL for multiple targets.

$ bazel run //:repl

Attributes

name

Name; Required

A unique name for this rule.

deps

List of labels; Optional; Default is []

List of Haskell targets to load into the REPL

collect_data

Boolean; Optional; Default is True

Whether to collect the data runfiles from the dependencies in srcs, data and deps attributes.

experimental_from_binary

List of strings; Optional; Default is []

Black-list of targets to not load by source but as packages.

        Wild-card targets such as //... or //:all are allowed.

        The black-list takes precedence over the white-list.

        Note, this attribute will change depending on the outcome of
        https://github.com/bazelbuild/bazel/issues/7763.
experimental_from_source

List of strings; Optional; Default is ['//...']

White-list of targets to load by source.

        Wild-card targets such as //... or //:all are allowed.

        The black-list takes precedence over the white-list.

        Note, this attribute will change depending on the outcome of
        https://github.com/bazelbuild/bazel/issues/7763.
repl_ghci_args

List of strings; Optional; Default is []

Arbitrary extra arguments to pass to GHCi. This extends compiler_flags and repl_ghci_args from the toolchain

repl_ghci_commands

List of strings; Optional; Default is []

Arbitrary extra commands to execute in GHCi.

Examples

haskell_repl(
    name = "repl",
    deps = [
        "//lib:some_lib",
        "//exe:some_exe",
    ],
    experimental_from_source = [
        "//lib/...",
        "//exe/...",
        "//common/...",
    ],
    experimental_from_binary = [
        "//lib/vendored/...",
    ],
)

Collects all transitive Haskell dependencies from deps. Those that match experimental_from_binary or are defined in an external workspace will be loaded as binary packages. Those that match experimental_from_source and are defined in the local workspace will be loaded by source.

You can call the REPL like this: