Accept the GHC to accept the core module with a core function that is not IO ()

Is there any way (flag or hack) to force the GHC to accept the main module, where the main signature of the function is not IO () ? For Fay, the main functions are of type Fay () , but the GHC does not accept this if the module is Main (or the name of the module).

+4
source share
1 answer

The entry point to the program must be of type IO a for some a , and as far as I know, there is no way to force the GHC to accept other types (without changing its source code).

The default entry point is Main.main , but you can specify various actions as entry points using the -main-is flag with GHC. General form

 ghc -main-is Module.action ModuleThatImportsEverything.hs -o programme 

You can omit the Module part if the Main module,

 ghc -main-is action ModuleThatImportsEverything.hs -o programme 

or action if its name is Main ,

 ghc -main-is Module ModuleThatImportsEverything.hs -o programme 

equivalent to -main-is Module.main .

In your case, you can add a dummy action to the Main module or a dummy module, which, of course, needs to be imported (directly or indirectly) from the Main module - into the program in order to become an entry point with respect to the GHC.

+9
source

Source: https://habr.com/ru/post/1437518/


All Articles