X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=ghc%2Fdocs%2Fadd_to_compiler%2Fcore-syntax.verb;h=a5b8d091cfeab7a1fd774939ec2d0f61c941531e;hb=10521d8418fd3a1cf32882718b5bd28992db36fd;hp=11b80d0ffdc425c38473b1ec67fd37128d19c9b3;hpb=7fa716e248a1f11fa686965f57aebbb83b74fa7b;p=ghc-hetmet.git diff --git a/ghc/docs/add_to_compiler/core-syntax.verb b/ghc/docs/add_to_compiler/core-syntax.verb index 11b80d0..a5b8d09 100644 --- a/ghc/docs/add_to_compiler/core-syntax.verb +++ b/ghc/docs/add_to_compiler/core-syntax.verb @@ -53,44 +53,41 @@ As we saw with the ``abstract syntax'' (in Section~\ref{sec:AbsSyntax}), the Core syntax is also {\em parameterised}, this time with respect to binders and bound-variables (or ``bindees''). The definition of a Core expression -begins:\srcloc{coreSyn/CoreSyn.lhs} -\begin{tightcode} +begins\srcloc{coreSyn/CoreSyn.lhs}: +\begin{mytightcode} data CoreExpr binder bindee = CoVar bindee | CoLit CoreLiteral ... type PlainCoreBinder = Id type PlainCoreBindee = Id -type PlainCoreExpr = CoreExpr PlainCoreBinder PlainCoreBindee -\end{tightcode} +type PlainCoreExpr = CoreExpr PlainCoreBinder PlainCoreBindee\end{mytightcode} Most back-end passes use the parameterisation shown above, namely -@PlainCoreExprs@,\srcloc{coreSyn/PlainCore.lhs} parameterised on @Id@ +@PlainCoreExprs@\srcloc{coreSyn/PlainCore.lhs}, parameterised on @Id@ for both binders and bindees. An example of a pass that uses a different parameterisation is -occurrence analysis,\srcloc{simplCore/OccurAnal.lhs} which gathers +occurrence analysis\srcloc{simplCore/OccurAnal.lhs}, which gathers up info about the {\em occurrences} of bound variables. It uses: -\begin{tightcode} +\begin{mytightcode} data BinderInfo {\dcd\rm-- various things to record about binders...} type TaggedBinder tag = (Id, tag) type TaggedCoreExpr tag = CoreExpr (TaggedBinder tag) Id -substAnalyseExpr :: PlainCoreExpr -> TaggedCoreExpr BinderInfo -\end{tightcode} +substAnalyseExpr :: PlainCoreExpr -> TaggedCoreExpr BinderInfo\end{mytightcode} The pass's expression-mangling function then has the unsurprising type shown above. Core syntax has a ``twin'' datatype that is also sometimes useful: -{\em annotated} Core syntax.\srcloc{coreSyn/AnnCoreSyn.lhs} This is a +{\em annotated} Core syntax\srcloc{coreSyn/AnnCoreSyn.lhs}. This is a datatype identical in form to Core syntax, but such that every ``node'' of a Core expression can be annotated with some information of your choice. As an example, the type of a pass that attaches a @Set@ of free variables to every subexpression in a Core expression -might be:\srcloc{coreSyn/FreeVars.lhs} -\begin{tightcode} +might be\srcloc{coreSyn/FreeVars.lhs}: +\begin{mytightcode} freeVars :: PlainCoreExpr -> AnnCoreExpr Id Id (Set Id) - {\dcd\rm-- parameterised on binders, bindees, and annotation} -\end{tightcode} + {\dcd\rm-- parameterised on binders, bindees, and annotation}\end{mytightcode} \subsection{Unboxing and other Core syntax details} \label{sec:unboxing}