[project @ 2001-08-29 10:12:34 by simonmar]
[ghc-hetmet.git] / ghc / compiler / hsSyn / HsTypes.lhs
index f5156ae..49040bf 100644 (file)
@@ -11,7 +11,10 @@ module HsTypes (
         , hsUsOnce, hsUsMany
 
        , mkHsForAllTy, mkHsDictTy, mkHsIParamTy
-       , hsTyVarName, hsTyVarNames, replaceTyVarName
+       , hsTyVarName, hsTyVarNames, replaceTyVarName,
+       
+       -- Type place holder
+       PostTcType, placeHolderType,
 
        -- Printing
        , pprParendHsType, pprHsForAll, pprHsContext, pprHsTyVarBndr
@@ -36,17 +39,41 @@ import RdrName              ( RdrName, mkUnqual )
 import Name            ( Name, getName )
 import OccName         ( NameSpace, tvName )
 import Var             ( TyVar, tyVarKind )
-import Subst           ( mkTyVarSubst, substTy )
+import Subst           ( substTyWith )
 import PprType         ( {- instance Outputable Kind -}, pprParendKind )
 import BasicTypes      ( Boxity(..), Arity, tupleParens )
 import PrelNames       ( mkTupConRdrName, listTyConKey, usOnceTyConKey, usManyTyConKey, hasKey,
                          usOnceTyConName, usManyTyConName
                        )
 import FiniteMap
+import Util            ( eqListBy )
 import Outputable
+\end{code}
+
+
+%************************************************************************
+%*                                                                     *
+\subsection{Annotating the syntax}
+%*                                                                     *
+%************************************************************************
+
+\begin{code}
+type PostTcType = Type         -- Used for slots in the abstract syntax
+                               -- where we want to keep slot for a type
+                               -- to be added by the type checker...but
+                               -- before typechecking it's just bogus
 
+placeHolderType :: PostTcType  -- Used before typechecking
+placeHolderType  = panic "Evaluated the place holder for a PostTcType"
 \end{code}
 
+
+%************************************************************************
+%*                                                                     *
+\subsection{Data types}
+%*                                                                     *
+%************************************************************************
+
 This is the syntax for types as seen in type signatures.
 
 \begin{code}
@@ -75,6 +102,7 @@ data HsType name
   -- Generics
   | HsOpTy             (HsType name) name (HsType name)
   | HsNumTy             Integer
+
   -- these next two are only used in interfaces
   | HsPredTy           (HsPred name)
   
@@ -285,7 +313,7 @@ toHsType (NoteTy (SynNote ty@(TyConApp tycon tyargs)) real_ty)
   where
     syn_matches      = ty_from_syn `tcEqType` real_ty
     (tyvars,syn_ty)  = getSynTyConDefn tycon
-    ty_from_syn      = substTy (mkTyVarSubst tyvars tyargs) syn_ty
+    ty_from_syn      = substTyWith tyvars tyargs syn_ty
 
     -- We only use the type synonym in the file if this doesn't cause
     -- us to lose important information.  This matters for usage
@@ -443,10 +471,4 @@ eq_hsPred env (HsClassP c1 tys1) (HsClassP c2 tys2)
 eq_hsPred env (HsIParam n1 ty1) (HsIParam n2 ty2)
   = n1 == n2 && eq_hsType env ty1 ty2
 eq_hsPred env _ _ = False
-
--------------------
-eqListBy :: (a->a->Bool) -> [a] -> [a] -> Bool
-eqListBy eq []     []     = True
-eqListBy eq (x:xs) (y:ys) = eq x y && eqListBy eq xs ys
-eqListBy eq xs     ys     = False
 \end{code}