wordTy,
wordTyCon,
- isFFIArgumentTy, -- :: Bool -> Type -> Bool
- isFFIResultTy, -- :: Type -> Bool
- isFFIExternalTy, -- :: Type -> Bool
- isFFIDynResultTy, -- :: Type -> Bool
- isFFILabelTy, -- :: Type -> Bool
- isAddrTy, -- :: Type -> Bool
- isForeignObjTy -- :: Type -> Bool
+ isFFIArgumentTy, -- :: Bool -> Type -> Bool
+ isFFIResultTy, -- :: Type -> Bool
+ isFFIExternalTy, -- :: Type -> Bool
+ isFFIDynArgumentTy, -- :: Type -> Bool
+ isFFIDynResultTy, -- :: Type -> Bool
+ isFFILabelTy, -- :: Type -> Bool
+ isAddrTy, -- :: Type -> Bool
+ isForeignObjTy -- :: Type -> Bool
) where
-- But we allow () as well
isFFIResultTy ty = checkRepTyCon (\tc -> tc == unitTyCon || legalIncomingTyCon tc) ty
+isFFIDynArgumentTy :: Type -> Bool
+-- The argument type of a foreign import dynamic must be either Addr, or
+-- a newtype of Addr.
+isFFIDynArgumentTy = checkRepTyCon (== addrTyCon)
+
+isFFIDynResultTy :: Type -> Bool
-- The result type of a foreign export dynamic must be either Addr, or
-- a newtype of Addr.
isFFIDynResultTy = checkRepTyCon (== addrTyCon)
+isFFILabelTy :: Type -> Bool
-- The type of a foreign label must be either Addr, or
-- a newtype of Addr.
isFFILabelTy = checkRepTyCon (== addrTyCon)
, splitForAllTys
)
import TysWiredIn ( isFFIArgumentTy, isFFIResultTy,
- isFFIExternalTy, isAddrTy,
- isFFIDynResultTy, isFFILabelTy
+ isFFIExternalTy, isFFIDynArgumentTy, isFFIDynResultTy,
+ isFFILabelTy
)
import Type ( Type )
import Unique
case args of
[] -> check False (illegalForeignTyErr True{-Arg-} ty)
(x:xs) ->
- check (isAddrTy x) (illegalForeignTyErr True{-Arg-} ty) `thenTc_`
+ check (isFFIDynArgumentTy x) (illegalForeignTyErr True{-Arg-} ty) `thenTc_`
mapTc (checkForeignArg (isFFIArgumentTy is_safe)) xs `thenTc_`
checkForeignRes True {-NonIO ok-} isFFIResultTy res
| otherwise =
| is_dynamic =
-- * the first (and only!) arg has got to be a function type
-- and it must return IO t
- -- * result type is an Addr or IO Addr
+ -- * result type is IO Addr
case args of
[arg] ->
case splitFunTys arg of