Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Haskell's ghci support running a script and then quit, like python or perl?

Python or Perl supports:

python xxx.py
perl xxx.pl
powershell xxx.ps1

Execute the script and quit with an exit code. When I tried GHCi (as ghci xxx.hs) it seems to load the xxx.hs file and enter interactive mode, without quiting.

  1. Does the GHC interpreter support such operations?
  2. Does this "interpreting" require to have a main function like the GHC compiler does?
like image 908
vik santata Avatar asked Feb 07 '23 14:02

vik santata


1 Answers

Use runghc to get the same behavior. You will indeed need a main :: IO () function still.

like image 183
sclv Avatar answered Mar 05 '23 18:03

sclv