Search code examples
haskellcompiler-constructionio

What language is Haskell written in?


Also (besides the title question), is there source code available for different impure Haskell functions like IO?

I don't mean the Haskell side of the code, but whatever Haskell implements to do IO.


Solution

  • Haskell implementations are written in a range of languages.

    For example, GHC is:

    • runtime: a mixture of C, assembly and C--
    • compiler: Haskell, Happy (for parsing), and Alex (for lexing)
    • libraries: Haskell and a few C bindings, a little assembly and C--

    The primops are the native instructions of the runtime. They in turn are implemented in the runtime via C, C-- and assembly fragments.

    IO in particular is mediated via the IO manager, and via foreign libraries of IO primitives.