-stateAndPtrPrimTyCon
- = pcDataTyCon stateAndPtrPrimTyConKey sT_BASE SLIT("StateAndPtr#")
- alpha_beta_tyvars [stateAndPtrPrimDataCon]
-stateAndPtrPrimDataCon
- = pcDataCon stateAndPtrPrimDataConKey sT_BASE SLIT("StateAndPtr#")
- alpha_beta_tyvars [] [mkStatePrimTy alphaTy, betaTy]
- stateAndPtrPrimTyCon nullSpecEnv
-
-stateAndCharPrimTyCon
- = pcDataTyCon stateAndCharPrimTyConKey sT_BASE SLIT("StateAndChar#")
- alpha_tyvar [stateAndCharPrimDataCon]
-stateAndCharPrimDataCon
- = pcDataCon stateAndCharPrimDataConKey sT_BASE SLIT("StateAndChar#")
- alpha_tyvar [] [mkStatePrimTy alphaTy, charPrimTy]
- stateAndCharPrimTyCon nullSpecEnv
-
-stateAndIntPrimTyCon
- = pcDataTyCon stateAndIntPrimTyConKey sT_BASE SLIT("StateAndInt#")
- alpha_tyvar [stateAndIntPrimDataCon]
-stateAndIntPrimDataCon
- = pcDataCon stateAndIntPrimDataConKey sT_BASE SLIT("StateAndInt#")
- alpha_tyvar [] [mkStatePrimTy alphaTy, intPrimTy]
- stateAndIntPrimTyCon nullSpecEnv
-
-stateAndWordPrimTyCon
- = pcDataTyCon stateAndWordPrimTyConKey sT_BASE SLIT("StateAndWord#")
- alpha_tyvar [stateAndWordPrimDataCon]
-stateAndWordPrimDataCon
- = pcDataCon stateAndWordPrimDataConKey sT_BASE SLIT("StateAndWord#")
- alpha_tyvar [] [mkStatePrimTy alphaTy, wordPrimTy]
- stateAndWordPrimTyCon nullSpecEnv
-
-stateAndAddrPrimTyCon
- = pcDataTyCon stateAndAddrPrimTyConKey sT_BASE SLIT("StateAndAddr#")
- alpha_tyvar [stateAndAddrPrimDataCon]
-stateAndAddrPrimDataCon
- = pcDataCon stateAndAddrPrimDataConKey sT_BASE SLIT("StateAndAddr#")
- alpha_tyvar [] [mkStatePrimTy alphaTy, addrPrimTy]
- stateAndAddrPrimTyCon nullSpecEnv
-
-stateAndStablePtrPrimTyCon
- = pcDataTyCon stateAndStablePtrPrimTyConKey fOREIGN SLIT("StateAndStablePtr#")
- alpha_beta_tyvars [stateAndStablePtrPrimDataCon]
-stateAndStablePtrPrimDataCon
- = pcDataCon stateAndStablePtrPrimDataConKey fOREIGN SLIT("StateAndStablePtr#")
- alpha_beta_tyvars []
- [mkStatePrimTy alphaTy, applyTyCon stablePtrPrimTyCon [betaTy]]
- stateAndStablePtrPrimTyCon nullSpecEnv
-
-stateAndForeignObjPrimTyCon
- = pcDataTyCon stateAndForeignObjPrimTyConKey fOREIGN SLIT("StateAndForeignObj#")
- alpha_tyvar [stateAndForeignObjPrimDataCon]
-stateAndForeignObjPrimDataCon
- = pcDataCon stateAndForeignObjPrimDataConKey fOREIGN SLIT("StateAndForeignObj#")
- alpha_tyvar []
- [mkStatePrimTy alphaTy, applyTyCon foreignObjPrimTyCon []]
- stateAndForeignObjPrimTyCon nullSpecEnv
-
-stateAndFloatPrimTyCon
- = pcDataTyCon stateAndFloatPrimTyConKey sT_BASE SLIT("StateAndFloat#")
- alpha_tyvar [stateAndFloatPrimDataCon]
-stateAndFloatPrimDataCon
- = pcDataCon stateAndFloatPrimDataConKey sT_BASE SLIT("StateAndFloat#")
- alpha_tyvar [] [mkStatePrimTy alphaTy, floatPrimTy]
- stateAndFloatPrimTyCon nullSpecEnv
-
-stateAndDoublePrimTyCon
- = pcDataTyCon stateAndDoublePrimTyConKey sT_BASE SLIT("StateAndDouble#")
- alpha_tyvar [stateAndDoublePrimDataCon]
-stateAndDoublePrimDataCon
- = pcDataCon stateAndDoublePrimDataConKey sT_BASE SLIT("StateAndDouble#")
- alpha_tyvar [] [mkStatePrimTy alphaTy, doublePrimTy]
- stateAndDoublePrimTyCon nullSpecEnv
-\end{code}
-
-\begin{code}
-stateAndArrayPrimTyCon
- = pcDataTyCon stateAndArrayPrimTyConKey aRR_BASE SLIT("StateAndArray#")
- alpha_beta_tyvars [stateAndArrayPrimDataCon]
-stateAndArrayPrimDataCon
- = pcDataCon stateAndArrayPrimDataConKey aRR_BASE SLIT("StateAndArray#")
- alpha_beta_tyvars [] [mkStatePrimTy alphaTy, mkArrayPrimTy betaTy]
- stateAndArrayPrimTyCon nullSpecEnv
-
-stateAndMutableArrayPrimTyCon
- = pcDataTyCon stateAndMutableArrayPrimTyConKey aRR_BASE SLIT("StateAndMutableArray#")
- alpha_beta_tyvars [stateAndMutableArrayPrimDataCon]
-stateAndMutableArrayPrimDataCon
- = pcDataCon stateAndMutableArrayPrimDataConKey aRR_BASE SLIT("StateAndMutableArray#")
- alpha_beta_tyvars [] [mkStatePrimTy alphaTy, mkMutableArrayPrimTy alphaTy betaTy]
- stateAndMutableArrayPrimTyCon nullSpecEnv
-
-stateAndByteArrayPrimTyCon
- = pcDataTyCon stateAndByteArrayPrimTyConKey aRR_BASE SLIT("StateAndByteArray#")
- alpha_tyvar [stateAndByteArrayPrimDataCon]
-stateAndByteArrayPrimDataCon
- = pcDataCon stateAndByteArrayPrimDataConKey aRR_BASE SLIT("StateAndByteArray#")
- alpha_tyvar [] [mkStatePrimTy alphaTy, byteArrayPrimTy]
- stateAndByteArrayPrimTyCon nullSpecEnv
-
-stateAndMutableByteArrayPrimTyCon
- = pcDataTyCon stateAndMutableByteArrayPrimTyConKey aRR_BASE SLIT("StateAndMutableByteArray#")
- alpha_tyvar [stateAndMutableByteArrayPrimDataCon]
-stateAndMutableByteArrayPrimDataCon
- = pcDataCon stateAndMutableByteArrayPrimDataConKey aRR_BASE SLIT("StateAndMutableByteArray#")
- alpha_tyvar [] [mkStatePrimTy alphaTy, applyTyCon mutableByteArrayPrimTyCon alpha_ty]
- stateAndMutableByteArrayPrimTyCon nullSpecEnv
-
-stateAndSynchVarPrimTyCon
- = pcDataTyCon stateAndSynchVarPrimTyConKey cONC_BASE SLIT("StateAndSynchVar#")
- alpha_beta_tyvars [stateAndSynchVarPrimDataCon]
-stateAndSynchVarPrimDataCon
- = pcDataCon stateAndSynchVarPrimDataConKey cONC_BASE SLIT("StateAndSynchVar#")
- alpha_beta_tyvars [] [mkStatePrimTy alphaTy, mkSynchVarPrimTy alphaTy betaTy]
- stateAndSynchVarPrimTyCon nullSpecEnv
-\end{code}
-
-The ccall-desugaring mechanism uses this function to figure out how to
-rebox the result. It's really a HACK, especially the part about
-how many types to drop from \tr{tys_applied}.
-
-\begin{code}
-getStatePairingConInfo
- :: Type -- primitive type
- -> (Id, -- state pair constructor for prim type
- Type) -- type of state pair
-
-getStatePairingConInfo prim_ty
- = case (maybeAppTyCon prim_ty) of
- Nothing -> panic "getStatePairingConInfo:1"
- Just (prim_tycon, tys_applied) ->
+isFFIArgumentTy :: Type -> Bool
+isFFIArgumentTy ty =
+ (opt_GlasgowExts && isUnLiftedType ty) || --leave out for now: maybeToBool (maybeBoxedPrimType ty))) ||
+ case (splitAlgTyConApp_maybe ty) of
+ Just (tycon, _, _) -> (getUnique tycon) `elem` primArgTyConKeys
+ _ -> False
+
+-- types that can be passed as arguments to "foreign" functions
+primArgTyConKeys
+ = [ intTyConKey, int8TyConKey, int16TyConKey, int32TyConKey, int64TyConKey
+ , wordTyConKey, word8TyConKey, word16TyConKey, word32TyConKey, word64TyConKey
+ , floatTyConKey, doubleTyConKey
+ , addrTyConKey, charTyConKey, foreignObjTyConKey
+ , stablePtrTyConKey, byteArrayTyConKey, mutableByteArrayTyConKey
+ ]
+
+-- types that can be passed from the outside world into Haskell.
+-- excludes (mutable) byteArrays.
+isFFIExternalTy :: Type -> Bool
+isFFIExternalTy ty =
+ (opt_GlasgowExts && isUnLiftedType ty) || --leave out for now: maybeToBool (maybeBoxedPrimType ty))) ||
+ case (splitAlgTyConApp_maybe ty) of
+ Just (tycon, _, _) ->
+ let
+ u_tycon = getUnique tycon
+ in
+ (u_tycon `elem` primArgTyConKeys) &&
+ not (u_tycon `elem` notLegalExternalTyCons)
+ _ -> False
+
+
+isFFIResultTy :: Type -> Bool
+isFFIResultTy ty =
+ not (isUnLiftedType ty) &&
+ case (splitAlgTyConApp_maybe ty) of
+ Just (tycon, _, _) ->