GHC extensions

Ryan Scott ryan.gl.scott at gmail.com
Thu Apr 19 12:45:03 UTC 2018


Hi Peter,

> What does exactly happen if an extension is needed for a certain language element, but it is not present?

Generally, these manifest as runtime checks of the form (xopt
LangExt.TheLanguageExtensionName dflags). For an example, see [1],
where GHC checks if the TypeFamilyDependencies extension is enabled,
and if not, subsequently throws an error.

> Does the type checker still continue its business after encountering such an error; or does it stop, and dump its the error messages?

It depends. Sometimes, GHC uses the addErrTc function to add an error
but not cause an outright failure, continuing until there is a fatal
error. The failWithTc function, on the other hand, adds an error and
causes GHC to exit, reporting all errors it's collected up to that
point. (The example in [1] does this.)

Ryan S.
-----
[1] http://git.haskell.org/ghc.git/blob/5d76846405240c051b00cddcda9d8d02c880968e:/compiler/typecheck/TcTyClsDecls.hs#l1097


More information about the ghc-devs mailing list