MercuryTechnologies / ghciwatch

Load a GHCi session for a Haskell project and reload it when source files change
https://mercurytechnologies.github.io/ghciwatch/
MIT License
104 stars 9 forks source link

Document the default behavior when --watch flag is not present #307

Open jhrcek opened 1 month ago

jhrcek commented 1 month ago

Describe the feature you’d like to be implemented

It would be nice to mention (maybe in --help, but definitely in docs) what exactly is being watched when --watch flag is not specified.

Is cabal file included in the watching by default? It seems to me that there are no reloads on cabal file changes (in which case this is a bug report). Is it all .hs files found in current directory?

List alternatives to the feature and their pros and cons

No response

Additional context

Thank you for opensourcing this great tool, I switched my project to it from ghcid and I'm excited it fixes many issues that I had with ghcid

9999years commented 1 month ago

Thanks for the ticket!

The short answer is that the default value is src. It's pretty unsophisticated. I thought I had a note explaining this somewhere but apparently I do not. Do you have somewhere you think this information should live? (Where did you look for it before you realized it wasn't listed?) I might create a new section in the user manual for it.

If a file argument is given (ghciwatch Foo.hs), the command executed is ghci Foo.hs. If neither a file argument nor --command are given, the command is cabal repl.

https://github.com/MercuryTechnologies/ghciwatch/blob/56db4fba3c8258bfac496b7885d3ab203d8f6f44/src/ghci/mod.rs#L132-L139

I also have a long-standing TODO to copy some of ghcid's logic for constructing a default command, which is listed here:

https://github.com/ndmitchell/ghcid/blob/e2852979aa644c8fed92d46ab529d2c6c1c62b59/src/Ghcid.hs#L142-L171

jhrcek commented 1 month ago

Do you have somewhere you think this information should live?

Good question. Skimming the docs again I see it's actually mentioned in passing in the first example: https://mercurytechnologies.github.io/ghciwatch/cli.html#examples "Load cabal v2-repl and watch for changes in src:"

I would expand that to "watch for changes to *.hs files in src directory or any of its subdirectories (recursively)" (or whatever is actually true)

Originally I was looking for it under --watch flag's documentation https://mercurytechnologies.github.io/ghciwatch/cli.html#--watch maybe because I'm used to optparse-applicative showing the defaults as part of the help message for each flag, e.g. it could be added as last sentence there..

--watch <PATH>
    A path to watch for changes.

    Directories are watched recursively. Can be given multiple times.

    **If not provided, the default behavior is as if `--watch src` was provided.**