Coder Social home page Coder Social logo

Comments (4)

ndmitchell avatar ndmitchell commented on August 24, 2024

The problem with cabal exec is that it's slow, and in older versions, buggy (if there is any compile error it bails out rather than opening ghci with a compile error). What is the difference between cabal exec and cabal repl? Having arguments be :loaded seems like a reasonable idea, and might have been enough in conjunction with cabal repl to make your third command work.

from ghcid.

istathar avatar istathar commented on August 24, 2024

The problem with cabal exec is that it's slow

Well, that's mitigated by the fact that the whole point of ghcid would seem to be running the child GHCi process only once, so wrapping it in cabal exec isn't going to hurt. [Day to day I am running the above command via a shell script:

$ cat ~/.local/bin/build 
exec ghcid --command="cabal exec ghci $*"
$

thence build tests/ThoughtExperiment.hs, (because I keep trying to do cabal exec ghcid, which is wrong but seems reasonable)].

What is the difference between cabal exec and cabal repl?

As far as I can tell, cabal repl will only load a named section from the .cabal file (executable, test suite, or benchmark) and not just an arbitrary file — which does work with the pattern above

Having arguments be :loaded seems like a reasonable idea, and might have been enough in conjunction with cabal repl to make your third command work.

Quite possibly, but type checking ad-hoc scripts is where this is really shining for me for the moment, and lord knows having to enumerate each and every junk test program in your .cabal file just to repl it is tedious at best.

AfC

from ghcid.

ndmitchell avatar ndmitchell commented on August 24, 2024

One of the reasons I regularly stop/start my ghcid is to save my laptop battery, which I guess #26 is the real fix for. So I guess what we need is an algorithm to go from a directory with files in it, and optionally a list of files, to a command line and list of commands. Currently that algorithm is https://github.com/ndmitchell/ghcid/blob/master/src/Ghcid.hs#L51 and has no support for free command line arguments. It seems what you are suggesting is roughly:

  • If you have a .cabal file in the directory, and no arguments, do cabal repl.
  • If you have a .cabal file in the directory, and some arguments, do cabal exec ghci <arguments>.
  • Otherwise, do ghci <arguments>

Does that seem about right?

One thing that seems not to work with that is that if I import Paths_shake into a module then cabal exec doesn't work, but cabal repl does. Any thoughts on how to avoid that?

from ghcid.

ndmitchell avatar ndmitchell commented on August 24, 2024

I've rewritten it, so now ghcid tests/Experiment.hs works, which will do a cabal exec ghci tests/Experiment.hs for you under the covers. Please let me know if there are still undesirable cases.

from ghcid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.