Commits

Even Wiik Thomassen committed fc7037c

SOme work on putStrLn.

Comments (0)

Files changed (2)

 
 % List of todos
 %----------------
-\cleardoublepage
-\phantomsection
-\addcontentsline{toc}{chapter}{List of todos}
-\listoftodos
+%\cleardoublepage
+%\phantomsection
+%\addcontentsline{toc}{chapter}{List of todos}
+%\listoftodos
 
 % List of figures
 %-----------------
-\phantomsection
-\addcontentsline{toc}{chapter}{List of figures}
-\renewcommand{\listfigurename}{List of figures}
-\listoffigures
+%\phantomsection
+%\addcontentsline{toc}{chapter}{List of figures}
+%\renewcommand{\listfigurename}{List of figures}
+%\listoffigures
 
 % List of tables
 %----------------
-\phantomsection
-\addcontentsline{toc}{chapter}{List of tables}
-\renewcommand{\listtablename}{List of tables}
-\listoftables
+%\phantomsection
+%\addcontentsline{toc}{chapter}{List of tables}
+%\renewcommand{\listtablename}{List of tables}
+%\listoftables
 
 % List of listings
 %------------------
 
 % Chapters
 %----------
-\include{introduction}
-\include{ghc} % Haskell, GHC, Core
+%\include{introduction}
+%\include{ghc} % Haskell, GHC, Core
 \include{rpython} % Python, PyPy, RPython, JIT
 \include{extcore} % GHC's External Core
 \include{pyhaskell} % Everyhing about PyHaskell
 \include{jit} % JIT techniques (method)
 \include{lowlevel} % Low level code examples
-\include{benchmarks} % Describe how we benchmark
-\include{evaluation}  % (result)
+%\include{benchmarks} % Describe how we benchmark
+%\include{evaluation}  % (result)
 %\include{discussion}
 %\include{conclusion}
-\include{related}
+%\include{related}
 
 % Appendices
 %------------
 
 % List of acronyms
 %------------------
-\phantomsection
-\printglossaries
+%\phantomsection
+%\printglossaries
 
 \end{document}
 \begin{figure}[tbp]
 	\center
 	\includegraphics[scale=0.75]{./img/pipeline}
-	\caption[Haskell-Python pipeline]{Haskell-Python pipeline by \citet{skrede}\label{fig:pipeline}}
+	\caption[Haskell-Python pipeline]{%
+        Haskell-Python pipeline by \citet{skrede}\label{fig:pipeline}}
 \end{figure}
 The pipeline starts with the \gls{ghc} frontend that takes care of parsing,
 type checking and desugaring Haskell source code. \gls{ghc} then generates an
 \todo{Need better section-title!}
 Describe, in detail, the work I have done on PyHaskell during my thesis.
 
+\subsection{runMainIO}
+\mycode{runMainIO} is a simple wrapper around \mycode{Main.main} that should
+catch otherwise uncaught exceptions, and should also flushe stdout/stderr
+before exiting.
+\mytodo{TODO, move this notice or fix/implement it.}
+
+\subsection{putStrLn}
+\mycode{putStrLn} is a simple function that takes a list of \mycode{Char}'s
+(a string), and the prints them (with a newline) to \mycode{stdout}. The type
+of \mycode{putStrLn} is defined in Haskell Prelude as:
+\mint{haskell}|String -> IO ()|
+While we had implemented it with the correct behaviour, in as far as it printed
+the correct things to \mycode{stdout}, it returned the \mycode{Char} list
+instead of \mycode{IO ()}. It was done this way to avoid having to implement
+parts such as IO, but it pushed the list further down the evaluation stack,
+which could be problematic.
+
+Consider the simple example of printing the string "Hey" to \mycode{stdout}:
+\mint{haskell}|main = putStrLn "Hey"|
+In the external core output produced by \gls{ghc}
+(\autoref{lst:putStrLn-extcore}), one might see that it simply involves calling
+\mycode{putStrLn} with the unpacked string "Hey". PyHaskell converts this to
+a set of operations, and in line six of \autoref{lst:putStrLn-evallog} the
+string is printed. The argument to \mycode{putStrLn} can be seen again in line
+seven, and it is given to \mycode{runMainIO} in line eight, until evaluation
+ends.
+
+\mytodo{actually implement IO (), and return it, then explain what I did and show an example}
+
+\begin{listing}[htbp]
+\begin{lstlisting}[basicstyle=\footnotesize, numberstyle=\tiny\color{gray}, numbers=right]
+%module main:Main
+  main:Main.main :: (ghczmprim:GHCziTypes.IO
+                     ghczmprim:GHCziTuple.Z0T) =
+    base:SystemziIO.putStrLn
+    (ghczmprim:GHCziCString.unpackCStringzh
+     ("Hey"::ghczmprim:GHCziPrim.Addrzh));
+  main:ZCMain.main :: (ghczmprim:GHCziTypes.IO
+                       ghczmprim:GHCziTuple.Z0T) =
+    base:GHCziTopHandler.runMainIO @ ghczmprim:GHCziTuple.Z0T
+    main:Main.main;
+\end{lstlisting}
+\caption{putStrLn example, GHC external core output\label{lst:putStrLn-extcore}}
+\end{listing}
+
+\begin{listing}[htbp]
+\begin{lstlisting}[basicstyle=\footnotesize, numberstyle=\tiny\color{gray}, numbers=right]
+runMainIO putStrLn unpackCString# Hey  => 
+putStrLn unpackCString# Hey  => 
+unpackCString# Hey  => 
+(Constr : H, (Constr : e, (Constr : y, (Constr []))))  => 
+putStrLn (Constr : H, (Constr : e, (Constr : y, (Constr []))))  => 
+Hey
+(Constr : H, (Constr : e, (Constr : y, (Constr []))))  => 
+runMainIO (Constr : H, (Constr : e, (Constr : y, (Constr []))))  => 
+\end{lstlisting}
+\caption{putStrLn example, PyHaskell evaluation log\label{lst:putStrLn-evallog}}
+\end{listing}
+
 
 \section{Current status/Summary}
 %-------------------------------