Cabal run command

The cabal run . command works if there’s no command line arguments. However, If the haskell program takes them, the running cabal command cabal run . does not work. So, I should go to the binary directory and run then the binary directly. Is there any shortcut to run with cabal command without going to the build directory to run it?

Thank you

2 Likes

You can separate cabal arguments from the program arguments with --. For example try: cabal run exe:the-executable-name -- --help

6 Likes

It works. Thanks! (A button that marks as an answer seems not visible in my view…)

3 Likes

You are welcome!

It seems like we are missing the discourse-solved plugin to enable accepting an answer.

A helpful abbreviation, if you know you have only one executable in your project, you can also use cabal run exes -- <prog-args>.
The meta-target exes resolves to one executable in this case and runs it.

NB: these meta-targets exist for all kinds of components, e.g. tests, benchmarks, libs, all (for everything), etc…

4 Likes