6df98575367829aa84a0cdc18c7d6230fe098d37
[matthijs/master-project/report.git] / Utils / Lambda.tex
1 %
2 % Some utilities for formatting (extended) lambda calculus and
3 % transformations.
4 %
5
6 \startuseMPgraphic{HLine}
7 path a, b;
8 % Create a rectangle of the full size
9 a := origin -- (\MPvar{width}, 0mm);
10 % Randomize it a bit
11 b := a randomized (\overlaywidth / 25) ;
12 % And draw it
13 drawoptions (withpen pencircle scaled .75mm withcolor black) ;
14 draw b; 
15 \stopuseMPgraphic
16
17 % Draw a line with the given options. Accepts only the 'width' option. Be
18 % careful that these are metapost options, so use \the\textwidth instead of
19 % textwidth, and a metapost expression for arithmethic (e.g. 0.5 *
20 % \the\textwidth instead of 0.5\textwidth).
21 \def\HLine[#1]%
22   {\setupMPvariables[HLine][#1]%
23   \useMPgraphic{HLine}}
24
25 \startuseMPgraphic{box}
26 path a, b;
27 % Create a rectangle of the full size
28 a := unitsquare xyscaled(\overlaywidth,\overlayheight);
29 % Randomize it a bit
30 b := a randomized (\overlaywidth / 25) ;
31 % And draw it
32 drawoptions (withpen pencircle scaled .75mm withcolor black) ;
33 draw b; 
34 \stopuseMPgraphic
35
36 \defineoverlay[box][\useMPgraphic{box}]
37
38 % Define \{start,stop}boxed with a nice metapost box around it.
39 \defineframedtext[boxed][background=box,frame=off]
40 % A boxed variant with the width forced to page width. This is used in
41 % \startrans, since the content somehow doesn't scale the box around it
42 % properly.
43 \defineframedtext[wideboxed][background=box,frame=off,width=\textwidth,offset=.02\textwidth]
44
45 % Install the lambda calculus pretty-printer, as defined in pret-lam.lua.
46 \installprettytype [LAM] [LAM]
47 % Define \startlambda \stoplambda
48 \definetyping[lambda][option=LAM,style=sans,before=\startboxed,after=\stopboxed]
49
50 % Define \lam{} (since \lambda is taken)
51 \definetype[lam][option=LAM,style=sans]
52
53 % Install the transformation pretty-printer, as defined in pret-trans.lua.
54 \installprettytype [TRANS] [TRANS]
55 % Define \starttrans \stoptrans
56 \definetyping[trans][option=TRANS,style=normal,before=\startwideboxed,after=\stopwideboxed]
57
58 % Install the haskell pretty-printer, as defined in pret-haskell.lua.
59 \installprettytype [HASKELL] [HASKELL]
60 % Define \starthaskell \stophaskell
61 \definetyping[haskell][option=HASKELL,before=\startboxed,after=\stopboxed]
62 % Define \hs
63 \definetype[hs][option=HASKELL,style=mono]