I want to execute a binary file, which was compiled by the GHC Haskell compiler.
If I execute ./main.hi I get:
bash: ./main.hi: cannot execute binary file: Exec format error
and if I write ./main I get
bash: ./main: No such file or directory but file exists.
Result of the ls command:
log.txt main.hi main.hs main.o
chmod didn't help to fix the problem. My Haskell code:
module HelloWorld where
main :: IO ()
main = putStrLn "Hello, World!"
mainmust appear in a module namedMain-- or, with GHC, you may (must) inform it of your alternative main module's name. So, you can either change your file toor change your compilation line to include the
-main-isargument; for example:After making either of these changes, you should see an additional file in the list:
This new file is the executable, and it can be run with
./main.