<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> 
<head>
<title>ActiveHs Developer’s Documentation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta name="copyright" content="Copyright &#169; 2008-2011 Péter Diviánszky" />
<link rel="shortcut icon" href="icon.ico" />
<script src="common_en.js" charset="utf-8" type="text/javascript"></script> 
<link rel="stylesheet" href="common.css" type="text/css" />
</head>
<body onload="javascript:resetForms(); javascript:slidy_init();">
<div><h1 class="cover">ActiveHs Developer’s Documentation</h1>
<div id="info"></div>
<ul>
<li><a href="#main-components">Main Components</a></li>
<li><a href="#module-hierarchy">Module Hierarchy</a></li>
<li><a href="#web-server-component">Web Server Component</a></li>
<li><a href="#converter-component">Converter Component</a></li>
<li><a href="#interpreter-component">Interpreter Component</a></li>
</ul>
</div>
<p>This is the developer’s documentation of ActiveHs. To understand the terms used, <a href="UsersGuide_en.xml">please read the user’s guide first</a>.</p>
<div class="section level1" id="main-components">
<h1><a href="#main-components">Main Components</a></h1>
<p>ActiveHs has five main components, static files, web server, converter, interpreter and libraries:</p>
<p><img src="DevDoc_enc45727a0abe3448fa3584fed761f0961.png" alt="DevDoc_enc45727a0abe3448fa3584fed761f0961.png" /></p>
<p>Green files are the user’s input.</p>
<div class="handout">
<hr />
<dl>
<dt><strong>libraries</strong></dt>
<dd>The ActiveHs base libraries contain SVG graphics support and some auxiliary declarations. The base libraries should be imported in the .lhs files.
</dd>
<dt><strong>converter</strong></dt>
<dd>The converter converts literate Haskell files with pandoc comments to xhtml files with the help of the pandoc library. The template files are used during this process. The template files may refer to the static files but these files are not needed during the conversion.<br />Inline latex and graphviz content in the comments will be converted to png files.<br />Exercises in the comments will be converted to exercise files.<br />
</dd>
<dt><strong>static files</strong></dt>
<dd>Static files are javascript and css files served statically.<br />These files are responsible for the slideshow mode and the AJAX input fields for the exercises in the xml files.
</dd>
<dt><strong>web server</strong></dt>
<dd>The web server serves static files and .xml and .png files generated by the converter.<br />The web server also handles Haskell expression evaluation requests with the help of the interpreter and with the help of the exercise files generated by the converter.
</dd>
<dt><strong>interpreter</strong></dt>
<dd>The interpreter is a specialized Haskell interpreter which can evaluate expressions, compare expressions, test definitions and check definitions (with quickcheck). The exercise files contain the information needed to perform these tasks.
</dd>
</dl>
</div>
</div>
<div class="section level1" id="module-hierarchy">
<h1><a href="#module-hierarchy">Module Hierarchy</a></h1>
<p>The following diagram contains the Haskell source files of ActiveHs (boxed nodes), the main dependencies between them (edges between boxes) and the main external dependencies (unboxed nodes).</p>
<p>The converter component consists of two modules: <code>Parse</code> and <code>Compile</code> (top part).<br />The web server component consists of the <code>Main</code> module and some auxiliary modules (<code>Cache</code> and <code>Args</code>; middle part).<br />The interpreter component consists of the remaining modules (bottom part).</p>
<p><img src="DevDoc_eneac0e6acf6e333b3aa5ae0cc9f1a5255.png" alt="DevDoc_eneac0e6acf6e333b3aa5ae0cc9f1a5255.png" /></p>
</div>
<div class="section level1" id="web-server-component">
<h1><a href="#web-server-component">Web Server Component</a></h1>
<p>The web server component consists of the <code>Main</code> module and the <code>Cache</code> and <code>Args</code> auxiliary modules.</p>
<p>Schematic handling of requests:</p>
<p><img src="DevDoc_en2d2f1d24663ba0ee7f66e51431599dbe.png" alt="DevDoc_en2d2f1d24663ba0ee7f66e51431599dbe.png" /></p>
<p>If a requested .xml file does not exists, but there is a corresponding .lhs file, or the .xml file exists but the corresponding .lhs file is newer, then first the converter will be invoked on the .lhs file, then the .xml file will be served.</p>
<p>There are four different post request corresponding to the four different interpreter actions (see below). In any case, the web server tries to serve a cached answer. If there is no cached answer, the interpreter will be invoked, and the answer will be cached and served.</p>
<p>The <code>Cache</code> module implements a very simple cache.</p>
<p>The <code>Args</code> module is responsible for the command-line arguments.</p>
</div>
<div class="section level1" id="converter-component">
<h1><a href="#converter-component">Converter Component</a></h1>
<p>Conversion is done in two main phases which are implemented in the <code>Parse</code> and <code>Compile</code> modules.</p>
<p><code>Parse</code> phase:</p>
<ol style="list-style-type: decimal">
<li>Comments are filtered out.</li>
<li>Parsing with the lhs + markdown pandoc reader function.</li>
<li>Find and parse ActiveHs commands in pandoc’s inner document format.</li>
</ol>
<p><code>Compile</code> phase:</p>
<ol style="list-style-type: decimal">
<li>ActiveHs commands are converted into the pandoc’s inner document format.<br /> During this process the interpreter component may be invoked.</li>
<li>.dot and .latex code blocks are filtered out and converted into .png by external shell commands</li>
<li>The xhtml file is produced by the corresponding padoc writer function.</li>
</ol>
</div>
<div class="section level1" id="interpreter-component">
<h1><a href="#interpreter-component">Interpreter Component</a></h1>
<p>The interpreter is built bottom-up as follows:</p>
<ol style="list-style-type: decimal">
<li><p><code>hint</code> package</p>
The <code>hint</code> package provides a simplified interface to the GHC API.</li>
<li><p><code>Simple</code> module</p>
This module provides an even more simplified and somewhat managed interface to <code>hint</code>.<br /><a href="Economic_en.xml">The main ideas are described here.</a></li>
<li><p><code>Smart</code> module</p>
<p>This module adds more functionality to the interface of <code>Simple</code>.<br />Main features added:</p>
<ul>
<li>Type inference with the <code>:t</code> command</li>
<li>Kind inference with the <code>:k</code> command</li>
<li>Hoogle search with the <code>:?</code> command, based on <code>HoogleCustom</code></li>
<li>Hoogle information search with the <code>:i</code> command, based on <code>HoogleCustom</code></li>
<li>Automatic command selection (in most cases you don’t need <code>:t</code>, <code>:k</code>, <code>:?</code> or <code>:i</code>)</li>
<li>Type specialization, based on <code>Specialize</code> (needed for the next two features)</li>
<li>Prettyprint values, based on <code>data-pprint</code> (<a href="Show_en.xml">look at this for exaples</a>)</li>
<li>Display numeric functions, based on <code>dia-functions</code> (<a href="FunctionGraphs_en.xml">look at this for exaples</a>)</li>
<li>Display expressions with type <code>Diagram</code>, based on <code>dia-functions</code> (<a href="Diagrams_en.xml">look at this for exaples</a>)</li>
<li>Error logging, based on <code>snap</code> logger</li>
<li>Basic internationalization support</li>
</ul></li>
<li><p><code>Special</code> module</p>
<p>This module provides 4 special modes on top of <code>Smart</code>:</p>
<ul>
<li>Expression evaluation</li>
<li>Expression comparison: Decide whether an expression is equal to a reference implementation.</li>
<li>Testing definitions: Decide whether the value of an expression is the same with the given and with the reference implementation.</li>
<li>Checking definitions: Decide whether a definition is equal functionally to a reference implementation.<br /> This mode is built on quickcheck and the definition testing mode.</li>
</ul></li>
</ol>
</div>
<div><h1><a href="Overview_en.xml">Back to the main page</a></h1>
<p><em><a href="Overview_en.xml">Main page</a></em></p>
</div>
</body>
</html>

