Run a script (not a module) with ghc

心已入冬 提交于 2019-12-12 04:23:40

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!