-eqSimpleTy :: (Eq t,Eq u) => GenType t u -> GenType t u -> Bool
-
-(TyVarTy tv1) `eqSimpleTy` (TyVarTy tv2) =
- tv1 == tv2
-(AppTy f1 a1) `eqSimpleTy` (AppTy f2 a2) =
- f1 `eqSimpleTy` f2 && a1 `eqSimpleTy` a2
-(TyConTy tc1 u1) `eqSimpleTy` (TyConTy tc2 u2) =
- tc1 == tc2 --ToDo: later: && u1 == u2
-
-(FunTy f1 a1 u1) `eqSimpleTy` (FunTy f2 a2 u2) =
- f1 `eqSimpleTy` f2 && a1 `eqSimpleTy` a2 && u1 == u2
-(FunTy f1 a1 u1) `eqSimpleTy` t2 =
- -- Expand t1 just in case t2 matches that version
- (AppTy (AppTy (TyConTy mkFunTyCon u1) f1) a1) `eqSimpleTy` t2
-t1 `eqSimpleTy` (FunTy f2 a2 u2) =
- -- Expand t2 just in case t1 matches that version
- t1 `eqSimpleTy` (AppTy (AppTy (TyConTy mkFunTyCon u2) f2) a2)
-
-(SynTy tc1 ts1 t1) `eqSimpleTy` (SynTy tc2 ts2 t2) =
- (tc1 == tc2 && and (zipWith eqSimpleTy ts1 ts2) && length ts1 == length ts2)
- || t1 `eqSimpleTy` t2
-(SynTy _ _ t1) `eqSimpleTy` t2 =
- t1 `eqSimpleTy` t2 -- Expand the abbrevation and try again
-t1 `eqSimpleTy` (SynTy _ _ t2) =
- t1 `eqSimpleTy` t2 -- Expand the abbrevation and try again
-
-(DictTy _ _ _) `eqSimpleTy` _ = panic "eqSimpleTy: got DictTy"
-_ `eqSimpleTy` (DictTy _ _ _) = panic "eqSimpleTy: got DictTy"
-
-(ForAllTy _ _) `eqSimpleTy` _ = panic "eqSimpleTy: got ForAllTy"
-_ `eqSimpleTy` (ForAllTy _ _) = panic "eqSimpleTy: got ForAllTy"
-
-(ForAllUsageTy _ _ _) `eqSimpleTy` _ = panic "eqSimpleTy: got ForAllUsageTy"
-_ `eqSimpleTy` (ForAllUsageTy _ _ _) = panic "eqSimpleTy: got ForAllUsageTy"
-
-_ `eqSimpleTy` _ = False
-\end{code}
-
-Types are ordered so we can sort on types in the renamer etc. DNT: Since
-this class is also used in CoreLint and other such places, we DO expand out
-Fun/Syn/Dict types (if necessary).
-
-\begin{code}
-eqTy :: Type -> Type -> Bool
-
-eqTy t1 t2 =
- eq nullTyVarEnv nullUVarEnv t1 t2
- where
- eq tve uve (TyVarTy tv1) (TyVarTy tv2) =
- tv1 == tv2 ||
- case (lookupTyVarEnv tve tv1) of
- Just tv -> tv == tv2
- Nothing -> False
- eq tve uve (AppTy f1 a1) (AppTy f2 a2) =
- eq tve uve f1 f2 && eq tve uve a1 a2
- eq tve uve (TyConTy tc1 u1) (TyConTy tc2 u2) =
- tc1 == tc2 -- ToDo: LATER: && eqUsage uve u1 u2
-
- eq tve uve (FunTy f1 a1 u1) (FunTy f2 a2 u2) =
- eq tve uve f1 f2 && eq tve uve a1 a2 && eqUsage uve u1 u2
- eq tve uve (FunTy f1 a1 u1) t2 =
- -- Expand t1 just in case t2 matches that version
- eq tve uve (AppTy (AppTy (TyConTy mkFunTyCon u1) f1) a1) t2
- eq tve uve t1 (FunTy f2 a2 u2) =
- -- Expand t2 just in case t1 matches that version
- eq tve uve t1 (AppTy (AppTy (TyConTy mkFunTyCon u2) f2) a2)
-
- eq tve uve (DictTy c1 t1 u1) (DictTy c2 t2 u2)
- | c1 == c2
- = eq tve uve t1 t2 && eqUsage uve u1 u2
- -- NB we use a guard for c1==c2 so that if they aren't equal we
- -- fall through into expanding the type. Why? Because brain-dead
- -- people might write
- -- class Foo a => Baz a where {}
- -- and that means that a Foo dictionary and a Baz dictionary are identical
- -- Sigh. Let's hope we don't spend too much time in here!
-
- eq tve uve t1@(DictTy _ _ _) t2 =
- eq tve uve (expandTy t1) t2 -- Expand the dictionary and try again
- eq tve uve t1 t2@(DictTy _ _ _) =
- eq tve uve t1 (expandTy t2) -- Expand the dictionary and try again
-
- eq tve uve (SynTy tc1 ts1 t1) (SynTy tc2 ts2 t2) =
- (tc1 == tc2 && and (zipWith (eq tve uve) ts1 ts2) && length ts1 == length ts2)
- || eq tve uve t1 t2
- eq tve uve (SynTy _ _ t1) t2 =
- eq tve uve t1 t2 -- Expand the abbrevation and try again
- eq tve uve t1 (SynTy _ _ t2) =
- eq tve uve t1 t2 -- Expand the abbrevation and try again
-
- eq tve uve (ForAllTy tv1 t1) (ForAllTy tv2 t2) =
- eq (addOneToTyVarEnv tve tv1 tv2) uve t1 t2
- eq tve uve (ForAllUsageTy u1 b1 t1) (ForAllUsageTy u2 b2 t2) =
- eqBounds uve b1 b2 && eq tve (addOneToUVarEnv uve u1 u2) t1 t2
-
- eq _ _ _ _ = False
-
- eqBounds uve [] [] = True
- eqBounds uve (u1:b1) (u2:b2) = eqUVar uve u1 u2 && eqBounds uve b1 b2
- eqBounds uve _ _ = False
+showTypeCategory :: Type -> Char
+ {-
+ {C,I,F,D} char, int, float, double
+ T tuple
+ S other single-constructor type
+ {c,i,f,d} unboxed ditto
+ t *unpacked* tuple
+ s *unpacked" single-cons...
+
+ v void#
+ a primitive array
+
+ E enumeration type
+ + dictionary, unless it's a ...
+ L List
+ > function
+ M other (multi-constructor) data-con type
+ . other type
+ - reserved for others to mark as "uninteresting"
+ -}
+showTypeCategory ty
+ = if isDictTy ty
+ then '+'
+ else
+ case splitTyConApp_maybe ty of
+ Nothing -> if maybeToBool (splitFunTy_maybe ty)
+ then '>'
+ else '.'
+
+ Just (tycon, _) ->
+ let utc = getUnique tycon in
+ if utc == charDataConKey then 'C'
+ else if utc == intDataConKey then 'I'
+ else if utc == floatDataConKey then 'F'
+ else if utc == doubleDataConKey then 'D'
+ else if utc == integerDataConKey then 'J'
+ else if utc == charPrimTyConKey then 'c'
+ else if (utc == intPrimTyConKey || utc == wordPrimTyConKey
+ || utc == addrPrimTyConKey) then 'i'
+ else if utc == floatPrimTyConKey then 'f'
+ else if utc == doublePrimTyConKey then 'd'
+ else if isPrimTyCon tycon {- array, we hope -} then 'A'
+ else if isEnumerationTyCon tycon then 'E'
+ else if isTupleTyCon tycon then 'T'
+ else if maybeToBool (maybeTyConSingleCon tycon) then 'S'
+ else if utc == listTyConKey then 'L'
+ else 'M' -- oh, well...