Even Wiik Thomassen  committed fc7037c

SOme work on putStrLn.

  • Participants
  • Parent commits 32bf1c2

Comments (0)

Files changed (2)

 % List of todos
-\addcontentsline{toc}{chapter}{List of todos}
+%\addcontentsline{toc}{chapter}{List of todos}
 % List of figures
-\addcontentsline{toc}{chapter}{List of figures}
-\renewcommand{\listfigurename}{List of figures}
+%\addcontentsline{toc}{chapter}{List of figures}
+%\renewcommand{\listfigurename}{List of figures}
 % List of tables
-\addcontentsline{toc}{chapter}{List of tables}
-\renewcommand{\listtablename}{List of tables}
+%\addcontentsline{toc}{chapter}{List of tables}
+%\renewcommand{\listtablename}{List of tables}
 % List of listings
 % Chapters
-\include{ghc} % Haskell, GHC, Core
+%\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)
 % Appendices
 % List of acronyms

File pyhaskell.tex

-	\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}}
 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.
+\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.}
+\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
+\mytodo{actually implement IO (), and return it, then explain what I did and show an example}
+\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;
+\caption{putStrLn example, GHC external core output\label{lst:putStrLn-extcore}}
+\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 []))))  => 
+(Constr : H, (Constr : e, (Constr : y, (Constr []))))  => 
+runMainIO (Constr : H, (Constr : e, (Constr : y, (Constr []))))  => 
+\caption{putStrLn example, PyHaskell evaluation log\label{lst:putStrLn-evallog}}
 \section{Current status/Summary}