Changes between Version 2 and Version 3 of Commentary/Compiler/TypeChecker


Ignore:
Timestamp:
Jun 25, 2013 8:39:07 AM (2 years ago)
Author:
adamgundry
Comment:

update links to new commentary

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Compiler/TypeChecker

    v2 v3  
    33Probably the most important phase in the frontend is the type checker, which is located at [[GhcFile(compiler/typecheck/)]]. GHC type checks programs in their original Haskell form before the desugarer converts them into Core code. This complicates the type checker as it has to handle the much more verbose Haskell AST, but it improves error messages, as those message are based on the same structure that the user sees.
    44
    5 GHC defines the abstract syntax of Haskell programs in [[GhcModule(compiler/hsSyn/HsSyn.lhs)]] using a structure that abstracts over the concrete representation of bound occurences of identifiers and patterns. The module [[GhcModule(compiler/typecheck/TcHsSyn.lhs)]] defines a number of helper function required by the type checker. Note that the type [[GhcModule(compiler/typecheck/TcRnTypes.lhs)]].`TcId` used to represent identifiers in some signatures during type checking is, in fact, nothing but a synonym for a [http://darcs.haskell.org/ghc/docs/comm/the-beast/vars.html plain Id] (TODO: Point at new commentary equivalent).
     5GHC defines the abstract syntax of Haskell programs in [[GhcModule(compiler/hsSyn/HsSyn.lhs)]] using a structure that abstracts over the concrete representation of bound occurences of identifiers and patterns. The module [[GhcModule(compiler/typecheck/TcHsSyn.lhs)]] defines a number of helper function required by the type checker. Note that the type [[GhcModule(compiler/typecheck/TcRnTypes.lhs)]].`TcId` used to represent identifiers in some signatures during type checking is, in fact, nothing but a synonym for a [wiki:Commentary/Compiler/EntityTypes#Typevariablesandtermvariables plain Id].
    66
    7 It is also noteworthy, that the representations of types changes during type checking from `HsType` to `TypeRep.Type`. The latter is a [http://darcs.haskell.org/ghc/docs/comm/the-beast/types.html hybrid type] (TODO: Point at new commentary equivalent) representation that is used to type Core, but still contains sufficient information to recover source types. In particular, the type checker maintains and compares types in their `Type` form.
     7It is also noteworthy, that the representations of types changes during type checking from `HsType` to `TypeRep.Type`. The latter is a [wiki:Commentary/Compiler/TypeType hybrid type] representation that is used to type Core, but still contains sufficient information to recover source types. In particular, the type checker maintains and compares types in their `Type` form.
    88
    99== The Overall Flow of Things ==
     
    1111=== Entry Points Into the Type Checker ===
    1212
    13 The interface of the type checker (and [http://darcs.haskell.org/ghc/docs/comm/the-beast/renamer.html renamer] (TODO: Point at new commentary equivalent)) to the rest of the compiler is provided by [[GhcModule(compiler/typecheck/TcRnDriver.lhs)]]. Entire modules are processed by calling `tcRnModule` and GHCi uses `tcRnStmt`, `tcRnExpr`, and `tcRnType` to typecheck statements and expressions, and to kind check types, respectively. Moreover, `tcRnExtCore` is provided to typecheck external Core code. Moreover, `tcTopSrcDecls` is used by Template Haskell - more specifically by `TcSplice.tc_bracket` - to type check the contents of declaration brackets.
     13The interface of the type checker (and [wiki:Commentary/Compiler/Renamer renamer]) to the rest of the compiler is provided by [[GhcModule(compiler/typecheck/TcRnDriver.lhs)]]. Entire modules are processed by calling `tcRnModule` and GHCi uses `tcRnStmt`, `tcRnExpr`, and `tcRnType` to typecheck statements and expressions, and to kind check types, respectively. Moreover, `tcRnExtCore` is provided to typecheck external Core code. Moreover, `tcTopSrcDecls` is used by Template Haskell - more specifically by `TcSplice.tc_bracket` - to type check the contents of declaration brackets.
    1414
    1515=== Renaming and Type Checking a Module ===
     
    6262Expressions are type checked by [[GhcModule(compiler/typecheck/TcExpr)]].
    6363
    64 Usage occurences of identifiers are processed by the function tcId whose main purpose is to [http://darcs.haskell.org/ghc/docs/comm/the-beast/typecheck.html#inst instantiate overloaded identifiers] (TODO: Point at new commentary equivalent). It essentially calls `TcInst.instOverloadedFun` once for each universally quantified set of type constraints. It should be noted that overloaded identifiers are replaced by new names that are first defined in the LIE (Local Instance Environment?) and later promoted into top-level bindings.
     64Usage occurences of identifiers are processed by the function tcId whose main purpose is to [#HandlingofDictionariesandMethodInstances instantiate overloaded identifiers]. It essentially calls `TcInst.instOverloadedFun` once for each universally quantified set of type constraints. It should be noted that overloaded identifiers are replaced by new names that are first defined in the LIE (Local Instance Environment?) and later promoted into top-level bindings.
    6565
    6666=== Handling of Dictionaries and Method Instances ===