ghc-9.6.1: The GHC API
Safe HaskellSafe-Inferred
LanguageHaskell2010

GHC.Tc.Gen.Foreign

Description

Typechecking foreign declarations

A foreign declaration is used to either give an externally implemented function a Haskell type (and calling interface) or give a Haskell function an external calling interface. Either way, the range of argument and result types these functions can accommodate is restricted to what the outside world understands (read C), and this module checks to see if a foreign declaration has got a legal type.

Synopsis

Documentation

isForeignImport :: forall name. UnXRec name => LForeignDecl name -> Bool Source #

isForeignExport :: forall name. UnXRec name => LForeignDecl name -> Bool Source #

checkForeignRes :: Bool -> Bool -> (Type -> Validity' IllegalForeignTypeReason) -> Type -> TcM () Source #

Check that the type has the form (IO t) or (t) , and that t satisfies the given predicate. When calling this function, any newtype wrappers (should) have been already dealt with by normaliseFfiType.

We also check that the Safe Haskell condition of FFI imports having results in the IO monad holds.