Skip to content

Instantly share code, notes, and snippets.

@ivanperez-keera
Created October 1, 2017 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivanperez-keera/d13672a8ab5a2321d1f7b47d16a199e1 to your computer and use it in GitHub Desktop.
Save ivanperez-keera/d13672a8ab5a2321d1f7b47d16a199e1 to your computer and use it in GitHub Desktop.
Example of haskell code formatted as in "Beautiful code, compelling evidence"
\definecolor{mygreen}{rgb}{0,0.6,0}
\lstset{
commentstyle=\color{mygreen},
keywordstyle=\color{blue}, % keyword style
breaklines=true
}
\begin{minipage}{\linewidth}
\hspace*{.1\linewidth}%
\begin{minipage}{.7\linewidth}
\begin{lstlisting}[frame=l,basicstyle=\small\ttfamily,language=Haskell,
escapeinside={(*@}{@*)},
escapebegin={\begin{lrbox}{0}\normalfont\itshape\small\color{black!70}},
escapeend={\end{lrbox}\llap{\box0\hspace{10pt}}}
]
(*@ 30 @*) gameMain :: IORef WorldState
(*@ $\hookrightarrow$ @*) -> (IORef WorldState -> IO ()) -> IO ()
(*@ @*) gameMain worldStateRef mainCallback = do
(*@ @*) startTime <- getCurrentTime
(*@ @*)
(*@ @*) worldState <- readIORef worldStateRef
(*@ 35 @*)
(*@ @*) let mainpanel = mainPanel worldState
(*@ @*)
(*@ @*) let lvl = curLevel worldState
(*@ @*) lvlData = levelData lvl
(*@ 40 @*)
(*@ @*) -- get updated input
(*@ @*) let keysRef' = keysStateRef worldState
(*@ @*) mousePosRef' = mousePosRef worldState
(*@ @*) mousePos' <- readIORef (mousePosRef worldState)
(*@ 45 @*) keys' <- readIORef (keysStateRef worldState)
(*@ @*) Glut.Size winW winH <- Glut.get Glut.windowSize
(*@ @*) let (mousex, mousey) =
(*@ $\hookrightarrow$ @*) translateMousePos mousePos' winW winH
(*@ @*) ...
\end{lstlisting}
\end{minipage}
\end{minipage}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment