-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathghc-vis.tex
34 lines (27 loc) · 1.25 KB
/
ghc-vis.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
% ghcvis-Dg.tex
\begin{hcarentry}{ghc-vis}
\label{ghc-vis}
\report{Dennis Felsing}%05/13
\status{active development}
\participants{Joachim Breitner}
\makeheader
The tool ghc-vis visualizes live Haskell data structures in GHCi.
Since it does not force the evaluation of the values under inspection it is possible to see Haskell's lazy evaluation and sharing in action while you interact with the data.
Ghc-vis supports two styles: A linear rendering similar to GHCi's \texttt{:print}, and a graph-based view where closures in memory are nodes and pointers between them are edges.
In the following GHCi session a partially evaluated list of fibonacci numbers is visualized:
\begin{verbatim}
> let f = 0 : 1 : zipWith (+) f (tail f)
> f !! 2
> :view f
\end{verbatim}
%**<img width=500 src="./fib.jpg">
%*ignore
\begin{center}
\includegraphics[width=0.35\textwidth]{html/fib.jpg}
\end{center}
%*endignore
At this point the visualization can be used interactively: To evaluate a thunk, simply click on it and immediately see the effects. You can even evaluate thunks which are normally not reachable by regular Haskell code.
Ghc-vis can also be used as a library and in combination with GHCi's debugger.
\FurtherReading
\url{https://dennis.felsing.org/ghc-vis}
\end{hcarentry}