% % Listings setup (unused)
% \usepackage{listings}
% \newcommand{\li}{\lstinline[style=Haskell, breaklines=true, breakatwhitespace=true]}
% \newcommand{\uli}{\lstinline[basicstyle=\ttfamily,breaklines=true, breakatwhitespace=true]}
% \lstnewenvironment{haskell}{\lstset{style=Haskell}}{}
% \lstnewenvironment{code}{\lstset{style=Haskell}}{}
% \lstdefinestyle{Haskell}{language=Haskell
%         ,columns=flexible
%         ,basewidth={.365em}
%         ,keepspaces=True
%         ,texcl=true
%         ,escapechar=!
%         ,basicstyle=\sffamily
%         ,stringstyle=\itshape
%         ,showstringspaces=false
%         ,commentstyle=\rmfamily\itshape
%         ,literate={->}{$\,\to\,$}2
%                   {<-}{$\,\leftarrow\,$}2
%                   {==>}{$\,\implies\,$}2
%                   {=>}{$\,\Rightarrow\,$}2
%                   {→}{$\,\to\,$}2
% %                  {\\}{$\uplambda$}1
% %                  {+}{{$+$}}1
%                   {[]}{[\,]\ }1
% %                  {--}{{---\ }}1  would be nice, but prevents detection of comments
%                   {++}{{$+\!\!+$}}1
% %        % Nicer comment separator
% %        ,deletecomment=[l]--%
% %        ,escapeinside={-- }{\^^M}
% %        ,escapebegin={\rmfamily\obeyspaces--- }
%         ,keywords={%
%             case,class,data,default,deriving,do,else,%
%             foreign,if,import,in,infix,infixl,infixr,instance,%
%             let,forall,letrec,module,newtype,role,of,then,type,where,\_,%
%             nominal,representational,phantom,sub,sym,family%
%         }
%         }

% Manual syntax highlighting




\newcommand{\haskellfont}{\sffamily}

\input{consumenextword}

\begingroup
\catcode`!=\active
\gdef\activateexclamationmark{%    note the global \gdef
  \catcode`!=\active%
  \def!{\consumenextword{\hkw}}%
}
\endgroup

\begingroup
\catcode`*=\active
\gdef\activatenicemult{%    note the global \gdef
  \catcode`*=\active%
  \def*{{$\ast$}}%
}
\endgroup

\def\hcode{%
\begingroup%
%
\activateexclamationmark%
\activatenicemult%
\newcommand{\hind}{~~~~}%
\newcommand{\hwhere}{~~\hkw{where}}%
%
\unskip%
\vspace{\abovedisplayskip}%
\par%
\noindent%
\haskellfont%
\pboxed%
\defaultcolumn{@{}l@{ }}%
\ignorespaces%
}
\def\endhcode{%
\endpboxed%
\vspace{\belowdisplayskip}%
\par\noindent%
\endgroup%
\ignorespacesafterend%
}

\def\thcode{\varwidth{10cm}\begingroup\hcode}
\def\endthcod{\endhcode\endgroup\endvarwidth}

\newcommand{\hkw}[1]{\textbf{#1}}

\makeatletter
\def\hi{%
  \begingroup%
  \activateexclamationmark%
  \activatenicemult%
  \hi@%
}
\newcommand{\hi@}[1]{%
\haskellfont%
#1%
\endgroup%
}

\makeatother
