2426178877fa3e10a67ed4f143381aa8ac2b9bcb
[matthijs/master-project/report.git] / Utils / Lambda.tex
1 %
2 % Some utilities for formatting (extended) lambda calculus and
3 % transformations.
4 %
5
6 \startuniqueMPgraphic{box}
7 path a, b;
8 % Create a rectangle of the full size
9 a := unitsquare xyscaled(\overlaywidth,\overlayheight);
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 \stopuniqueMPgraphic
16
17 \defineoverlay[box][\uniqueMPgraphic{box}]
18
19 % Define \{start,stop}boxed with a nice metapost box around it.
20 \defineframedtext[boxed][background=box,frame=off]
21 % A boxed variant with the width forced to page width. This is used in
22 % \startrans, since the content somehow doesn't scale the box around it
23 % properly.
24 \defineframedtext[wideboxed][background=box,frame=off,width=\textwidth,offset=.02\textwidth]
25
26 % Install the lambda calculus pretty-printer, as defined in pret-lam.lua.
27 \installprettytype [LAM] [LAM]
28 % Define \startlambda \stoplambda
29 \definetyping[lambda][option=LAM,style=sans,before=\startboxed,after=\stopboxed]
30
31 % Define \lam{} (since \lambda is taken)
32 \definetype[lam][option=LAM,style=sans]
33
34 % Install the transformation pretty-printer, as defined in pret-trans.lua.
35 \installprettytype [TRANS] [TRANS]
36 % Define \starttrans \stoptrans
37 \definetyping[trans][option=TRANS,style=normal,before=\startwideboxed,after=\stopwideboxed]
38
39 % Install the haskell pretty-printer, as defined in pret-haskell.lua.
40 \installprettytype [HASKELL] [HASKELL]
41 % Define \starthaskell \stophaskell
42 \definetyping[haskell][option=HASKELL,before=\startboxed,after=\stopboxed]
43 % Define \hs
44 \definetype[hs][option=HASKELL,style=mono]