wiki:NewPragmas

Version 7 (modified by malcolm.wallace@…, 7 years ago) (diff)

--

Possible New Pragmas

While implementations are never under any obligation to follow pragmas, it is good to have standardized meanings for common pragmas so that when implementations do use them they can do so in a way that is compatable with others.

Haskell'98 specifies:

  • INLINE
  • NOINLINE
  • SPECIALIZE

Here are some suggestions for newer pragmas to standardise:

  • LINE - hopefully with optional character position as well as line number so that intraline error reporting can work properly.
  • SRCLOC_ANNOTATE - generalized Assertions? which can be used to annotate any function with its use site.
  • DEPRECATED - mark modules, classes, types and functions that have been deprecated
  • LANGUAGE - a pragma for specifying language options with a common compiler-independent namespace.
  • ENCODING - see UnicodeInHaskellSource
  • INCLUDE - see ForeignFunctionInterface
  • REGION - hints to editors and code analysis tools to allow code folding
  • COSTCENTER - places to attach profiling information
  • UNUSED - declare that certain values may be unused so the compiler won't warn about them
  • UNPACK - control the unboxing of strict values
  • SUPERSPECIALIZE - like specialize, but implements run-time check to determine if a specialization can be used
  • RULES - rewriting rules
  • OPTIONS_hc - way to pass options to a certain compiler
  • NOPRELUDE - do not automatically include any modules
  • PREPROCESS - pragma to specify arbitrary program to preprocess file

GHC supports INLINE, NOINLINE, SPECIALIZE, LINE, DEPRECATED, LANGUAGE, INCLUDE, RULES, OPTIONS_GHC.

nhc98 supports LINE, OPTIONS_NHC.

Cabal uses LANGUAGE and INCLUDE.

References