File: InteractivePreIn.lhs

package info (click to toggle)
lhs2tex 1.24-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,976 kB
  • sloc: haskell: 4,408; makefile: 314; sh: 221
file content (31 lines) | stat: -rwxr-xr-x 586 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
%include verbatim.fmt

\begingroup
\let\origtt=\ttfamily
\def\ttfamily#1{\origtt}
%if style == newcode

module InteractivePre where

%endif

\begin{code}
%format SPL(x) = $ ( x )
%if style == newcode
%format QU(x)  = [ | x | ]
%format ^^     = " "
%else
%format QU(x)  = "\llbracket " x "\rrbracket "
%format ^^     = "\; "
%endif

%options ghci -fth -pgmL ../lhs2TeX -optL--pre

This is a rather stupid way of computing |42| using
Template Haskell:

> answer = SPL(foldr1 (\x y -> QU(SPL(x) + SPL(y))) (replicate 21 ^^ QU(2)))

The answer is indeed \eval{answer}.
\end{code}
\endgroup