So I cannot :l mySmallExample.hs as easily
/cc @typedrat
just for the record, inside a project, cabal new-repl typically will chdir into the folder of the respective package whose component was requested for the repl session
For a project-less new-repl invocation I too would expect ghci to be invoked with the original CWD you invoked cabal with
This is somewhat tricky to handle, because there are a lot of layers of stuff between where we know if we are using new-repl at all and if we are in a project or outside of one and the place where we decide what the CWD should be.
This is indeed an issue. But I have to wonder: if you're firing up cabal new-repl with the immediate intention of just :loading a single file, perhaps we should allow new-repl to support this use case directly? For example, you might have a cabal script like this:
{- cabal:
build-depends: base >= 4.9
, QuickCheck >= 2.12
, sop-core >= 0.4
-}
module Main where
...
Currently, you can cabal new-run Main.hs and it'll take care of the rest, but sadly, there does not appear to be a counterpart for new-repl. AFAICT, you have to perform all of the following steps:
cabal new-repl -b QuickCheck -b sop-core. (Yes, you have to specify all of the dependencies as flags, despite the fact that they're already stated in the file itself. Urk.):cd ... to get back to the directory you were in (due to this bug described in this issue).:load Main.hs.new-repl in step 1. If you accidentally forgot one, prepare to Ctrl+D and start all over again from step 1.This feels excessively complicated. Why can't we just say cabal new-repl Main.hs? (Or perhaps --file Main.hs, if folks feel that this behavior should be behind a flag.)
Most helpful comment
This is indeed an issue. But I have to wonder: if you're firing up
cabal new-replwith the immediate intention of just:loading a single file, perhaps we should allownew-replto support this use case directly? For example, you might have acabalscript like this:Currently, you can
cabal new-run Main.hsand it'll take care of the rest, but sadly, there does not appear to be a counterpart fornew-repl. AFAICT, you have to perform all of the following steps:cabal new-repl -b QuickCheck -b sop-core. (Yes, you have to specify all of the dependencies as flags, despite the fact that they're already stated in the file itself. Urk.):cd ...to get back to the directory you were in (due to this bug described in this issue).:load Main.hs.new-replin step 1. If you accidentally forgot one, prepare to Ctrl+D and start all over again from step 1.This feels excessively complicated. Why can't we just say
cabal new-repl Main.hs? (Or perhaps--file Main.hs, if folks feel that this behavior should be behind a flag.)