- | isDynamicTarget target -- Foreign import dynamic
- = checkCg checkCOrAsmOrInterp `thenM_`
- checkCConv cconv `thenM_`
- case arg_tys of -- The first arg must be Ptr, FunPtr, or Addr
- [] ->
- check False (illegalForeignTyErr empty sig_ty) `thenM_`
- return idecl
- (arg1_ty:arg_tys) ->
- getDOpts `thenM` \ dflags ->
- check (isFFIDynArgumentTy arg1_ty)
- (illegalForeignTyErr argument arg1_ty) `thenM_`
- checkForeignArgs (isFFIArgumentTy dflags safety) arg_tys `thenM_`
- checkForeignRes nonIOok (isFFIImportResultTy dflags) res_ty `thenM_`
- return idecl
- | otherwise -- Normal foreign import
- = checkCg (checkCOrAsmOrDotNetOrInterp) `thenM_`
- checkCConv cconv `thenM_`
- checkCTarget target `thenM_`
- getDOpts `thenM` \ dflags ->
- checkForeignArgs (isFFIArgumentTy dflags safety) arg_tys `thenM_`
- checkForeignRes nonIOok (isFFIImportResultTy dflags) res_ty `thenM_`
- return idecl
+ | isDynamicTarget target = do -- Foreign import dynamic
+ checkCg checkCOrAsmOrInterp
+ checkCConv cconv
+ case arg_tys of -- The first arg must be Ptr, FunPtr, or Addr
+ [] -> do
+ check False (illegalForeignTyErr empty sig_ty)
+ return idecl
+ (arg1_ty:arg_tys) -> do
+ dflags <- getDOpts
+ check (isFFIDynArgumentTy arg1_ty)
+ (illegalForeignTyErr argument arg1_ty)
+ checkForeignArgs (isFFIArgumentTy dflags safety) arg_tys
+ checkForeignRes nonIOok (isFFIImportResultTy dflags) res_ty
+ return idecl
+ | otherwise = do -- Normal foreign import
+ checkCg (checkCOrAsmOrDotNetOrInterp)
+ checkCConv cconv
+ checkCTarget target
+ dflags <- getDOpts
+ checkForeignArgs (isFFIArgumentTy dflags safety) arg_tys
+ checkForeignRes nonIOok (isFFIImportResultTy dflags) res_ty
+ return idecl