Skip to content

Inconsistent renaming of unit type and constructor

I'm trying to emulate Purescript's idiom of explicit imports and I've noticed something odd:

GHCi claims

Prelude> :info ()
data () = () 	-- Defined in ‘GHC.Tuple’
instance Eq () -- Defined in ‘GHC.Classes’
instance Monoid () -- Defined in ‘GHC.Base’
instance Ord () -- Defined in ‘GHC.Classes’
instance Semigroup () -- Defined in ‘GHC.Base’
instance Show () -- Defined in ‘GHC.Show’
instance Read () -- Defined in ‘GHC.Read’
instance Enum () -- Defined in ‘GHC.Enum’
instance Bounded () -- Defined in ‘GHC.Enum’

However, data () = () is always in scope even when the Prelude namespace is moved around or thinned. The code below compiles even though () wasn't imported:

module Main where

import qualified Prelude (IO, return)

main :: Prelude.IO ()
main = Prelude.return ()

Moreoever it's not possible to import data () = () from GHC.Tuple, i.e.

import GHC.Tuple ( () )

as well as

import GHC.Tuple ( (()) )

fail with a parser error.

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