I often have situations where I leave main :: IO ()
functions in tests. I can run these fine with runghc
, but sometimes I want to compile them (e.g. for running on another platform). Is there a way to do this? If I run, for example,
ghc --make Test.Haar
where Test/Haar.hs
has a main
method, then nothing happens, it just creates the .o
file.
ghc --make -main-is Test.Haar Test.Haar
Note, however, that after using -main-is Test.Haar
, if you want to use the module as part of another programme, you have to recompile it without the -main-is
, otherwise the linker will find two entry-points and throw an error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With