How to run a Haskell file in interpreted mode

前端 未结 4 1504
隐瞒了意图╮
隐瞒了意图╮ 2020-12-04 14:23

I\'ve been told you can interpret Haskell files (which I assume means they will work like Ruby/Python/Perl). I can\'t find the command line option on GHC to do this, though.

4条回答
  •  臣服心动
    2020-12-04 14:41

    $ runhaskell MyFile.hs
    

    Alternatively, runghc (they're the same thing). ghci MyFile.hs will also start an interactive REPL session with MyFile.hs loaded, but if you want to run a main program then runhaskell is the way to go.

    It's probably a good idea to get into the habit of testing parts of your program as isolated units in GHCi rather than running the whole thing each time, but obviously for shorter scripts it's simplest and easiest just to run the entire thing.

提交回复
热议问题