Skip to content

cabal repl load single module #2592

Open

Description

@joeyh

I have a large project with a lot of modules that form an Executable. I'd like to use cabal repl to load up a single source file, reusing the objects that cabal build has already build
as needed for its dependencies.

If I just run "cabal repl", it loads every module in my project. This takes rather a long time. Even :r in the resulting repl takes a noticiable number of seconds. Long enough that my mind wanders. (Also, ghci's " Ok, modules loaded: " line is so long that any compilation error messages are pushed way off the top of the screen.)

Instead, I'd like to be able to run "cabal repl My.Module", and have it load only that module and its dependencies. This would let it load much faster.

Before cabal repl, I had a hack that used basically the same approach; running cabal build, grepping out the ghc --make, and reusing the same set of options (with some ugly tweaks to make it work) when starting ghci. With my hack, I am able to start ghci on a specified souce file, loading only that file (and its dependencies), reusing the cabal build objects. So, I know this can be done.

btw, dcoutts tells me there is some code in cabal that anticipates using cabal repl this way.

Activity

  1. codygman commented on May 25, 2015

    @codygman

    Just wanted to say this sounds like a good enhancement.

  2. osa1 commented on May 30, 2015

    @osa1
  3. erikd commented on Jul 12, 2016

    @erikd
    Member

    I wonder if the current behavior of cabal repl is actually what is most useful for most people.

    There are a number of differences in the behavior of cabal repl that are different from cabal repl -- ghci ... that I find suprising and unhelpful.

  4. ezyang commented on Jul 12, 2016

    @ezyang
    Contributor

    For what it's worth, I've never used cabal repl, and so I'll support UI changes by those of you who do use it. (For me, most of the time I just want to get the GHC command line args out of Cabal so I can run them myself.)

  5. erikd commented on Jul 12, 2016

    @erikd
    Member

    Ok, I'll set up a bunch of little demo projects that demonstrate what I think are problems with cabal repl and see what can and should be fixed.

  6. elliottt commented on Sep 10, 2016

    @elliottt

    I usually use cabal exec ghci instead of cabal repl for exactly the reasons listed above. Recently, I've been using cabal new-repl to take advantage of the new-build functionality, and was thinking that an option to not load any modules would fix my original gripes with cabal repl. This seems simpler to me, though I do see the advantage of being able to specify a list of modules to load (when working on a parser, for example).

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