diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2015-04-30 00:19:45 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2015-04-30 00:19:45 +0100 |
commit | 54cefbd753b516fe8645c1470750ad7f65352844 (patch) | |
tree | 5224dbfef23e8f27ba1b267aa191eaeb436f1660 /docs/backpack/algorithm.tex | |
parent | d4a926ba52fbbbdeaadfff7c86e7175c8cc1b97c (diff) | |
download | haskell-54cefbd753b516fe8645c1470750ad7f65352844.tar.gz |
Typeset Backpack syntax in a figure
Diffstat (limited to 'docs/backpack/algorithm.tex')
-rw-r--r-- | docs/backpack/algorithm.tex | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/docs/backpack/algorithm.tex b/docs/backpack/algorithm.tex index 956480b0e4..68ea2285d0 100644 --- a/docs/backpack/algorithm.tex +++ b/docs/backpack/algorithm.tex @@ -48,19 +48,31 @@ which allow us to hide requirements from import. \section{Front-end syntax} -For completeness, here is the package language we will be shaping and typechecking: - -\begin{verbatim} - package ::= "package" pkgname [pkgexports] "where" pkgbody - pkgbody ::= "{" pkgdecl_0 ";" ... ";" pkgdecl_n "}" - pkgdecl ::= "module" modid [exports] where body - | "signature" modid [exports] where body - | "include" pkgname [inclspec] - inclspec ::= "(" renaming_0 "," ... "," renaming_n [","] ")" - [ "requires" "(" renaming_0 "," ... "," renaming_n [","] ")" ] - pkgexports ::= inclspec - renaming ::= modid "as" modid -\end{verbatim} +\begin{figure} +$$ +\begin{array}{rcll} +p,q,r && \mbox{Package names} \\ +m,n && \mbox{Module names} \\[1em] +\multicolumn{3}{l}{\mbox{\bf Packages}} \\ + pkg & ::= & \verb|package|\; p\; [provreq]\; \verb|where {| d_1 \verb|;| \ldots \verb|;| d_n \verb|}| \\[1em] +\multicolumn{3}{l}{\mbox{\bf Declarations}} \\ + d & ::= & \verb|module|\; m \; [exports]\; \verb|where|\; body \\ + & | & \verb|signature|\; m \; [exports]\; \verb|where|\; body \\ + & | & \verb|include|\; p \; [provreq] \\[1em] +\multicolumn{3}{l}{\mbox{\bf Provides/requires specification}} \\ +provreq & ::= & \verb|(| \, rns \, \verb|)| \; + [ \verb|requires(|\, rns \, \verb|)| ] \\ +rns & ::= & rn_0 \verb|,| \, \ldots \verb|,| \, rn_n [\verb|,|] & \mbox{Renamings} \\ +rn & ::= & m\, \verb|as| \, n & \mbox{Renaming} \\[1em] +\multicolumn{3}{l}{\mbox{\bf Haskell code}} \\ +exports & & \mbox{A Haskell module export list} \\ +body & & \mbox{A Haskell module body} \\ +\end{array} +$$ +\caption{Syntax of Backpack} \label{fig:syntax} +\end{figure} + +The syntax of Backpack is given in Figure~\ref{fig:syntax}. See the ``Backpack manual'' for more explanation about the syntax. It is slightly simplified here by removing any constructs which are easily implemented as syntactic sugar (e.g., a \verb|modid| renaming is simply \verb|modid as modid|.) |