2 % Some utilities for formatting (extended) lambda calculus and
6 \startuseMPgraphic{HLine}
8 % Create a rectangle of the full size
9 a := origin -- (\MPvar{width}, 0mm);
11 b := a randomized (\overlaywidth / 50) ;
13 drawoptions (withpen pencircle scaled .75mm withcolor black) ;
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).
22 {\setupMPvariables[HLine][#1]%
25 \startuseMPgraphic{HDLine}
27 % Create a rectangle of the full size
28 a := origin -- (\MPvar{width}, 0mm);
30 b := a randomized (\overlaywidth / 100) ;
32 drawoptions (withpen pencircle scaled .75mm withcolor black dashed evenly) ;
36 % Draw a line with the given options. Accepts only the 'width' option. Be
37 % careful that these are metapost options, so use \the\textwidth instead of
38 % textwidth, and a metapost expression for arithmethic (e.g. 0.5 *
39 % \the\textwidth instead of 0.5\textwidth).
41 {\setupMPvariables[HDLine][#1]%
42 \useMPgraphic{HDLine}}
44 \startuseMPgraphic{box}
46 % Create a rectangle of the full size
47 a := unitsquare xyscaled(\overlaywidth,\overlayheight);
49 b := a randomized (min(\overlayheight, \overlaywidth) / 25) ;
51 drawoptions (withpen pencircle scaled .75mm withcolor black) ;
55 \defineoverlay[box][\useMPgraphic{box}]
57 % Define \{start,stop}boxed with a nice metapost box around it.
58 \defineframedtext[boxed][width=fit,background=box,frame=off]
60 % Install the lambda calculus pretty-printer, as defined in pret-lam.lua.
61 \installprettytype [LAM] [LAM]
62 % Define \startlambda \stoplambda
63 \definetyping[lambda][option=LAM,style=sans,before=\startboxed,after=\stopboxed]
65 % Define \lam{} (since \lambda is taken)
66 \definetype[lam][option=LAM,style=sans]
68 % Install the transformation pretty-printer, as defined in pret-trans.lua.
69 \installprettytype [TRANS] [TRANS]
70 % Define \starttrans \stoptrans
71 \definetyping[trans][option=TRANS,style=normal,before=\startboxed,after=\stopboxed]
73 % Install the haskell pretty-printer, as defined in pret-haskell.lua.
74 \installprettytype [HASKELL] [HASKELL]
75 % Define \starthaskell \stophaskell
76 \definetyping[haskell][option=HASKELL,before=\startboxed,after=\stopboxed]
78 \definetype[hs][option=HASKELL,style=mono]
80 % Type the given buffer with the lambda typing style.
81 % e.g., \typebufferlam{buffname}
82 \define[1]\typebufferlam{
83 % We can't use \startlambda here defined by definetyping[lambda] above when
84 % typing buffers, so instead we'll redfine the options here.
85 \setuptyping[option=LAM,style=sans,before=,after=]
89 % Reset the typing options
90 \setuptyping[option=none,style=\tttf]
93 % Type the given buffer with the haskell typing style.
94 % e.g., \typebufferhs{buffname}
95 \define[1]\typebufferhs{
96 % We can't use \startlambda here defined by definetyping[lambda] above when
97 % typing buffers, so instead we'll redfine the options here.
98 \setuptyping[option=HASKELL,style=mono]
102 % Reset the typing options
103 \setuptyping[option=none,style=\tttf]
106 % Display a useMPgraphic in a pretty box
107 \define[1]\boxedgraphic{
113 % Define a "definition" float. We would like some more backgroundoffset, but
114 % this offset doesn't move the caption, causing the border to cross the
115 % caption... Also, centering the content didn't seem to work...
116 % TODO: Make more pretty.
117 \definefloat[definition][definitions]
118 \setupfloat[definition][background=box,backgroundoffset=1mm]
120 % Define an "example" float. Don't add box around it, since an example will
121 % commonly contain two boxed items (Before / after, code / picture).
122 \definefloat[example][examples]
123 \setupcaption[example][location=top] % Put captions on top