• simonpj's avatar
    [project @ 2002-02-13 15:19:17 by simonpj] · 711e4d7a
    simonpj authored
    	Do the Right Thing for TyCons where we
    	can't see all their constructors.
    Inside a TyCon, three things can happen
    1. GHC knows all the constructors, and has them to hand.
       (Nowadays, there may be zero constructors.)
    2. GHC knows all the constructors, but has declined to slurp
       them all in, to avoid sucking in more declarations than
       necessary.  All we remember is the number of constructors,
       so we can get the return convention right.
    3. GHC doesn't know anything. This happens *only* for decls
       coming from .hi-boot files, where the programmer declines to
       supply a representation.
    Until now, these three cases have been conflated together.  Matters
    are worse now that a TyCon really can have zero constructors.  In
    fact, by confusing (3) with (1) we can actually generate bogus code.
    With this commit, the dataCons field of a TyCon is of type:
    data DataConDetails datacon
      = DataCons [datacon]	-- Its data constructors, with fully polymorphic types
    			-- A type can have zero constructors
      | Unknown		-- We're importing this data type from an hi-boot file
    			-- and we don't know what its constructors are
      | HasCons Int		-- In a quest for compilation speed we have imported
    			-- only the number of constructors (to get return
    			-- conventions right) but not the constructors themselves
    This says exactly what is going on.  There are lots of consequential small