Runtime Haskell interpreter (GHC API wrapper)


Version on this page:
LTS Haskell 22.29:
Stackage Nightly 2024-07-15:
Latest on Hackage:

See all snapshots hint appears in

BSD-3-Clause licensed by The Hint Authors
Maintained by [email protected]
This version can be pinned in stack with:hint-,2981

Module documentation for


Build Status Hackage

This library defines an Interpreter monad. It allows to load Haskell modules, browse them, type-check and evaluate strings with Haskell expressions and even coerce them into values. The library is thread-safe and type-safe (even the coercion of expressions to values).

It is, essentially, a huge subset of the GHC API wrapped in a simpler API.

Compatibility is kept with the three last major GHC releases. For example, if the current version is GHC 8.6, Hint will work on 8.6, 8.4 and 8.2.


Check example.hs to see a simple but comprehensive example (it must be run from the examples directory).


  • Support GHC 8.8
  • Drop support for GHC 8.2

  • Make tests pass with stack 2.1.1


  • Support GHC 8.6
  • Drop support for GHC 8.0


  • Support GHC 8.4
  • Drop support for GHC 7.8 and 7.10
  • Add runStmt to execute statements in the IO monad and bind new names
  • Internal changes of temporary files for phantom modules
    • The files are now called M<nnn>.hs instead of <nnn>
    • Improved cleanup of phantom module source files
    • ghc 8.4 only: phantom modules are put into a temporary directory
  • Add typeChecksWithDetails to obtain type-checking errors
  • Stop GHC from overwriting the Ctrl-C signal handler
  • Add SetImportsF to allow finer imports control


  • Support for GHC 8.2
  • Support use in a dynamically-linked executable
  • Add normalizeType, like ghci’s :kind!
  • Drop support for GHC 7.6


  • Support for GHC 8.0
  • Add displayException to InterpreterError


  • Add runInterpreter variant that takes a GHC libdir at runtime
  • Add missing negated extensions to the Extension type
  • Do not throw GHC warnings as errors


  • Expose unsafeInterpret in Language.Haskell.Interpreter.Unsafe


  • Drop support for GHC 7.4
  • Remove deprecated functions and modules:
    • glasgowExtensions
    • setUseLanguageExtensions
    • setInstalledModsAreInScopeQualified
    • Language.Haskell.Interpreter.GHC
    • Language.Haskell.Interpreter.GHC.Unsafe
  • Drop dependencies on ghc-mtl and extensible-exceptions


  • New maintainer and source code repo

  • It builds against 7.4.2 (not 7.4.1), so update the constraints.

  • Builds with GHC 7.10
  • Builds again with GHC 7.4
  • Drops dependency on utf8-string

  • Better error reporting (thanks to Corentin Dupont)

  • Based on exceptions-0.6

  • Based on exceptions-0.4

  • Compiles with GHC 7.8
  • Fixed an issue where P was available as a qualified version of Prelude (thanks to Samuel Gélineau)
  • Uses exceptions package instead of MonadCatchIO-mtl (API breakage expected)
  • No longer depends on haskell-src
  • Changelog should now appear in Hackage
  • Integrated unit tests with cabal

  • Fixed a race condition that would happen, for instance, when two process where run one next to the other, making them, on some platforms, to get the same random number seed (thanks to Mario Pastorelli and Samuel Gélineau)
  • Small fix in documentation (thanks to Daniil Frumin)

  • Works again on GHC 7.2.x (thanks to Björn Peemöller)

  • Works on GHC 7.4.6
  • Cleans up files for phantom modules that were left behind (thanks to Beltram Felgenhauer)

  • Works on GHC 7.4.1

  • Works on GHC 7.2.1

  • Supports GHC 7

  • Instance declaration for Applicative (InterpreterT m) works with mtl-2 (requires Applicative m, this shouldn’t break anything…)

  • Add unsafeRunInterpreterWithArgs
  • Check that only one instance of the interpreter is run at any time

  • Can be built against MonadCatchIO-mtl-0.3.x.x

  • Fixed a bug that would make expressions using heavy use of the layout rule to fail to be interpreted (see parens)

  • hint.cabal includes version bounds for package ghc-mtl. This is to avoid the accidental selection of the completely unrelated ghc-mtl internal to GHC and, apparently, installed in the hackage server

  • Exports functions parens and isInterpretedModule
  • Experimental support for module annotations
  • Uses extensible-exceptions in order to provide a uniform interface across different ghc versions
  • Provides an Applicative instance for IntepreterT
  • Adds an option to configurate the searchPath

  • No longer uses Language.Haskell.Extension due to configuration problems with Cabal. Instead, it uses its own Language.Haskell.Interpreter.Extension module.

  • Updated API:
    • InterpreterT monad transformer (Interpreter = InterpreterT IO)
    • No more Sessions, use runInterpreter only once
    • New options handling functions
      • but observe that there is no setOptimizations equivalent; since GHC does no optimization on interpreted code, this was actually doing nothing
  • Works with GHC 6.10 and 6.8 (untested with 6.6)


  • setImportsQ added (modules can be imported both qualified and unqualified)

  • BUGFIX: No longer fails on expressions ending in a – comment


  • setInstalledModsAreInScopeQualified added
  • Now depends on ghc-paths (no longer needs a custom cabal script)


  • setOptimizations added
  • Module Language.Haskell.Interpreter.GHC.Unsafe added (contains unsafeSetGhcOption)
  • Unit tests now based on HUnit


  • BUGFIX: Module reloading was broken under 6.8
  • GHC.GhcExceptions are catched and turned into InterpreterErrors

  • Adds the requirement cabal-version < 1.3


  • Works also with GHC 6.8 and 6.6
  • Added the getModuleExports function
  • withSession function throws a dynamic exception instead of returning Either Error a
  • Requires Cabal 1.2.x