Reputation: 7162
I can build and run a simple Haskell
program with cabal
module Main where
import System.Environment ( getArgs )
main :: IO ()
main = do
-- (input:_:_) <- getArgs
print "Hello Oren"
When no arguments are expected, everything goes fine:
$ cabal build 1>/dev/null 2>/dev/null
$ cabal run
Up to date
"Hello Oren"
It seems possible to pass arguments to the program:
$ cabal run --help | sed -n '13,16p'
Extra arguments can be passed to the program, but use '--' to separate
arguments for the program from arguments for cabal. The executable is run in
an environment where it can find its data files inplace in the build tree.
However, I can't seem to make it work:
$ cabal run -- Oren 13 10
cabal: Cannot run the package Oren, it is not in this project (either directly
or indirectly). If you want to add it to the project then edit the
cabal.project file.
Upvotes: 5
Views: 1126
Reputation: 10685
You'll need to explicitly call your target that you want to run. For example you can use exes
as a shorthand if you only have one executable:
$ cabal run exes -- Oren 13 10
The cabal documentation section on Target Forms lists all possible ways to write the target.
Upvotes: 5