Commit 9da797b4 authored by Sylvain Henry's avatar Sylvain Henry

Update GHC.Hs.* paths

parent d8310369
......@@ -9,15 +9,15 @@ The program is initially parsed into "**`HsSyn`**", a collection of data types t
The `HsSyn` modules live in the [compiler/hsSyn](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/hsSyn) directory. Each module declares a related group of declarations, *and* gives their pretty-printer.
- [compiler/hsSyn/HsSyn.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/hsSyn/HsSyn.hs): the root module. It exports everything you need, and it's generally what you should import.
- [compiler/hsSyn/HsBinds.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/hsSyn/HsBinds.hs): bindings.
- [compiler/hsSyn/HsImpExp.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/hsSyn/HsImpExp.hs): imports and exports.
- [compiler/hsSyn/HsDecls.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/hsSyn/HsDecls.hs): top-level declarations.
- [compiler/hsSyn/HsExpr.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/hsSyn/HsExpr.hs): expressions, match expressions, comprehensions.
- [compiler/hsSyn/HsLit.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/hsSyn/HsLit.hs): literals.
- [compiler/hsSyn/HsPat.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/hsSyn/HsPat.hs): patterns.
- [compiler/hsSyn/HsTypes.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/hsSyn/HsTypes.hs): types.
- [compiler/hsSyn/HsUtils.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/hsSyn/HsUtils.hs): utility functions (no data types).
- [compiler/GHC/Hs.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/GHC/Hs.hs): the root module. It exports everything you need, and it's generally what you should import.
- [compiler/GHC/Hs/Binds.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/GHC/Hs/Binds.hs): bindings.
- [compiler/GHC/Hs/ImpExp.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/GHC/Hs/ImpExp.hs): imports and exports.
- [compiler/GHC/Hs/Decls.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/GHC/Hs/Decls.hs): top-level declarations.
- [compiler/GHC/Hs/Expr.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/GHC/Hs/Expr.hs): expressions, match expressions, comprehensions.
- [compiler/GHC/Hs/Lit.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/GHC/Hs/Lit.hs): literals.
- [compiler/GHC/Hs/Pat.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/GHC/Hs/Pat.hs): patterns.
- [compiler/GHC/Hs/Type.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/GHC/Hs/Type.hs): types.
- [compiler/GHC/Hs/Utils.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/GHC/Hs/Utils.hs): utility functions (no data types).
There is significant mutual recursion between modules, and hence a couple of `hs-boot` files. Look at [ModuleDependencies](module-dependencies) to see the dependencies.
......
......@@ -4,7 +4,7 @@
Probably the most important phase in the frontend is the type checker, which is located at [compiler/typecheck/](https://gitlab.haskell.org/ghc/ghc/blob/master/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.
GHC defines the abstract syntax of Haskell programs in [compiler/hsSyn/HsSyn.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/hsSyn/HsSyn.hs) using a structure that abstracts over the concrete representation of bound occurences of identifiers and patterns. The module [compiler/typecheck/TcHsSyn.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/typecheck/TcHsSyn.hs) defines a number of helper function required by the type checker. Note that the type [compiler/typecheck/TcRnTypes.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/typecheck/TcRnTypes.hs).`TcId` used to represent identifiers in some signatures during type checking is, in fact, nothing but a synonym for a [plain Id](commentary/compiler/entity-types#type-variables-and-term-variables).
GHC defines the abstract syntax of Haskell programs in [compiler/GHC/Hs.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/GHC/Hs.hs) using a structure that abstracts over the concrete representation of bound occurences of identifiers and patterns. The module [compiler/typecheck/TcHsSyn.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/typecheck/TcHsSyn.hs) defines a number of helper function required by the type checker. Note that the type [compiler/typecheck/TcRnTypes.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/typecheck/TcRnTypes.hs).`TcId` used to represent identifiers in some signatures during type checking is, in fact, nothing but a synonym for a [plain Id](commentary/compiler/entity-types#type-variables-and-term-variables).
It is also noteworthy, that the representations of types changes during type checking from `HsType` to `TypeRep.Type`. The latter is a [hybrid type](commentary/compiler/type-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.
......
......@@ -59,7 +59,7 @@ The main source files related to External Core:
Other files that contain some reference to External Core or are otherwise relevant:
- [compiler/coreSyn/PprCore.lhs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/coreSyn/PprCore.lhs): Some code to pretty-print the Core data type.
- [compiler/hsSyn/HsSyn.lhs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/hsSyn/HsSyn.lhs): Top-level syntax tree representations for various things GHC can read, including External Core.
- [compiler/GHC/Hs.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/GHC/Hs.hs): Top-level syntax tree representations for various things GHC can read, including External Core.
- [compiler/main/DriverPhases.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/main/DriverPhases.hs): Includes code to decide how to parse things based on file extension.
- [compiler/main/HscMain.lhs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/main/HscMain.lhs): The main compiler pipeline.
......
......@@ -26,7 +26,7 @@ tool writers to use the GHC API.
>
>
> In the past it was difficult to work with the GHC AST as any generic traversals had to carefully tiptoe around an assortment of panic and undefined expressions. These have now been removed, by uses of `PostRn`, `PostTc`, etc, allowing standard traversal libraries to be used. See module `hsSyn/PlaceHolder`.
> In the past it was difficult to work with the GHC AST as any generic traversals had to carefully tiptoe around an assortment of panic and undefined expressions. These have now been removed, by uses of `PostRn`, `PostTc`, etc, allowing standard traversal libraries to be used. See module `GHC/Hs/PlaceHolder`.
>
>
......
......@@ -44,7 +44,7 @@ This can be achieved by making use of the mechanics listed below. If it turns ou
`hsSyn/HsExtension.hs` would be extended to
`GHC/Hs/Extension.hs` would be extended to
```
......
......@@ -19,7 +19,7 @@ By "subsume" we mean that it should be possible to instantiate TTG [HsSyn](imple
The subsumption of above five ASTs is done by providing instances for the extension type families.
For instance, the AST for GHC's parsing, renaming, and typechecking are defined by providing instances of the extension type families using accordingly the indices `GhcPs`, `GhcRn`, and `GhcTc`.
[Here](https://github.com/ghc/ghc/blob/master/compiler/hsSyn/HsExpr.hs#L737-L835) is the actual code providing such instances for the `HsExpr` datatype of expressions in the TTG [HsSyn](implementing-trees-that-grow/hs-syn).
[Here](https://github.com/ghc/ghc/blob/master/compiler/GHC/Hs/Expr.hs#L737-L835) is the actual code providing such instances for the `HsExpr` datatype of expressions in the TTG [HsSyn](implementing-trees-that-grow/hs-syn).
## General pattern for TTG
......
......@@ -313,8 +313,8 @@ Below is a list of primary source code locations that implement injectivity:
Relevant source code notes are:
- `Note [FamilyResultSig]` in [compiler/hsSyn/HsDecls.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/hsSyn/HsDecls.hs)
- `Note [Injectivity annotation]` in [compiler/hsSyn/HsDecls.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/hsSyn/HsDecls.hs)
- `Note [FamilyResultSig]` in [compiler/GHC/Hs/Decls.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/GHC/Hs/Decls.hs)
- `Note [Injectivity annotation]` in [compiler/GHC/Hs/Decls.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/GHC/Hs/Decls.hs)
- `Note [Injective type families]` in [compiler/types/TyCon.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/types/TyCon.hs)
- `Note [Renaming injectivity annotation]` in [compiler/rename/RnSource.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/rename/RnSource.hs)
- `Note [Verifying injectivity annotation]` in [compiler/types/FamInstEnv.hs](https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/types/FamInstEnv.hs)
......
......@@ -119,7 +119,7 @@ Note that the actual implementation is **not** using the `do`-Notation, it's onl
## Implementation details
Monad comprehensions had to change the `StmtLR` data type in the `hsSyn/HsExpr.lhs` file in order to be able to lookup and store all functions required to desugare monad comprehensions correctly (e.g. `return`, `(>>=)`, `guard` etc). Renaming is done in `rename/RnExpr.lhs` and typechecking in `typecheck/TcMatches.lhs`. The main desugaring is done in `deSugar/DsListComp.lhs`. If you want to start hacking on monad comprehensions I'd look at those files first.
Monad comprehensions had to change the `StmtLR` data type in the `GHC/Hs/Expr.lhs` file in order to be able to lookup and store all functions required to desugare monad comprehensions correctly (e.g. `return`, `(>>=)`, `guard` etc). Renaming is done in `rename/RnExpr.lhs` and typechecking in `typecheck/TcMatches.lhs`. The main desugaring is done in `deSugar/DsListComp.lhs`. If you want to start hacking on monad comprehensions I'd look at those files first.
Some things you might want to be aware of:
......
......@@ -213,7 +213,7 @@ data PmPat :: PatTy -> * where
, pm_con_tvs :: [TyVar]
, pm_con_dicts :: [EvVar]
, pm_con_args :: [PmPat t] } -> PmPat t
-- For PmCon arguments' meaning see @ConPatOut@ in hsSyn/HsPat.hs
-- For PmCon arguments' meaning see @ConPatOut@ in GHC/Hs/Pat.hs
PmVar :: { pm_var_id :: Id } -> PmPat t
PmLit :: { pm_lit_lit :: PmLit } -> PmPat t -- See Note [Literals in PmPat]
PmNLit :: { pm_lit_id :: Id
......@@ -227,7 +227,7 @@ Literal patterns are not essential for the algorithm to work, but it is
more efficient to treat them more like constructors by matching against them eagerly than
generating equality constraints to feed the term oracle with (as we do in the paper). Additionally,
we use negative patterns (constructor `PmNLit`), for efficiency also. `PmCon` contains several
fields, effectively copying constructor `ConPatOut` of type `Pat` (defined in `hsSyn/HsPat.hs`).
fields, effectively copying constructor `ConPatOut` of type `Pat` (defined in `GHC/Hs/Pat.hs`).
Since the algorithm runs post-typechecking, we have a lot of information available for the
treatment of GADTs.
......@@ -288,7 +288,7 @@ empty or not afterwards, we check on the fly and use just a boolean for each.
The algorithm process as follows:
- Translate a clause (which contains `Pat`s, defined in `hsSyn/HsPat.hs`) to `PatVec`s (`translatePat`
- Translate a clause (which contains `Pat`s, defined in `GHC/Hs/Pat.hs`) to `PatVec`s (`translatePat`
is the workhorse):
```
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment