Skip to content

`runghc` accepts invalid main program (for GHC 8.8.1)

Consider the Main module

module Main () where main = putStrLn "The impossible happened"

which according to the Haskell Report does not constitute a valid Haskell Program (as it doesn't export the main entry point)

Compiling this with ghc --make will rightly reject it with

Main.hs:1:1: error:
    The IO action ‘main’ is not exported by module ‘Main’
  |
1 | module Main () where main = putStrLn "The impossible happened"
  | ^

However, runghc Main.hs (starting with GHC 8.8.1) will happily run this invalid program:

$ runghc Main.hs
The impossible happened

This inconsistent behaviour has lead to less informed people assuming such a program might be actually "valid" Haskell.

Edited by Herbert Valerio Riedel
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information