Opened 2 years ago

Last modified 2 years ago

#11647 new bug

GHCi does not honour implicit `module Main (main) where` for re-exported `main`s

Reported by: hvr Owned by:
Priority: normal Milestone:
Component: GHCi Version: 7.10.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program 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:

-- module Main (main) where
import Main2 (main)
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:  :? 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.

Change History (1)

comment:1 Changed 2 years ago by hvr

Type of failure: None/UnknownGHC rejects valid program
Note: See TracTickets for help on using tickets.