summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/checklistings/example.tex
blob: 88980097a9ff99979a2c6c67e46c43291c455b98 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
\documentclass[a4paper]{article}

\usepackage[T1]{fontenc}
\usepackage[prompt=,prefix=example]{checklistings}
\usepackage{listings}

\lstdefinestyle{camlstyle}{%
  language=caml,
  basicstyle=\sffamily,
  keywordstyle=\bf,
  literate={"}{\textquotedbl}1,
}
%BEGIN LATEX
\checklistings{codelst={style=camlstyle}}
%END LATEX
%HEVEA \newstyle{.chklistingerr}{font-style: italic; color: red;}
%HEVEA \newstyle{.chklistingmsg}{font-style: italic;}
%HEVEA \checklistings{codelst=\{style=camlstyle\}}

\begin{document}

\noindent
Two simple declarations:
\begin{chklisting}
let x = 3
let f x = x + 1
\end{chklisting}

\noindent
and, after compilation with \chklistingcmd, their types:
\chklistingmsg{}

\noindent
Then, building on these definitions:
\begin{chklisting}[continue,withresult,label=early]
let y = f 3
\end{chklisting}

\noindent
What about compiler error messages?:
\begin{chklisting}[fail]
let z = 3 + "four"
\end{chklisting}

\noindent
They are also detected:
\chklistingerr{}

\noindent
We can continue on from earlier examples:

\begin{chklisting}[withresult,include=early]
let z = f y
\end{chklisting}

\end{document}