Created
October 1, 2017 10:12
-
-
Save ivanperez-keera/d13672a8ab5a2321d1f7b47d16a199e1 to your computer and use it in GitHub Desktop.
Example of haskell code formatted as in "Beautiful code, compelling evidence"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\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