[GHC] #11647: GHCi does not honour implicit `module Main (main) where` for re-exported `main`s

GHC ghc-devs at haskell.org
Fri Feb 26 08:21:27 UTC 2016


#11647: GHCi does not honour implicit `module Main (main) where` for re-exported
`main`s
-------------------------------------+-------------------------------------
           Reporter:  hvr            |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  GHCi           |           Version:  7.10.3
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Haskell2010 states:

 > An abbreviated form of module, consisting only of the module body, is
 permitted. If this is used, the header is assumed to be `module Main(main)
 where`.


 Consider the following two modules:

 {{{#!hs
 -- module Main (main) where
 import Main2 (main)
 }}}

 {{{#!hs
 module Main2 (main) where
 main :: IO ()
 main = return ()
 }}}

 A non-interactive GHC happily compiles `ghc --make Main`, however, GHCi
 fails with

 {{{
 $ ghci Main.hs
 GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
 unknown option: 'c'
 [1 of 2] Compiling Main2            ( Main2.hs, interpreted )
 [2 of 2] Compiling Main             ( Main.hs, interpreted )

 Main.hs:1:1: The IO action ‘main’ is not exported by module ‘Main’
 Failed, modules loaded: Main2.
 }}}

 For GHCi we need to uncomment the explicit `module Main (main) where` line
 to make it work.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11647>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list