|Version 7 (modified by 10 years ago) (diff),|
ExternalCore data type is used by GHC to communicate code represented in the Core data type with the outside world. It comes with an external syntax, a parser, a pretty printer, and code to convert between Core and External Core. Unfortunately, External Core has not been widely used, and the code has bit-rotted. The recent changes in Core to use System FC have exacerbated the problem. This page documents the process of getting External Core and Core back in sync.
Once the process is finished, this page will just describe the design.
The main source files related to External Core:
- compiler/coreSyn/ExternalCore.lhs: The definition of the External Core data type.
- compiler/coreSyn/MkExternalCore.lhs: Some code to convert Core to External Core.
- compiler/coreSyn/PprExternalCore.lhs: Some code to pretty-print External Core.
- compiler/parser/LexCore.hs: The lexer for External Core.
- compiler/parser/ParserCore.y: The parser for External Core.
- compiler/parser/ParserCoreUtils.hs: Some additional utility functions used by
- utils/ext-core/: Old code intended as an executable specification of External Core.
Other files that contain some reference to External Core or are otherwise relevant:
- compiler/coreSyn/PprCore.lhs: Some code to pretty-print the Core data type.
- compiler/hsSyn/HsSyn.lhs: Top-level syntax tree representations for various things GHC can read, including External Core.
- compiler/main/DriverPhases.hs: Includes code to decide how to parse things based on file extension.
- compiler/main/HscMain.lhs: The main compiler pipeline.
- http://research.microsoft.com/~simonpj/papers/ext-f: Description of the System FC language which GHC now uses internally.
- docs/ext-core/: The current documentation for External Core, which should eventually become a chapter in the GHC User's Guide.
- http://www.haskell.org/ghc/docs/latest/html/users_guide/ext-core.html: What the User's Guide currently has to say about External Core.
- External Core originally parsed into a list of
TyClDecland a list of
IfaceBinding. It now seems as though it might be better to replace the
LHsDecl. This would require us to:
- Add a new data constructor for
data HsBind id = ... | CoreBind id (ExtCore id)
- Extend the renamer to rename
- Extend the type checker to typecheck
ExtCore Nameto generate
- Extend the desugarer to desugar
- Add a new data constructor for
- We probably want to represent all data types as GADTs, even if they can be represented in Haskell 98 form, so that we only have one representation.
- Define an external text representation for External Core (which will probably be simply a minor modification of the old format) (mostly done?)
- Update the External Core data type to be compatible with the current Core data type. (mostly done)
PprExternalCore.lhsto print stuff that
ParserCorecan understand. (mostly done)
MkExternalCore.lhsto support both the current Core and the new External Core. (mostly done)
- Update the parser to recognize the new external syntax, generating an empty module at first. (partly done)
- Update the parser to generate LHsBind rather than IfaceBinding
- Convert the current External Core documentation (in LaTeX) into a chapter (in XML) in the User's Guide.
- The LaTeX documentation describes PrimOps in some detail. This information is now in the library documentation, so it is probably not needed in the External Core chapter.