问题
Previously I used ghc
version < 8
on Linux and when I had a script in a file, say file.hs
, like
let x = "hello"
putStrLn x
double x=2*x
print $ double 2
double 3
then it was possible to run it and get the outputs in a terminal by doing
ghc -e ':script file.hs'
Now I'm using ghc 8.0.1
on Windows and this does not work anymore. Is there another way ?
I can get the outputs if I open GHCi
and type :script file.hs
. But I want these outputs in the terminal.
I don't know whether this is due to the upgrade of ghc
or to the OS.
回答1:
This works with double quotes:
ghc -e ":script file.hs"
来源:https://stackoverflow.com/questions/41313467/run-a-script-not-a-module-with-ghc