8f2c0d982793eb87633231d8e545577fb514d287
[haskell-report.git] / report / haskell.verb
1 % Formatting for double-sided
2 \documentclass[twoside,10pt]{book}
3
4 \usepackage{times}
5 \usepackage{makeidx}
6 \usepackage{graphicx}
7 \usepackage{url}
8 \usepackage[dvipsnames,usenames]{color}
9 \usepackage[pdftex,bookmarks=true]{hyperref}
10
11 \evensidemargin=0in
12 \oddsidemargin=.5in
13 \sloppy
14
15 %---------------------------------------------------------------------
16 % Joe Fasel said this "twosidefix" is necessary if you really
17 % have a two-sided printer:
18 %       (note: double @@'s for verbatim-ery)
19 \makeatletter
20 \def\titlepage{\@@restonecolfalse\if@@twocolumn\@@restonecoltrue\onecolumn
21  \else \newpage \fi \thispagestyle{empty}\c@@page\m@@ne}
22 \def\endtitlepage{\if@@twoside\newpage\thispagestyle{empty}\hbox{}
23                         \else \c@@page\@@z \fi
24    \if@@restonecol\twocolumn \else \newpage \fi}
25 \makeatother
26 %---------------------------------------------------------------------
27
28 % the major sections have \cleardoublepages between them
29 % if you want those between EVERY section, change the
30 % following defn:
31 \newcommand{\startnewsection}{\clearpage}
32 %
33 % if doing one-sided printing, change this defn to
34 % be just "\clearpage":
35 \newcommand{\startnewstuff}{\cleardoublepage}
36 % keep some pages from looking unbelievably appalling
37 \raggedbottom
38
39 % Fix those ugly floating figures.
40 \renewcommand{\floatpagefraction}{0.1}
41 \renewcommand{\textfraction}{0.1}
42 \renewcommand{\topfraction}{1.0}
43 \renewcommand{\bottomfraction}{1.0}
44
45 % table of contents: show only down to subsections
46 \setcounter{tocdepth}{3}
47 \setcounter{secnumdepth}{3}
48
49 % general formatting
50 \textheight=8.5in
51 \textwidth=6.0in
52 \topmargin=0in
53 \pagestyle{headings}
54
55 \makeindex
56 % an extra thing for makeindex
57 \newcommand{\hseealso}[2]{{\em see also\/} #1}
58
59 % NEWCOMMANDS
60
61 % general
62 \newcommand{\folks}[1]{\begin{quote}\sf#1\end{quote}}
63 \newcommand{\sectionpart}[1]{\vspace{2 ex}\noindent{\bf #1}}
64 \newcommand{\bq}{\begin{quote}}
65 \newcommand{\eq}{\end{quote}}
66 \newcommand{\bt}{\begin{tabular}}
67 \newcommand{\et}{\end{tabular}}
68 \newcommand{\bto}{\begin{tabular}}
69 \newcommand{\eto}{\end{tabular}}
70 \newcommand{\bi}{\begin{itemize}}
71 \newcommand{\ei}{\end{itemize}}
72 \newcommand{\struthack}[1]{\rule{0pt}{#1}}
73 \newcommand{\inputHS}[1]{{\small \input{#1}}}
74 % Use smaller font 
75
76 \newcommand{\ToDo}[1]{}
77 %\newcommand{\ToDo}[1]{({\bf $\spadesuit$ ToDo:} {\em #1})}
78
79 \newcommand{\WeSay}[1]{}
80 %\newcommand{\WeSay}[1]{({\bf $\clubsuit$ YaleSays:} {\em #1})}
81
82 \newcommand{\anchor}[2]{#2}
83
84 % indexing
85 \newcommand{\indextt}[1]{\index{#1@@{\tt #1}}}
86 \newcommand{\indexsyn}[1]{\index{#1@@{\it #1}}}
87 \newcommand{\indexmodule}[1]{\index{#1@@{\tt #1} (module)}}
88 \newcommand{\indextycon}[1]{\index{#1@@{\tt #1} (datatype)}}
89 \newcommand{\indexsynonym}[1]{\index{#1@@{\tt #1} (type synonym)}}
90 \newcommand{\indexclass}[1]{\index{#1@@{\tt #1} (class)}}
91 \newcommand{\indexdi}[1]{\index{#1@@{\tt #1} (class)!derived instance}}
92 \newcommand{\indexnote}[1]{#1n}
93 \newcommand{\emptystr}{[\,]}
94 \newcommand{\ignorehtml}[1]{#1}
95
96 \makeatletter
97 \def\theindex{\@@restonecoltrue\if@@twocolumn\@@restonecolfalse\fi
98 \columnseprule \z@@
99 \columnsep 35pt\twocolumn[\section*{Index}
100         \addcontentsline{toc}{section}{Index}
101         \input{index-intro}\vskip 20pt]
102  \@@mkboth{INDEX}{INDEX}\thispagestyle{plain}\parindent\z@@
103  \parskip\z@@ plus .3pt\relax\let\item\@@idxitem
104 }
105 \makeatother
106
107 % outlined figures
108 \newcommand{\ecaption}[1]{\vspace{-1 ex}\caption{#1}\vspace{1 ex}}
109 \newsavebox{\fmbox}
110
111 \newenvironment{outlineenv}
112   {\begin{lrbox}{\fmbox}%
113    \begin{minipage}{415pt}%
114    \vspace{1 ex}}
115   {\end{minipage}%
116    \vspace{1 ex}%
117     \end{lrbox}%
118     \begin{center}%
119     \fbox{\usebox{\fmbox}}%
120      \end{center}}
121
122 \newcommand{\outline}[1]{%
123 \begin{lrbox}{\fmbox}%
124 \begin{minipage}{415pt}%
125 \vspace{1 ex}
126 #1  
127 \end{minipage}%
128 \vspace{1 ex}%
129 \end{lrbox}%
130 \begin{center}%
131 \fbox{\usebox{\fmbox}}%
132 \end{center}
133 }
134
135 \newcommand{\outlinec}{\outline}
136
137 % we used to have a complicated arrangement with a tabular environment
138 % to indent the code blocks a little, but it ran into difficulties
139 % when I started using the verbatim environment for code, also it
140 % looked bad in the HTML output.  The simple way works best: just use
141 % the quote environment. --SDM 4/2010
142 \newcommand{\bprog}{\vspace{-1ex}\begin{quote}}
143 \newcommand{\eprog}{\end{quote}\vspace{-1ex}}
144 \newcommand{\bprogB}{}
145 \newcommand{\eprogB}{}
146 \newcommand{\eprogNoSkip}{\eprog}
147
148 % setting of code from ffi.tex
149 %
150 \makeatletter
151 \newenvironment{codedesc}{%             % description of code pieces
152   \list{}{\labelwidth\z@@
153     \let\makelabel\codedesclabel}
154   }{%
155   \endlist
156   }
157 \newcommand*{\codedesclabel}[1]{%
158   \hspace{-\leftmargin}
159   \parbox[b]{\labelwidth}{\makebox[0pt][l]{\texttt{#1}}\\}\hfil\relax
160   }
161 \makeatother
162 \newcommand{\combineitems}{\vspace*{-\itemsep}\vspace*{-\parsep}\vspace*{-1em}}
163
164 % general from ffi.tex
165 %
166 \newcommand{\clearemptydoublepage}{%
167   \newpage{\pagestyle{empty}\cleardoublepage}}
168
169 %special characters
170 \newcommand{\bkq}{\mbox{\tt \char'022}} % (syntax) backquote char
171 \newcommand{\bkqB}{\bkq\hspace{-.2em}} % (syntax) backquote char (Before)
172 \newcommand{\bkqA}{\hspace{-.2em}\bkq}% (syntax) backquote char (After)
173 %\newcommand{\fwq}{\mbox{\it \char'023}} % (syntax) (forward) quote char
174 % math formatting
175 \newcommand{\ba}{\begin{array}}
176 \newcommand{\ea}{\end{array}}
177 \newcommand{\mc}{\multicolumn}
178 \newcommand{\pile}[1]{\ba[t]{@@{}l@@{}} #1 \ea}
179 \newcommand{\eqn}[1]{\ba[t]{@@{}lcl@@{}} #1 \ea}
180 \newcommand{\equate}[1]{\[\eqn{#1}\]}
181 \newcommand{\la}{\leftarrow}
182 \newcommand{\ra}{\rightarrow}
183 \newcommand{\sq}[1]{[\,#1\,]}
184 \newcommand{\ab}[1]{\langle#1\rangle}
185 \newcommand{\ablarge}[1]{\langle \pile{#1\,\rangle}}
186 \newcommand{\lb}{[\![}
187 \newcommand{\rb}{]\!]}
188 \newcommand{\db}[1]{\lb#1\rb}
189 \newcommand{\ti}[1]{\mbox{{\it #1}}}
190 \newcommand{\tr}[1]{\mbox{{\rm #1}}}
191 \newcommand{\tb}[1]{\mbox{{\bf #1}}}
192 \newcommand{\x}{\times}
193 \newcommand{\lam}{\lambda}
194 \newcommand{\kr}{\kappa_{\rho}}
195 \newcommand{\syneq}{\rightarrow}
196 % denotational semantics
197 \newcommand{\denote}[3]{\[\ba{c} {\cal #1} : #2 \\[1 ex] #3 \ea\]}
198 \newcommand{\den}[2]{{\cal #1}\db{#2}\,}
199
200 \newcommand{\A}{\den{A}}
201 \newcommand{\B}{\den{B}}
202 \newcommand{\D}{\den{D}}
203 \newcommand{\E}{\den{E}}
204 \newcommand{\F}{\den{F}}
205 \newcommand{\G}{\den{G}}
206 \newcommand{\I}{\den{I}}
207 %%% \renewcommand{\L}{\den{L}}
208 \newcommand{\LE}{\den{L_E}}
209 \newcommand{\LH}{\den{L_H}}
210 \newcommand{\M}{\den{M}}
211 %%% \renewcommand{\O}{\den{O}}
212 \renewcommand{\P}{\den{P}}
213 \newcommand{\Pbot}{\den{P_{\bot}}}
214 \newcommand{\Q}{\den{Q}}
215 \newcommand{\R}{\den{R}}
216 \renewcommand{\S}{\den{S}}
217 \newcommand{\V}{\den{V}}
218 \newcommand{\W}{\den{W}}
219 \newcommand{\T}[2]{\den{T}{#1}\,\db{#2}}
220 % meta language
221 \newcommand{\PP}{\den{P'}}
222 \newcommand{\PS}{\den{P_S}}
223 \newcommand{\otherwise}{\quad\tr{otherwise}}
224 \newcommand{\case}[2]{\pile{
225  \tr{case}\ (#1)\ \tr{of} \\
226  \ba{@@{\quad}l@@{\ \ra\ }l@@{}} #2 \ea}}
227 \newcommand{\where}[2]{#1 \quad\tr{where}\quad #2}
228 \newcommand{\wherelarge}[2]{\pile{#1 \\ \tr{where} \\ \eqn{#2}}}
229 \newcommand{\cond}[3]{#1 \ra #2,\ #3}
230 \newcommand{\condlarge}[1]{\ba[t]{@@{}l@@{\ \ra\ }l@@{}} #1 \ea}
231 \newcommand{\range}[2]{{}_{#1}^{#2}\,}
232 % semantic operators
233 \newcommand{\concat}{\frown}
234 \newcommand{\seq}[1]{\ti{List}\ #1}
235 \newcommand{\opt}[1]{\widetilde{#1}}
236 \newcommand{\ov}{\opt{v}}
237 \newcommand{\fail}{\ti{none}}
238 \newcommand{\nonfail}{\ti{proper}}
239 \newcommand{\sym}{\bigtriangledown}
240 \newcommand{\pri}{\mathbin{\vec{\sym}}}
241 \newcommand{\mrg}{\mathbin{\dot{\sym}}}
242 \newcommand{\Sym}{\mathbin{\nabla}}
243 \newcommand{\Pri}{\mathbin{\vec{\Sym}}}
244 \newcommand{\Mrg}{\mathbin{\dot{\Sym}}}
245 \newcommand{\optSym}{\mathbin{\opt{\Sym}}}
246 \newcommand{\optodot}{\mathbin{\opt{\odot}}}
247 \newcommand{\proj}{\mid}
248 \newcommand{\restrict}{\setminus}
249 \newcommand{\sel}[4]{\ti{sel}_{#3#2}\ #4}
250 \newcommand{\bindnone}{\ti{bindnone}}
251 \newcommand{\bindvar}[2]{\ti{bindvar}\ \db{#1}\ #2}
252 \newcommand{\bindcon}[2]{\ti{bindcon}\ \db{#1}\ #2}
253 \newcommand{\bindconlarge}[4]{
254  #4\ \bindcon{#1}{\ablarge{ #2, \\ #3}}}
255 \newcommand{\bindmod}[2]{\ti{bindmod}\ \db{#1}\ #2}
256
257 \newcommand{\lookupval}[2]{\ti{lookupval}\ #1\ \db{#2}} %%% NEW
258 \newcommand{\lookupcon}[1]{\ti{lookupcon}\ \db{#1}} %%% NEW
259 \newcommand{\lookupdecon}[2]{\ti{lookupdecon}\ #1\ \db{#2}} %%% NEW
260
261 % used in static.verb
262 \newcommand{\TT}{\den{T_T}}
263 \newcommand{\TA}{\den{T_A}}
264 \newcommand{\TB}{\den{T_B}}
265 \newcommand{\TD}{\den{T_D}}
266 \newcommand{\TDA}{\den{T_{D_A}}}
267 \newcommand{\TDB}{\den{T_{D_B}}}
268 \newcommand{\TDP}{\den{T_{P_D}}}
269 \newcommand{\TE}{\den{T_E}}
270 \newcommand{\TLE}{\den{T_{L_E}}}
271 \newcommand{\TLH}{\den{T_{L_H}}}
272 %%% \newcommand{\TG}{\den{T_G}}
273 \newcommand{\TQ}{\den{T_Q}}
274 %%% \newcommand{\TR}{\den{T_R}}
275 \newcommand{\TF}{\den{T_F}}
276 \newcommand{\TFA}{\den{T_F'}}
277 \newcommand{\TP}{\den{T_P}}
278 \newcommand{\TPP}{\den{T_P'}}
279 \newcommand{\TPS}{\den{T_{PS}}}
280 \newcommand{\MGU}{\ti{MGU}}
281 \newcommand{\TI}{\den{T_I}}
282 \newcommand{\TL}{\den{T_L}}
283 \newcommand{\TM}{\den{T_M}}
284 %%% \newcommand{\TO}{\den{T_O}}
285 \newcommand{\TS}{\den{T_S}}
286 \newcommand{\TV}{\den{T_V}}
287 \newcommand{\tenvm}{\ddot{\nabla}}
288 \renewcommand{\tb}[1]{\triangleright#1\triangleleft}
289 \newcommand{\unbindvar}[2]{\ti{unbindvar}\ \db{#1}\ #2}
290 \newcommand{\unbindcon}[2]{\ti{unbindcon}\ \db{#1}\ #2}
291
292 % Haskell syntax macros: math mode assumed
293 \newcommand{\system}[2]{#1@;;@\cdots@;;@#2}
294 \newcommand{\module}[4]{module\ #1@:@\ #2\ #3\ #4}
295 \newcommand{\exposing}[1]{@expose@\ #1}
296 \newcommand{\hiding}[1]{@hide@\ #1}
297 \newcommand{\importnone}{\;}
298 \newcommand{\importcomb}[2]{#1\ @;;@\ #2}
299 \newcommand{\import}[2]{@import@\ #1\ #2}
300 \newcommand{\rename}[2]{#1\ @=@\ #2}
301 \newcommand{\declcomb}[2]{#1\ @;;@\ #2}
302
303 \newcommand{\type}[2]{@type@\ #1\ @=@\;#2}
304 \newcommand{\data}[2]{@data@\ #1\ @=@\;#2}
305 \newcommand{\tuple}[2]{@tuple@\ #1\ @=@\;#2} %%% NEW!
306 \newcommand{\view}[3]{@view@\ #1\ @=@\;#2\ @where@\ @{@\ #3\ @}@}
307 \newcommand{\class}[2]{@class@\ #1\ @where@\ @{@\ #2\ @}@}
308 \newcommand{\instance}[2]{@instance@\ #1\ @where@\ @{@\ #2\ @}@}
309 \newcommand{\signature}[2]{#1\ @::@\ #2}
310 \newcommand{\binding}[2]{#1\ @=@\ #2}
311 \newcommand{\lamexpr}[2]{@\@ #1 @->@ #2}
312
313 % While lambda defs. change...  if change, take care of preceding line MMG
314 \newcommand{\lamb}{@\ @}
315 \newcommand{\whereexpr}[2]{#1\ @where@\ @{@\ #2\ @}@}
316 \newcommand{\compexpr}[2]{@[@#1\ @|@\ #2@]@}
317 \newcommand{\genclause}[2]{#1\ @<-@\ #2}
318 \newcommand{\qualcomb}[2]{#1\ @,@\ #2}
319 \newcommand{\genguard}[1]{\ #1\ }
320 \newcommand{\caseexpr}[2]{@case@\ #1\ @of@\ @{@\ #2\ @}@}
321 \newcommand{\simplecaseexpr}[5]{@case@\ #1\ @of@\ @{@\ #2\ @->@\ #3;\ #4\ @->@\ #5\ @}@} 
322 \newcommand{\iteexpr}[3]{@if@\ #1\ @then@\ #2\ @else@\ #3}
323 \newcommand{\itexpr}[2]{@if@\ #1\ @then@\ #2}
324 \newcommand{\gpat}[2]{#1\ @|@\ #2}
325 \newcommand{\aspat}[2]{#1 @ @@ @ #2}
326 \newcommand{\fclause}[2]{#1\ @=@\ #2}
327 \newcommand{\fsym}[2]{#1\ @;@\ #2}
328 \newcommand{\fpri}[2]{#1\ @;@\ @else@\ @;@\ #2}
329 \newcommand{\aclause}[2]{#1\ @->@\ #2}
330 \newcommand{\saclause}[4]{#1\ @->@\ #2;\ #3\ @->@\ #4}
331 \newcommand{\asym}[2]{#1\ @;@\ #2}
332 \newcommand{\apri}[2]{#1\ @;@\ @else@\ @;@\ #2}
333 \newcommand{\dotted}[3]{#1\ #2\ \ldots\ #3}
334 \newcommand{\functype}[2]{#1\ @->@\ #2}
335 \newcommand{\predtype}[2]{#1\ @=>@ #2}
336 \newcommand{\xp}{\dotted{x}{p_1}{p_n}}
337 \newcommand{\xpg}{\dotted{x}{p_1}{p_n\ @{@\ g\ @}@}}
338 \newcommand{\es}{e_1\ \ldots\ e_n}
339 \newcommand{\ps}{p_1\ \ldots\ p_n}
340 \newcommand{\vs}{v_1\ \ldots\ v_n} %%% NEW
341 \newcommand{\xs}{x_1\ \ldots\ x_n} %%% NEW
342 \newcommand{\cT}{\dotted{c}{T_1}{T_n}}
343 \newcommand{\cTm}{\dotted{c_i}{T_{i1}}{T_{in_i}}\, @|@\range{i=1}{m}}
344 % syntax meta-language
345 \newcommand{\arity}[1]{\tr{arity}\ #1}
346 \newcommand{\infix}[1]{\tr{infix}\ #1}
347 \newcommand{\prefix}[1]{\tr{prefix}\ #1}
348 %
349 \newcommand{\tl}[1]{{\sc #1}}
350 \newcommand{\Haskell}{Haskell}
351
352 \newcommand{\subsubsubsection}{\subsubsection*}
353 \newcommand{\subsubsubsubsection}{\subsubsubsection*}
354
355 % Haskell-prime markup: this annotates the new/changed parts of the report.
356 \definecolor{prime}{named}{DarkOrchid}
357 \newcommand{\hprime}[1]{\color{prime}#1\normalcolor}
358 \newenvironment{haskellprime}{\color{prime}}{\normalcolor}
359
360 %\sloppy
361
362 % a few hyphenation patterns, anyone?
363 \hyphenation{da-ta-type da-ta-types}
364 \hyphenation{Has-kell}
365
366
367 \begin{document}
368
369 \input{iso-chars}
370
371 % Set the float fractions to sensible values
372 \setcounter{topnumber}{2}
373 \setcounter{bottomnumber}{0}
374 \setcounter{totalnumber}{2}
375 \setcounter{dbltopnumber}{2}
376 \renewcommand{\textfraction}{0.1}
377 \renewcommand{\floatpagefraction}{0.9}
378 \renewcommand{\dblfloatpagefraction}{0.9}
379
380 \setcounter{page}{0}
381
382 % ------------------------- Title page -----------------------------------
383
384 \begin{titlepage}
385
386 \setcounter{page}{0}
387
388 \outline{
389 \vspace{.3in}
390 \begin{center}
391 {\LARGE\bf Haskell 2010 (DRAFT)} \\[.1in]
392 {\LARGE\bf Language Report} \\[.3in]
393 \end{center}
394 \vspace{.3in}
395 }
396 \vspace{.15in}
397 \begin{center} \large
398 Simon Marlow\\
399 (editor)
400 \end{center}
401 \vspace{.15in}
402
403 \vspace{3in}
404
405 \begin{center} \emph{Copyright notice.} \end{center}
406
407 The authors and publisher intend this Report to belong to the entire Haskell
408 community, and grant permission to copy and distribute it for any
409 purpose, provided that it is reproduced in its
410 entirety, including this Notice. Modified versions of this Report may
411 also be copied and distributed for any 
412 purpose,
413 provided that the modified version is clearly presented as such, and
414 that it does not claim to be a definition of the language Haskell 2010.
415 \end{titlepage}
416
417 % ------------------------- Preface -----------------------------------
418
419 \pagenumbering{roman}
420
421 \clearpage
422 \clearpage
423 \tableofcontents
424 \startnewstuff
425
426 \parskip=10pt plus2pt minus2pt
427 \setlength{\parindent}{0cm}
428
429 \input{preface}
430
431 % ------------------------- Part I: language report -----------------------------------
432
433 \pagestyle{headings}
434 \startnewstuff
435 \pagenumbering{arabic}
436
437 \part{The Haskell 2010 Language}
438
439 \input{intro}\startnewsection
440 \input{lexemes}\startnewsection
441 \input{exps}\startnewsection
442 \input{decls}\startnewsection
443 \input{modules}\startnewsection
444 \input{basic}\startnewsection
445 \input{io-13}\startnewsection
446 \input{ffi}\startnewsection
447
448 % \appendix
449 \input{standard-prelude}\startnewsection
450 \input{syntax-iso}\startnewsection
451 \input{fixity}\startnewsection
452 \input{derived}\startnewsection
453 \input{pragmas}
454 %%
455
456 % ------------------------- Part II: libraries report -----------------------------------
457
458 \part{The Haskell 2010 Libraries}
459 \label{libraries}
460
461 \input{ratio}\startnewsection
462 \input{complex}\startnewsection
463 \input{numeric}\startnewsection
464 \input{ix}\startnewsection
465 \input{array}\startnewsection
466 \input{list}\startnewsection
467 \input{maybe}\startnewsection
468 \input{char}\startnewsection
469 \input{monad}\startnewsection
470 \input{io}\startnewsection
471 \input{directory}\startnewsection
472 \input{system}\startnewsection
473 \input{time}\startnewsection
474 \input{locale}\startnewsection
475 \input{cputime}\startnewsection
476 \input{random}\startnewsection
477
478 \input{lib-data-intword}
479 \input{lib-data-bits}
480
481 \input{lib-foreign}
482 \input{lib-ptr}
483 \input{lib-foreignptr}
484 \input{lib-storable}
485 \input{lib-stableptr}
486 \input{lib-marshal}
487 \input{lib-marshalerror}
488 \input{lib-marshalutils}
489 \input{lib-marshalalloc}
490 \input{lib-marshalarray}
491 \input{lib-cforeign}
492 \input{lib-ctypes}
493 \input{lib-cstring}
494 \input{lib-cerror}
495
496
497 % ------------------------- Index and references -----------------------------------
498
499 \startnewstuff
500 % insert the extra indexing things LAST
501 \input{index-extra}
502
503 % Add a contents line for the References -- may be off by one page
504 \addcontentsline{toc}{section}{References}
505 \bibliographystyle{plain}
506 \bibliography{haskell}
507 %
508 \startnewstuff
509 \printindex
510
511 \end{document}
512
513 % Local Variables: 
514 % mode: latex
515 % End: