• simonpj's avatar
    [project @ 2001-06-25 08:09:57 by simonpj] · d069cec2
    simonpj authored
    ----------------
    	Squash newtypes
    	----------------
    
    This commit squashes newtypes and their coerces, from the typechecker
    onwards.  The original idea was that the coerces would not get in the
    way of optimising transformations, but despite much effort they continue
    to do so.   There's no very good reason to retain newtype information
    beyond the typechecker, so now we don't.
    
    Main points:
    
    * The post-typechecker suite of Type-manipulating functions is in
    types/Type.lhs, as before.   But now there's a new suite in types/TcType.lhs.
    The difference is that in the former, newtype are transparent, while in
    the latter they are opaque.  The typechecker should only import TcType,
    not Type.
    
    * The operations in TcType are all non-monadic, and most of them start with
    "tc" (e.g. tcSplitTyConApp).  All the monadic operations (used exclusively
    by the typechecker) are in a new module, typecheck/TcMType.lhs
    
    * I've grouped newtypes with predicate types, thus:
    	data Type = TyVarTy Tyvar | ....
    		  | SourceTy SourceType
    
    	data SourceType = NType TyCon [Type]
    			| ClassP Class [Type]
    			| IParam Type
    
    [SourceType was called PredType.]  This is a little wierd in some ways,
    because NTypes can't occur in qualified types.   However, the idea is that
    a SourceType is a type that is opaque to the type checker, but transparent
    to the rest of the compiler, and newtypes fit that as do implicit parameters
    and dictionaries.
    
    * Recursive newtypes still retain their coreces, exactly as before. If
    they were transparent we'd get a recursive type, and that would make
    various bits of the compiler diverge (e.g. things which do type comparison).
    
    * I've removed types/Unify.lhs (non-monadic type unifier and matcher),
    merging it into TcType.
    
    Ditto typecheck/TcUnify.lhs (monadic unifier), merging it into TcMType.
    d069cec2
MkExternalCore.lhs 7.48 KB