Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a "haskell_repl" executable #220

Closed
judah opened this issue Apr 26, 2018 · 3 comments
Closed

Add a "haskell_repl" executable #220

judah opened this issue Apr 26, 2018 · 3 comments

Comments

@judah
Copy link
Collaborator

judah commented Apr 26, 2018

Currently, in order to use a REPL, we need to write explicit haskell_repl rules. Compare that to the UX of stack or cabal, where you can write stack repl some-package, stack repl some-package:exe:some-binary, etc., and automatically load a session with all the source files and dependencies for a particular target.

An alternate approach would be for rules_haskell to provide a single, generic script that takes a Bazel target (or targets) as a command-line argument, for example:

bazel build @io_tweag_rules_haskell//haskell_repl
bazel-bin/external/io_tweag_rules_haskell/haskell_repl/haskell_repl //some/haskell:target

One approach would be to write a version of haskell_repl which is an aspect, and then make the above script call bazel build //some/haskell:target --aspects ... to generate the script that the explicit rule produces today.

Another approach would be to use an OutputGroup for each haskell_library/haskell_binary, which contains source files and compilation info (similar to what we pass through the existing providers (HaskellBuildInfo, HaskellLibraryInfo).

@johnynek
Copy link

you could make a repl target an optional output of all rules.

e.g.

bazel run --direct_run //foo/bar/baz.repl

@mboes
Copy link
Member

mboes commented Apr 27, 2018

@johnynek's idea sounds very good to me. bazel run --direct_run is new in Bazel v0.12 released earlier this month. It opens new possibilities.

@mrkkrp
Copy link
Member

mrkkrp commented Apr 30, 2018

I worked on this today: https://github.com/tweag/rules_haskell/compare/auto-repl-per-target. @johnynek's idea worked quite well, we define optional repl output automatically for every binary and library target and so it's not built till explicitly requested.

Not opening PR yet because this needs:

  • a small cleanup
  • docs update
  • adding some options, such as something for setting additional GHCi flags, we provided this previously
  • a re-do of testing

I'll finish this up on Wednessday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants