\usepackage{listings}
\usepackage{amsopn}
\usepackage{amsmath}
\DeclareMathOperator*{\argmax}{arg\,max}
\newcommand{\clseq}{\left\langle}
\newcommand{\crseq}{\right\rangle}
\newcommand{\cseq}[1]{\left\langle\, #1 \,\right\rangle}
\newcommand{\cseqf}[2]{\left\langle\, #1 \;|\; #2 \,\right\rangle}
\newcommand{\cidx}[2]{\cseq{#1,\ldots,#2}}
\newcommand{\cset}[1]{\left\{ #1 \right\}}
\newcommand{\csetf}[2]{\left\{ #1 \;|\; #2 \right\}}

\newdimen\fsize
\fsize=11pt
\newcommand{\Lstbasicstyle}{\fontsize{\fsize}{1.1\fsize}\ttfamily}
\newcommand{\keywordstyle}{\fontsize{\fsize}{1.1\fsize}\normalfont\bf}

\lstset{
  xleftmargin=5.0ex,
  basicstyle=\Lstbasicstyle,
  captionpos=b,
  numbers=left, numberstyle=\small, numbersep=8pt,
  keywordstyle=\keywordstyle,
  keywords={signature,sig,structure,struct,function,case,of,type,datatype,let,val,fn,in,end,as,functor,alloc,if,then,else,while,with,and},
  commentstyle=\rmfamily\slshape,
  morecomment=[l]{\%},
  lineskip={1.5pt},
  columns=[l]fullflexible,
  keepspaces=true,
  mathescape=true,
  escapeinside={@}{@},
% NOTE: need TWO sets of braces around each definition below!
  literate={requires}{{$\text{\keywordstyle \% requires}$}}6
           {returns}{{$\text{\keywordstyle \% returns}$}}6
           {=}{{$=$}}2 
           {(}{{$($}}2
           {)}{{$)$}}2 
           {**}{{$\times$}}2 
           {||}{{$\Vert$}}2 
           {=>}{{$\boldsymbol\Rightarrow$}}2 
           {->}{{$\rightarrow$}}2 
}
