| 
1 | 1 | ---  | 
2 |  | -title: ‘main’ not defined  | 
 | 2 | +title: Missing main  | 
3 | 3 | summary: The IO action ‘main’ is not defined in module ‘Main’.  | 
4 | 4 | introduced: 9.8.1  | 
5 | 5 | severity: error  | 
6 | 6 | ---  | 
7 | 7 | 
 
  | 
8 |  | -GHC expects the `Main` module to define a function called `main` which it can use as the entry point of your program.  | 
 | 8 | +GHC expects the `Main` module to define a function called `main` which it can  | 
 | 9 | +use as the entry point of your program.  | 
9 | 10 | 
 
  | 
10 |  | -This error can also occur in unnamed modules, because GHC will default to the module name `Main` for such modules.  | 
 | 11 | +This error can also occur in unnamed modules, because GHC will default to the  | 
 | 12 | +module name `Main` for such modules.  | 
11 | 13 | 
 
  | 
12 |  | -If you just want GHC to produce an object file without an entry point, then you can give your module a name other than `Main` by putting a module header at the top of your file (below language pragmas and compiler options), for example as follows:  | 
 | 14 | +If you just want GHC to produce an object file without an entry point, then you  | 
 | 15 | +can give your module a name other than `Main` by putting a module header at the  | 
 | 16 | +top of your file (below language pragmas and compiler options), for example as  | 
 | 17 | +follows:  | 
13 | 18 | 
 
  | 
14 | 19 | ```  | 
15 | 20 | module Foo where  | 
16 | 21 | ```  | 
 | 22 | + | 
 | 23 | +The conventions around `main` are defined in the second paragraph of Chapter 5  | 
 | 24 | +of [The Haskell 2010 Report](https://www.haskell.org/onlinereport/haskell2010/haskellch5.html#x11-980005),  | 
 | 25 | + | 
 | 26 | +> A Haskell program is a collection of modules, one of which, by convention,  | 
 | 27 | +> must be called `Main` and must export the value `main`. The value of the  | 
 | 28 | +> program is the value of the identifier `main` in module `Main`, which must be  | 
 | 29 | +> a computation of type `IO t` for some type `t` (see Chapter 7). When the  | 
 | 30 | +> program is executed, the computation `main` is performed, and its result (of  | 
 | 31 | +> type `t`) is discarded.  | 
 | 32 | +
  | 
 | 33 | +## Example error text  | 
 | 34 | + | 
 | 35 | +```  | 
 | 36 | +example1/before/Lib.hs:1:1: error: [GHC-67120]  | 
 | 37 | +    The IO action ‘main’ is not defined in module ‘Main’  | 
 | 38 | +  |  | 
 | 39 | +1 | factorial :: Int -> Int  | 
 | 40 | +  | ^  | 
 | 41 | +```  | 
 | 42 | + | 
 | 43 | +```  | 
 | 44 | +example2/before/Main.hs:1:1: error: [GHC-67120]  | 
 | 45 | +    The IO action ‘main’ is not defined in module ‘Main’  | 
 | 46 | +  |  | 
 | 47 | +1 | notMain :: IO ()  | 
 | 48 | +  | ^  | 
 | 49 | +```  | 
0 commit comments