Skip to content

cabal v2-run File.hs should use runghc #6647

Open

Description

@phadej

... and have some flag to force compilation, if that's really needed.

For non-GHC compilers, the compilation code paths is then the only option.

This is one step to make cabal v2-run File.hs more responsive.

Activity

  1. phadej commented on Apr 5, 2020

    @phadej
    CollaboratorAuthor

    On the other though, it might be confusing when cabal run exe-in-project is first compiled. Maybe the default between compilation and interpretation should be consistent. Yet, adding runghc support is a good start.

  2. hvr commented on Apr 5, 2020

    @hvr
    Member

    This would be more a lot more convenient to do if we had ghc --run support (see https://gitlab.haskell.org/ghc/ghc/issues/18011) just like we don't invoke the repl via ghci but rather directly via ghc --interactive. Passing GHC arguments to runghc is a bit awkward and I'm not sure if runghc has any support for "response files".

  3. h6agpt5 commented on Nov 15, 2026

    @h6agpt5

    Now that GHC supports ghc --run, would it be worth revisiting this proposal?

  4. zlonast commented on Nov 15, 2026

    @zlonast
    Collaborator

    @h6agpt5 Hi, we’d be happy for you to give this a try, feel free to open a pull request.

  5. ulysses4ever commented on Nov 16, 2026

    @ulysses4ever
    Collaborator

    Interpreter (as in ghc --run) brings speedups when the script keeps changing. But if I want to re-run the same thing multiple times, the compiled version will be faster in general. So, there's a tradeoff, and the choice should probably be left to user by providing the corresponding flag, e.g. cabal run --interpret if the default is compiling. Here are timings for a simple script depending on several packages (async, containers, optparse-applicative):

    unchanged script after an edit
    cabal run today (compiled) 0.11 s 1.45–1.50 s
    cabal run --interpret, with a quick prototype 0.78 s 0.78 s
    bare ghc --run, same packages 0.23–0.34 s 0.23–0.24 s

    A tip from LLM: the multi-repl code path in CmdRepl.hs is already doing something very close (collects flags during the build phase and start GHCi afterwards) around lines 516--588. A good implementation would start from a refactor...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions