\ProvidesPackage{haskell} % © Andrew Cooke 2001, Ketil Malde 2005 % Released under the GPL - see http://www.gnu.org % % This file is a simple Latex style file that, together with the % listings package (and the geometry, titlesec and graphicx packages if % you include the code below that sets up a particular page style), % supports mixing Latex and Haskell. % % Listing no longer part of teTeX (as of 2.0.2), it seems. Current version % (listing 1.3) is recommended. % % Haskell already supports a literate programming style. If you put % Haskell code into a file that ends in ``.lhs'' then the contents will % be ignored except for anything between \begin{code} and \end{code}. % % All that I do below is add the glue to make this invoke the % appropriate actions in the listings package when Latex processes the % file. This takes the code inside the code block and formats it % nicely. % This stops warning from listings when used in article mode - you don't % want it if you are not using teh article style \newcounter{chapter} % Load the package that does the real work \usepackage{listings} \usepackage{lstpatch} % doesn't fix the bug it's supposed to?! \lst@CheckVersion{1.3} {\typeout{^^J% *** haskell.sty requires listings 1.3, ^^J% *** if you have an older version, you probably should upgrade.^^J ***^^J *** (Your version is \lst@version).^^J% ***^^J}% } % I couldn't get the haskell language definition from listing.sty to work. % Anyway, I don't think it's a good idea to add the Prelude identifiers % as keywords, so we define our own set instead: \lstset{ morekeywords={import,module,let,in,where,if,then,else}, morecomment=[l]--, morecomment=[n]{\{-}{-\}}, % this doesn't quite work -- why? morestring=[b]", sensitive=true } % Connect the code blocks to listings - this is the important bit! \lstnewenvironment{code} {\lstset{}% \csname lst@SetFirstLabel\endcsname} {\csname lst@SaveFirstLabel\endcsname} % The next chunk of code customizes the code appearance. See the % listings package documentation for full details. \lstset{ basicstyle=\small, % swap this and the following line for prop. font % basicstyle=\small\ttfamily, keywordstyle=\bfseries, % \underbar, % these look ugly identifierstyle=\ttfamily, commentstyle=\itshape, stringstyle=\slshape, basewidth={0.5em,0.45em}, columns=fullflexible, showstringspaces=false, numbers=left, numberstyle=\tiny, stepnumber=5, firstnumber=last, % frame=single, framerule=1pt, % ugly, but just to highlight the code % The following replace compound charcters like -> % Something is missing - someone kindly sent me an email which % I've lost - but it's obvious how to add more. literate={+}{{$+$}}1 {-}{{$-$}}1 {/}{{$/$}}1 {*}{{$*$}}1 {=}{{$=$}}1 {= }{{$=$ }}2 {==}{{$==$}}2 {== }{{$==$ }}3 {>}{{$>$}}1 {<}{{$<$}}1 {> }{{$>$ }}2 {< }{{$<$ }}2 {->}{{$\rightarrow$}}2 {>=}{{$\geq$}}2 {<-}{{$\leftarrow$}}2 {-> }{{$\rightarrow$ }}3 {>= }{{$\geq$ }}3 {<- }{{$\leftarrow$ }}3 {<=}{{$\leq$}}2 {=>}{{$\Rightarrow$}}2 {\ .}{{ $\circ$}}2 {&&}{$\wedge$}2 {||}{$\vee$}2 {&& }{$\wedge$ }3 {||}{$\vee$ }3 {\\}{$\lambda$}1 {\\ }{$\lambda$ }1 % ..but not in strings..how? {\\n}{$\setminus$n}2 {\\r}{$\setminus$r}2 % really ugly hack {\\"}{$\setminus$"}2 } % From here down it's just arranging things on the page how I like them % - nothing to do with formatting code etc. % Page size \usepackage[hmargin={5cm,3cm},vmargin={3cm,1cm},offset=0pt,nohead]{geometry} % Titles, layout etc \usepackage{titlesec} \titleformat{\part}[frame] {\normalfont} {\filright\footnotesize\enspace Andrew Cooke \enspace} {8pt} {\Large\bfseries\sffamily\filcenter} \titlespacing{\part} {-3cm}{-0.5cm}{5ex} \titleformat{\section} % [leftmargin] {\Large\bfseries\sffamily\raggedright} {}{0pt}{} \titlespacing{\section} {3cm}{2.5ex plus .1ex minus .2ex}{1pc} \titleformat{\subsection}[leftmargin] {\normalfont\bfseries\sffamily\filleft} {}{0pt}{} \titlespacing{\subsection} {3cm}{1.5ex plus .1ex minus .2ex}{1pc} \setlength{\parindent 0pt} \setlength{\parskip 1.5ex plus 0.5ex minus 0.2ex} % Support eps images \usepackage{graphicx}