Arity(..), NewOrData(..),
isFunTyCon, isPrimTyCon, isBoxedTyCon,
- isDataTyCon, isSynTyCon,
+ isDataTyCon, isSynTyCon, isNewTyCon,
mkDataTyCon,
mkFunTyCon,
import TyVar ( GenTyVar, alphaTyVars, alphaTyVar, betaTyVar )
import Usage ( GenUsage, Usage(..) )
import Kind ( Kind, mkBoxedTypeKind, mkArrowKind, resultKind, argKind )
-import PrelMods ( pRELUDE_BUILTIN )
import Maybes
import Name ( Name, RdrName(..), appendRdr, nameUnique,
mkTupleTyConName, mkFunTyConName
)
import Unique ( Unique, funTyConKey, mkTupleTyConUnique )
+import PrelInfo ( intDataCon, charDataCon )
import Pretty ( Pretty(..), PrettyRep )
import PprStyle ( PprStyle )
import SrcLoc ( SrcLoc, mkBuiltinSrcLoc )
+import Unique ( intDataConKey, charDataConKey )
import Util ( panic, panic#, nOfThem, isIn, Ord3(..) )
\end{code}
-- isDataTyCon returns False for @newtype@.
-- Not sure about this decision yet.
isDataTyCon (DataTyCon _ _ _ _ _ _ _ DataType) = True
+isDataTyCon (TupleTyCon _ _ _) = True
isDataTyCon other = False
+isNewTyCon (DataTyCon _ _ _ _ _ _ _ NewType) = True
+isNewTyCon other = False
+
isSynTyCon (SynTyCon _ _ _ _ _ _) = True
isSynTyCon _ = False
\end{code}
tyConKind FunTyCon = kind2
tyConKind (DataTyCon _ _ kind _ _ _ _ _) = kind
tyConKind (PrimTyCon _ _ kind) = kind
-
-tyConKind (SpecTyCon tc tys)
- = spec (tyConKind tc) tys
- where
- spec kind [] = kind
- spec kind (Just _ : tys) = spec (resultKind kind) tys
- spec kind (Nothing : tys) =
- argKind kind `mkArrowKind` spec (resultKind kind) tys
+tyConKind (SynTyCon _ _ k _ _ _) = k
tyConKind (TupleTyCon _ _ n)
= mkArrow n
mkArrow 1 = kind1
mkArrow 2 = kind2
mkArrow n = mkBoxedTypeKind `mkArrowKind` mkArrow (n-1)
+
+tyConKind (SpecTyCon tc tys)
+ = spec (tyConKind tc) tys
+ where
+ spec kind [] = kind
+ spec kind (Just _ : tys) = spec (resultKind kind) tys
+ spec kind (Nothing : tys) =
+ argKind kind `mkArrowKind` spec (resultKind kind) tys
\end{code}
\begin{code}
\begin{code}
tyConDerivings :: TyCon -> [Class]
tyConDerivings (DataTyCon _ _ _ _ _ _ derivs _) = derivs
-tyConDerivings other = []
+tyConDerivings other = []
\end{code}
\begin{code}
where
tag1 = tag_TyCon other_1
tag2 = tag_TyCon other_2
+
tag_TyCon FunTyCon = ILIT(1)
tag_TyCon (DataTyCon _ _ _ _ _ _ _ _) = ILIT(2)
tag_TyCon (TupleTyCon _ _ _) = ILIT(3)
tag_TyCon (PrimTyCon _ _ _) = ILIT(4)
tag_TyCon (SpecTyCon _ _) = ILIT(5)
+ tag_TyCon (SynTyCon _ _ _ _ _ _) = ILIT(6)
instance Eq TyCon where
a == b = case (a `cmp` b) of { EQ_ -> True; _ -> False }
_tagCmp a b = case (a `cmp` b) of { LT_ -> _LT; EQ_ -> _EQ; GT__ -> _GT }
instance Uniquable TyCon where
- uniqueOf (DataTyCon u _ _ _ _ _ _ _) = u
- uniqueOf (PrimTyCon u _ _) = u
- uniqueOf (SynTyCon u _ _ _ _ _) = u
- uniqueOf tc@(SpecTyCon _ _) = panic "uniqueOf:SpecTyCon"
- uniqueOf tc = uniqueOf (getName tc)
+ uniqueOf (DataTyCon u _ _ _ _ _ _ _) = u
+ uniqueOf (TupleTyCon u _ _) = u
+ uniqueOf (PrimTyCon u _ _) = u
+ uniqueOf (SynTyCon u _ _ _ _ _) = u
+ uniqueOf tc@(SpecTyCon _ _) = panic "uniqueOf:SpecTyCon"
+ uniqueOf tc = uniqueOf (getName tc)
\end{code}
\begin{code}
getName tc = panic "TyCon.getName"
{- LATER:
- getName (SpecTyCon tc tys) = let (m,n) = getOrigName tc in
+ getName (SpecTyCon tc tys) = let (m,n) = moduleNamePair tc in
(m, n _APPEND_ specMaybeTysSuffix tys)
- getName other_tc = getOrigName (expectJust "tycon1" (getName other_tc))
+ getName other_tc = moduleNamePair (expectJust "tycon1" (getName other_tc))
getName other = Nothing
-}
\end{code}