Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling in GHC

I'm learning Haskell and a simple doubt struck me, what is the difference between these two commands to compile using GHC (fac is a program to calculate factorial) :

ghc -o fac fac.hs

and

ghc fac.hs

Now to run the program I just do fac.exe (I'm using Windows).

Given that both works which one is right? both? And which one is the most advisable to use?

like image 441
user1493813 Avatar asked Dec 14 '25 10:12

user1493813


1 Answers

Both are OK. The only thing the -o command does is determine the name of the executable file that is generated. As far as the Haskell goes it doesn't make any difference.

Personally, I like always using "-o" to make things explicit (since I like avoiding implicit defaults in general) and to make it look more similar to other compilers (for example, the gcc C compiler kind of forces you to use its "-o" option, since the default name it uses otherwise is very ugly)

like image 113
hugomg Avatar answered Dec 16 '25 06:12

hugomg