Try using ghci
instead:
# cat Query.hs
main = putStrLn "Can ghc automatically run the executable?"
# ghci -fobject-code -e "main" Query.hs
Can ghc automatically run the executable?
# ls Query.*
Query.hi Query.hs Query.o
#
If you don’t want those extra files, use runghc
:
# runghc --help
Usage: runghc [runghc flags] [GHC flags] module [program args]
The runghc flags are
-f /path/to/ghc Tell runghc where GHC is
--ghc-arg=... Pass an option or argument to GHC
--help Print this usage information
--version Print version number
#