-isDoubleTy :: Type -> Bool
-isDoubleTy = isTyCon doubleTyConKey
-
-doubleTyCon = pcNonRecDataTyCon doubleTyConKey pREL_FLOAT SLIT("Double") [] [] [doubleDataCon]
-doubleDataCon = pcDataCon doubleDataConKey pREL_FLOAT SLIT("D#") [] [] [doublePrimTy] doubleTyCon
-\end{code}
-
-\begin{code}
-stablePtrTyCon
- = pcNonRecDataTyCon stablePtrTyConKey pREL_STABLE SLIT("StablePtr")
- alpha_tyvar [(True,False)] [stablePtrDataCon]
- where
- stablePtrDataCon
- = pcDataCon stablePtrDataConKey pREL_STABLE SLIT("StablePtr")
- alpha_tyvar [] [mkStablePtrPrimTy alphaTy] stablePtrTyCon
-\end{code}
-
-\begin{code}
-foreignObjTyCon
- = pcNonRecDataTyCon foreignObjTyConKey pREL_IO_BASE SLIT("ForeignObj")
- [] [] [foreignObjDataCon]
- where
- foreignObjDataCon
- = pcDataCon foreignObjDataConKey pREL_IO_BASE SLIT("ForeignObj")
- [] [] [foreignObjPrimTy] foreignObjTyCon
-
-isForeignObjTy :: Type -> Bool
-isForeignObjTy = isTyCon foreignObjTyConKey
-\end{code}
-
-%************************************************************************
-%* *
-\subsection[TysWiredIn-Integer]{@Integer@ and its related ``pairing'' types}
-%* *
-%************************************************************************
-
-@Integer@ and its pals are not really primitive. @Integer@ itself, first:
-\begin{code}
-integerTy :: Type
-integerTy = mkTyConTy integerTyCon
-
-integerTyCon = pcNonRecDataTyCon integerTyConKey pREL_NUM SLIT("Integer")
- [] [] [smallIntegerDataCon, largeIntegerDataCon]
-
-smallIntegerDataCon = pcDataCon smallIntegerDataConKey pREL_NUM SLIT("S#")
- [] [] [intPrimTy] integerTyCon
-largeIntegerDataCon = pcDataCon largeIntegerDataConKey pREL_NUM SLIT("J#")
- [] [] [intPrimTy, byteArrayPrimTy] integerTyCon
-
-
-isIntegerTy :: Type -> Bool
-isIntegerTy = isTyCon integerTyConKey
-\end{code}
-
-
-%************************************************************************
-%* *
-\subsection[TysWiredIn-ext-type]{External types}
-%* *
-%************************************************************************
-
-The compiler's foreign function interface supports the passing of a
-restricted set of types as arguments and results (the restricting factor
-being the )
-
-\begin{code}
-isFFIArgumentTy :: Bool -> Type -> Bool
--- Checks for valid argument type for a 'foreign import'
-isFFIArgumentTy is_safe ty = checkRepTyCon (legalOutgoingTyCon is_safe) ty
-
-isFFIExternalTy :: Type -> Bool
--- Types that are allowed as arguments of a 'foreign export'
-isFFIExternalTy ty = checkRepTyCon legalIncomingTyCon ty
-
-isFFIResultTy :: Type -> Bool
--- Types that are allowed as a result of a 'foreign import' or of a 'foreign export'
--- Maybe we should distinguish between import and export, but
--- here we just choose the more restrictive 'incoming' predicate
--- But we allow () as well
-isFFIResultTy ty = checkRepTyCon (\tc -> tc == unitTyCon || legalIncomingTyCon tc) ty
-
-checkRepTyCon :: (TyCon -> Bool) -> Type -> Bool
- -- look through newtypes
-checkRepTyCon check_tc ty = checkTyCon check_tc (repType ty)
-
-checkTyCon :: (TyCon -> Bool) -> Type -> Bool
-checkTyCon check_tc ty = case splitTyConApp_maybe ty of
- Just (tycon, _) -> check_tc tycon
- Nothing -> False
-
-isTyCon :: Unique -> Type -> Bool
-isTyCon uniq ty = checkTyCon (\tc -> uniq == getUnique tc) ty
-\end{code}
-
-----------------------------------------------
-These chaps do the work; they are not exported
-----------------------------------------------
-
-\begin{code}
-legalIncomingTyCon :: TyCon -> Bool
--- It's illegal to return foreign objects and (mutable)
--- bytearrays from a _ccall_ / foreign declaration
--- (or be passed them as arguments in foreign exported functions).
-legalIncomingTyCon tc
- | getUnique tc `elem` [ foreignObjTyConKey, byteArrayTyConKey, mutableByteArrayTyConKey ]
- = False
- | otherwise
- = marshalableTyCon tc
-
-legalOutgoingTyCon :: Bool -> TyCon -> Bool
--- Checks validity of types going from Haskell -> external world
--- The boolean is true for a 'safe' call (when we don't want to
--- pass Haskell pointers to the world)
-legalOutgoingTyCon be_safe tc
- | be_safe && getUnique tc `elem` [byteArrayTyConKey, mutableByteArrayTyConKey]
- = False
- | otherwise
- = marshalableTyCon tc
-
-marshalableTyCon tc
- = (opt_GlasgowExts && isUnLiftedTyCon tc)
- || getUnique tc `elem` [ intTyConKey, int8TyConKey, int16TyConKey, int32TyConKey, int64TyConKey
- , wordTyConKey, word8TyConKey, word16TyConKey, word32TyConKey, word64TyConKey
- , floatTyConKey, doubleTyConKey
- , addrTyConKey, charTyConKey, foreignObjTyConKey
- , stablePtrTyConKey
- , byteArrayTyConKey, mutableByteArrayTyConKey
- , boolTyConKey
- ]