1. Austin Seipp
  2. hs-asai

Commits

Austin Seipp  committed f02350b

Initial documentation draft.

Signed-off-by: Austin Seipp <mad.one@gmail.com>

  • Participants
  • Branches gh-pages

Comments (0)

Files changed (21)

File doc/Control-Delimited-Tutorial.html

View file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Control.Delimited.Tutorial</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
+window.onload = function () {pageLoad();setSynopsis("mini_Control-Delimited-Tutorial.html");};
+//]]>
+</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Control-Delimited-Tutorial.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">asai-0.0.0.0: A minimal library for delimited continuations.</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>portable</td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Maintainer</th><td>mad.one@gmail.com</td></tr><tr><th>Safe Haskell</th><td>Safe-Inferred</td></tr></table><p class="caption">Control.Delimited.Tutorial</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Introduction
+</a></li><li><a href="#g:2">Notes on <code>do</code>-notation
+</a></li><li><a href="#g:3">References
+</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>This module provides a brief introductory tutorial in the
+ &quot;Introduction&quot; section, followed by some discussion behind the
+ theory of the library with references.
+</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"></ul></div><div id="interface"><h1 id="g:1">Introduction
+</h1><div class="doc"><p>Lorem ipsum...
+</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>runDelim $ reset $ (shift1 (\_ -&gt; return &quot;hello&quot;) &gt;&gt;= \r -&gt; return (r + 1))
+</code></strong>&quot;hello&quot;
+</pre></div><h1 id="g:2">Notes on <code>do</code>-notation
+</h1><div class="doc"><p>Lorem ipsum...
+</p></div><h1 id="g:3">References
+</h1><div class="doc"><ul><li> <em>Polymorphic Delimited Continuations</em>, by Asai, Kameyama in <em>APLAS '07</em>:
+    <a href="http://logic.cs.tsukuba.ac.jp/~kam/paper/aplas07.pdf">http://logic.cs.tsukuba.ac.jp/~kam/paper/aplas07.pdf</a>
+</li><li> <em>Genuine shift\reset in Haskell98</em>, by Kiselyov, on <em>haskell-cafe</em>:
+    <a href="http://okmij.org/ftp/continuations/implementations.html#genuine-shift">http://okmij.org/ftp/continuations/implementations.html#genuine-shift</a>
+</li><li> <em>Introduction to programming with shift and reset</em>, by Kiselyov, Asai, in <em>CW2011</em>:
+    <a href="http://okmij.org/ftp/continuations/index.html#tutorial">http://okmij.org/ftp/continuations/index.html#tutorial</a>
+</li></ul></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.13.1</p></div></body></html>

File doc/Control-Delimited.html

View file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Control.Delimited</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
+window.onload = function () {pageLoad();setSynopsis("mini_Control-Delimited.html");};
+//]]>
+</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Control-Delimited.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">asai-0.0.0.0: A minimal library for delimited continuations.</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>Rank-2 types required</td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Maintainer</th><td>mad.one@gmail.com</td></tr><tr><th>Safe Haskell</th><td>Safe-Inferred</td></tr></table><p class="caption">Control.Delimited</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Delimited continuations
+</a><ul><li><a href="#g:2">A family of shift operators
+</a></li><li><a href="#g:3">Executing delimited computations
+</a></li></ul></li><li><a href="#g:4">Re-exports for convenience
+</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Delimited continuations featuring answer-type polymorphism, via
+ parameterized monads.
+</p><p>There is a tutorial available in <a href="Control-Delimited-Tutorial.html">Control.Delimited.Tutorial</a>.
+</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">data</span>  <a href="#t:Delim">Delim</a> s t b</li><li class="src short"><a href="#v:reset">reset</a> ::  <a href="Control-Delimited.html#t:Delim">Delim</a> s t s -&gt; <a href="Control-Delimited.html#t:Delim">Delim</a> s' s' t</li><li class="src short"><a href="#v:shift0">shift0</a> ::  ((b -&gt; s) -&gt; t) -&gt; <a href="Control-Delimited.html#t:Delim">Delim</a> s t b</li><li class="src short"><a href="#v:shift1">shift1</a> ::  ((b -&gt; s) -&gt; <a href="Control-Delimited.html#t:Delim">Delim</a> a t a) -&gt; <a href="Control-Delimited.html#t:Delim">Delim</a> s t b</li><li class="src short"><a href="#v:shift2">shift2</a> ::  ((b -&gt; <span class="keyword">forall</span> a'.  <a href="Control-Delimited.html#t:Delim">Delim</a> a' a' s) -&gt; <a href="Control-Delimited.html#t:Delim">Delim</a> a t a) -&gt; <a href="Control-Delimited.html#t:Delim">Delim</a> s t b</li><li class="src short"><a href="#v:runDelim">runDelim</a> ::  <a href="Control-Delimited.html#t:Delim">Delim</a> t t t -&gt; t</li><li class="src short">module <a href="Control-Indexed-Monad.html">Control.Indexed.Monad</a></li></ul></div><div id="interface"><h1 id="g:1">Delimited continuations
+</h1><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:Delim" class="def">Delim</a> s t b <a href="src/Control-Delimited.html#Delim" class="link">Source</a></p><div class="doc"><p>The type of a delimited continuation, which is answer-type polymorphic.
+</p><p>Functions of type <code>a -&gt; <code><a href="Control-Delimited.html#t:Delim">Delim</a></code> s t b</code> can be thought of as
+ functions of type <code>a / s -&gt; b / t</code>, which means given an <code>a</code> we
+ return a <code>b</code>, changing the <em>answer type</em> of the continuation from
+ <code>s</code> to <code>t</code>.
+</p><p>If a <code><a href="Control-Delimited.html#t:Delim">Delim</a></code> does not capture the computation using one of the
+ various <code>shift</code> operators (or <code>shift</code> does not change the answer
+ type,) then the term is <em>polymorphic</em> in the answer type.
+</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>:t runDelim $ reset $ shift2 ret !&gt;&gt;= \r -&gt; ret (r + (1 :: Int))
+</code></strong>runDelim $ reset $ shift2 ret !&gt;&gt;= \r -&gt; ret (r + (1 :: Int))
+  :: Int -&gt; forall a'. Delim a' a' Int
+</pre><p>Note how the quantified variable <code>a'</code> is both the input and output
+ answer type: thus, it cannot change from what is (in this case, the
+ answer type of the enclosing <code><a href="Control-Delimited.html#v:reset">reset</a></code> is <code><a href="/usr/local/share/doc/ghc/html/libraries/base-4.6.0.0/Data-Int.html#t:Int">Int</a></code>.) We use <code><a href="Control-Delimited.html#v:shift2">shift2</a></code>
+ here, which uses rank-2 typing to ensure the type variable does not
+ 'escape', much like the <code>ST</code> monad.
+</p></div><div class="subs instances"><p id="control.i:Delim" class="caption collapser" onclick="toggleSection('i:Delim')">Instances</p><div id="section.i:Delim" class="show"><table><tr><td class="src"><a href="Control-Indexed-Monad.html#t:Monad-39-">Monad'</a> <a href="Control-Delimited.html#t:Delim">Delim</a></td><td class="doc"><p>Delimited continuations form a parameterized <code><a href="Control-Indexed-Monad.html#t:Monad-39-">Monad'</a></code>.
+</p></td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:reset" class="def">reset</a> ::  <a href="Control-Delimited.html#t:Delim">Delim</a> s t s -&gt; <a href="Control-Delimited.html#t:Delim">Delim</a> s' s' t<a href="src/Control-Delimited.html#reset" class="link">Source</a></p><div class="doc"><p>Delimit a computation.
+</p></div></div><h2 id="g:2">A family of shift operators
+</h2><div class="top"><p class="src"><a name="v:shift0" class="def">shift0</a> ::  ((b -&gt; s) -&gt; t) -&gt; <a href="Control-Delimited.html#t:Delim">Delim</a> s t b<a href="src/Control-Delimited.html#shift0" class="link">Source</a></p><div class="doc"><p>Clear the current continuation and invoke our handler with it
+ bound as a parameter.
+</p><p>This is the most pure definition of <code>shift</code>.
+</p></div></div><div class="top"><p class="src"><a name="v:shift1" class="def">shift1</a> ::  ((b -&gt; s) -&gt; <a href="Control-Delimited.html#t:Delim">Delim</a> a t a) -&gt; <a href="Control-Delimited.html#t:Delim">Delim</a> s t b<a href="src/Control-Delimited.html#shift1" class="link">Source</a></p><div class="doc"><p>Clear the current continuation and invoke our handler with it
+ bound as a parameter.
+</p><p>This is a simple Haskell98 definition of <code>shift</code> that does not enforce
+ true answer type polymorphism by abstracting over the internal <code>s</code> and
+ <code>t</code> type variables.
+</p></div></div><div class="top"><p class="src"><a name="v:shift2" class="def">shift2</a> ::  ((b -&gt; <span class="keyword">forall</span> a'.  <a href="Control-Delimited.html#t:Delim">Delim</a> a' a' s) -&gt; <a href="Control-Delimited.html#t:Delim">Delim</a> a t a) -&gt; <a href="Control-Delimited.html#t:Delim">Delim</a> s t b<a href="src/Control-Delimited.html#shift2" class="link">Source</a></p><div class="doc"><p>Clear the current continuation and invoke our handler with it
+ bound as a paramter.
+</p><p>This definition of <code>shift</code> uses Rank-2 types to ensure the answer
+ type is in fact polymorphic: note the type of the captured continuation
+ is of type <code>Delim t' t' s</code>.
+</p></div></div><h2 id="g:3">Executing delimited computations
+</h2><div class="top"><p class="src"><a name="v:runDelim" class="def">runDelim</a> ::  <a href="Control-Delimited.html#t:Delim">Delim</a> t t t -&gt; t<a href="src/Control-Delimited.html#runDelim" class="link">Source</a></p><div class="doc"><p>Run a delimited computation.
+</p></div></div><h1 id="g:4">Re-exports for convenience
+</h1><div class="top"><p class="src">module <a href="Control-Indexed-Monad.html">Control.Indexed.Monad</a></p></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.13.1</p></div></body></html>

File doc/Control-Indexed-Monad.html

View file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Control.Indexed.Monad</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
+window.onload = function () {pageLoad();setSynopsis("mini_Control-Indexed-Monad.html");};
+//]]>
+</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Control-Indexed-Monad.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">asai-0.0.0.0: A minimal library for delimited continuations.</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>portable</td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Maintainer</th><td>mad.one@gmail.com</td></tr><tr><th>Safe Haskell</th><td>Safe-Inferred</td></tr></table><p class="caption">Control.Indexed.Monad</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Parameterized monads
+</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Parameterized monads.
+</p><p>When using GHC with <code>RebindableSyntax</code>, it's possible to overload
+ regular <code>do</code>-notation to use the <code><a href="Control-Indexed-Monad.html#t:Monad-39-">Monad'</a></code> typeclass.
+</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">class</span>  <a href="#t:Monad-39-">Monad'</a> m  <span class="keyword">where</span><ul class="subs"><li><a href="#v:ret">ret</a> ::  t -&gt; m a a t</li><li><a href="#v:bind">bind</a> ::  m b g s -&gt; (s -&gt; m a b t) -&gt; m a g t</li></ul></li><li class="src short"><a href="#v:-33--62--62--61-">(!&gt;&gt;=)</a> :: <a href="Control-Indexed-Monad.html#t:Monad-39-">Monad'</a> m =&gt; m b g s -&gt; (s -&gt; m a b t) -&gt; m a g t</li><li class="src short"><a href="#v:-33--43--62--62-">(!+&gt;&gt;)</a> :: <a href="Control-Indexed-Monad.html#t:Monad-39-">Monad'</a> m =&gt; m b g s -&gt; m a b t -&gt; m a g t</li></ul></div><div id="interface"><h1 id="g:1">Parameterized monads
+</h1><div class="top"><p class="src"><span class="keyword">class</span>  <a name="t:Monad-39-" class="def">Monad'</a> m  <span class="keyword">where</span><a href="src/Control-Indexed-Monad.html#Monad%27" class="link">Source</a></p><div class="doc"><p>Parameterized monads.
+</p><p>Regular monads are automatically lifted into this class through a
+ (hidden) newtype constructor.
+</p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:ret" class="def">ret</a> ::  t -&gt; m a a t<a href="src/Control-Indexed-Monad.html#ret" class="link">Source</a></p><div class="doc"><p>Parameterized <code><a href="/usr/local/share/doc/ghc/html/libraries/base-4.6.0.0/Control-Monad.html#v:return">return</a></code>.
+</p></div><p class="src"><a name="v:bind" class="def">bind</a> ::  m b g s -&gt; (s -&gt; m a b t) -&gt; m a g t<a href="src/Control-Indexed-Monad.html#bind" class="link">Source</a></p><div class="doc"><p>Parameterized <code><a href="/usr/local/share/doc/ghc/html/libraries/base-4.6.0.0/Control-Monad.html#v:-62--62--61-">&gt;&gt;=</a></code>.
+</p></div></div><div class="subs instances"><p id="control.i:Monad-39-" class="caption collapser" onclick="toggleSection('i:Monad-39-')">Instances</p><div id="section.i:Monad-39-" class="show"><table><tr><td class="src"><a href="Control-Indexed-Monad.html#t:Monad-39-">Monad'</a> <a href="Control-Delimited.html#t:Delim">Delim</a></td><td class="doc"><p>Delimited continuations form a parameterized <code><a href="Control-Indexed-Monad.html#t:Monad-39-">Monad'</a></code>.
+</p></td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:-33--62--62--61-" class="def">(!&gt;&gt;=)</a> :: <a href="Control-Indexed-Monad.html#t:Monad-39-">Monad'</a> m =&gt; m b g s -&gt; (s -&gt; m a b t) -&gt; m a g t<a href="src/Control-Indexed-Monad.html#%21%3E%3E%3D" class="link">Source</a></p><div class="doc"><p>Infix synonym for <code><a href="Control-Indexed-Monad.html#v:bind">bind</a></code>.
+</p></div></div><div class="top"><p class="src"><a name="v:-33--43--62--62-" class="def">(!+&gt;&gt;)</a> :: <a href="Control-Indexed-Monad.html#t:Monad-39-">Monad'</a> m =&gt; m b g s -&gt; m a b t -&gt; m a g t<a href="src/Control-Indexed-Monad.html#%21%2B%3E%3E" class="link">Source</a></p><div class="doc"><p>Defined as:
+</p><pre>m1 !+&gt;&gt; m2 = bind m1 (const m2)</pre></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.13.1</p></div></body></html>

File doc/asai.haddock

Binary file added.

File doc/doc-index.html

View file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>asai-0.0.0.0: A minimal library for delimited continuations. (Index)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">asai-0.0.0.0: A minimal library for delimited continuations.</p></div><div id="content"><div id="index"><p class="caption">Index</p><table><tr><td class="src">!+&gt;&gt;</td><td class="module"><a href="Control-Indexed-Monad.html#v:-33--43--62--62-">Control.Indexed.Monad</a>, Control.Delimited</td></tr><tr><td class="src">!&gt;&gt;=</td><td class="module"><a href="Control-Indexed-Monad.html#v:-33--62--62--61-">Control.Indexed.Monad</a>, Control.Delimited</td></tr><tr><td class="src">bind</td><td class="module"><a href="Control-Indexed-Monad.html#v:bind">Control.Indexed.Monad</a>, Control.Delimited</td></tr><tr><td class="src">Delim</td><td class="module"><a href="Control-Delimited.html#t:Delim">Control.Delimited</a></td></tr><tr><td class="src">Monad'</td><td class="module"><a href="Control-Indexed-Monad.html#t:Monad-39-">Control.Indexed.Monad</a>, Control.Delimited</td></tr><tr><td class="src">reset</td><td class="module"><a href="Control-Delimited.html#v:reset">Control.Delimited</a></td></tr><tr><td class="src">ret</td><td class="module"><a href="Control-Indexed-Monad.html#v:ret">Control.Indexed.Monad</a>, Control.Delimited</td></tr><tr><td class="src">runDelim</td><td class="module"><a href="Control-Delimited.html#v:runDelim">Control.Delimited</a></td></tr><tr><td class="src">shift0</td><td class="module"><a href="Control-Delimited.html#v:shift0">Control.Delimited</a></td></tr><tr><td class="src">shift1</td><td class="module"><a href="Control-Delimited.html#v:shift1">Control.Delimited</a></td></tr><tr><td class="src">shift2</td><td class="module"><a href="Control-Delimited.html#v:shift2">Control.Delimited</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.13.1</p></div></body></html>

File doc/frames.html

View file
+<!DOCTYPE html 
+     PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
+     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title></title>
+<script src="haddock-util.js" type="text/javascript"></script>
+<script type="text/javascript"><!--
+/*
+
+  The synopsis frame needs to be updated using javascript, so we hide
+  it by default and only show it if javascript is enabled.
+
+  TODO: provide some means to disable it.
+*/
+function load() {
+  var d = document.getElementById("inner-fs");
+  d.rows = "50%,50%";
+  postReframe();
+}
+--></script>
+</head>
+<frameset id="outer-fs" cols="25%,75%" onload="load()">
+  <frameset id="inner-fs" rows="100%,0%">
+    <frame src="index-frames.html" name="modules" />
+    <frame src="" name="synopsis" />
+  </frameset>
+  <frame src="index.html" name="main" />
+</frameset>
+</html>

File doc/haddock-util.js

View file
+// Haddock JavaScript utilities
+
+var rspace = /\s\s+/g,
+	  rtrim = /^\s+|\s+$/g;
+
+function spaced(s) { return (" " + s + " ").replace(rspace, " "); }
+function trim(s)   { return s.replace(rtrim, ""); }
+
+function hasClass(elem, value) {
+  var className = spaced(elem.className || "");
+  return className.indexOf( " " + value + " " ) >= 0;
+}
+
+function addClass(elem, value) {
+  var className = spaced(elem.className || "");
+  if ( className.indexOf( " " + value + " " ) < 0 ) {
+    elem.className = trim(className + " " + value);
+  }
+}
+
+function removeClass(elem, value) {
+  var className = spaced(elem.className || "");
+  className = className.replace(" " + value + " ", " ");
+  elem.className = trim(className);
+}
+
+function toggleClass(elem, valueOn, valueOff, bool) {
+  if (bool == null) { bool = ! hasClass(elem, valueOn); }
+  if (bool) {
+    removeClass(elem, valueOff);
+    addClass(elem, valueOn);
+  }
+  else {
+    removeClass(elem, valueOn);
+    addClass(elem, valueOff);
+  }
+  return bool;
+}
+
+
+function makeClassToggle(valueOn, valueOff)
+{
+  return function(elem, bool) {
+    return toggleClass(elem, valueOn, valueOff, bool);
+  }
+}
+
+toggleShow = makeClassToggle("show", "hide");
+toggleCollapser = makeClassToggle("collapser", "expander");
+
+function toggleSection(id)
+{
+  var b = toggleShow(document.getElementById("section." + id));
+  toggleCollapser(document.getElementById("control." + id), b);
+  rememberCollapsed(id, b);
+  return b;
+}
+
+var collapsed = {};
+function rememberCollapsed(id, b)
+{
+  if(b)
+    delete collapsed[id]
+  else
+    collapsed[id] = null;
+
+  var sections = [];
+  for(var i in collapsed)
+  {
+    if(collapsed.hasOwnProperty(i))
+      sections.push(i);
+  }
+  // cookie specific to this page; don't use setCookie which sets path=/
+  document.cookie = "collapsed=" + escape(sections.join('+'));
+}
+
+function restoreCollapsed()
+{
+  var cookie = getCookie("collapsed");
+  if(!cookie)
+    return;
+
+  var ids = cookie.split('+');
+  for(var i in ids)
+  {
+    if(document.getElementById("section." + ids[i]))
+      toggleSection(ids[i]);
+  }
+}
+
+function setCookie(name, value) {
+  document.cookie = name + "=" + escape(value) + ";path=/;";
+}
+
+function clearCookie(name) {
+  document.cookie = name + "=;path=/;expires=Thu, 01-Jan-1970 00:00:01 GMT;";
+}
+
+function getCookie(name) {
+  var nameEQ = name + "=";
+  var ca = document.cookie.split(';');
+  for(var i=0;i < ca.length;i++) {
+    var c = ca[i];
+    while (c.charAt(0)==' ') c = c.substring(1,c.length);
+    if (c.indexOf(nameEQ) == 0) {
+      return unescape(c.substring(nameEQ.length,c.length));
+    }
+  }
+  return null;
+}
+
+
+
+var max_results = 75; // 50 is not enough to search for map in the base libraries
+var shown_range = null;
+var last_search = null;
+
+function quick_search()
+{
+    perform_search(false);
+}
+
+function full_search()
+{
+    perform_search(true);
+}
+
+
+function perform_search(full)
+{
+    var text = document.getElementById("searchbox").value.toLowerCase();
+    if (text == last_search && !full) return;
+    last_search = text;
+    
+    var table = document.getElementById("indexlist");
+    var status = document.getElementById("searchmsg");
+    var children = table.firstChild.childNodes;
+    
+    // first figure out the first node with the prefix
+    var first = bisect(-1);
+    var last = (first == -1 ? -1 : bisect(1));
+
+    if (first == -1)
+    {
+        table.className = "";
+        status.innerHTML = "No results found, displaying all";
+    }
+    else if (first == 0 && last == children.length - 1)
+    {
+        table.className = "";
+        status.innerHTML = "";
+    }
+    else if (last - first >= max_results && !full)
+    {
+        table.className = "";
+        status.innerHTML = "More than " + max_results + ", press Search to display";
+    }
+    else
+    {
+        // decide what you need to clear/show
+        if (shown_range)
+            setclass(shown_range[0], shown_range[1], "indexrow");
+        setclass(first, last, "indexshow");
+        shown_range = [first, last];
+        table.className = "indexsearch";
+        status.innerHTML = "";
+    }
+
+    
+    function setclass(first, last, status)
+    {
+        for (var i = first; i <= last; i++)
+        {
+            children[i].className = status;
+        }
+    }
+    
+    
+    // do a binary search, treating 0 as ...
+    // return either -1 (no 0's found) or location of most far match
+    function bisect(dir)
+    {
+        var first = 0, finish = children.length - 1;
+        var mid, success = false;
+
+        while (finish - first > 3)
+        {
+            mid = Math.floor((finish + first) / 2);
+
+            var i = checkitem(mid);
+            if (i == 0) i = dir;
+            if (i == -1)
+                finish = mid;
+            else
+                first = mid;
+        }
+        var a = (dir == 1 ? first : finish);
+        var b = (dir == 1 ? finish : first);
+        for (var i = b; i != a - dir; i -= dir)
+        {
+            if (checkitem(i) == 0) return i;
+        }
+        return -1;
+    }    
+    
+    
+    // from an index, decide what the result is
+    // 0 = match, -1 is lower, 1 is higher
+    function checkitem(i)
+    {
+        var s = getitem(i).toLowerCase().substr(0, text.length);
+        if (s == text) return 0;
+        else return (s > text ? -1 : 1);
+    }
+    
+    
+    // from an index, get its string
+    // this abstracts over alternates
+    function getitem(i)
+    {
+        for ( ; i >= 0; i--)
+        {
+            var s = children[i].firstChild.firstChild.data;
+            if (s.indexOf(' ') == -1)
+                return s;
+        }
+        return ""; // should never be reached
+    }
+}
+
+function setSynopsis(filename) {
+    if (parent.window.synopsis) {
+        if (parent.window.synopsis.location.replace) {
+            // In Firefox this avoids adding the change to the history.
+            parent.window.synopsis.location.replace(filename);
+        } else {
+            parent.window.synopsis.location = filename;
+        }
+    }
+}
+
+function addMenuItem(html) {
+  var menu = document.getElementById("page-menu");
+  if (menu) {
+    var btn = menu.firstChild.cloneNode(false);
+    btn.innerHTML = html;
+    menu.appendChild(btn);
+  }
+}
+
+function adjustForFrames() {
+  var bodyCls;
+  
+  if (parent.location.href == window.location.href) {
+    // not in frames, so add Frames button
+    addMenuItem("<a href='#' onclick='reframe();return true;'>Frames</a>");
+    bodyCls = "no-frame";
+  }
+  else {
+    bodyCls = "in-frame";
+  }
+  addClass(document.body, bodyCls);
+}
+
+function reframe() {
+  setCookie("haddock-reframe", document.URL);
+  window.location = "frames.html";
+}
+
+function postReframe() {
+  var s = getCookie("haddock-reframe");
+  if (s) {
+    parent.window.main.location = s;
+    clearCookie("haddock-reframe");
+  }
+}
+
+function styles() {
+  var i, a, es = document.getElementsByTagName("link"), rs = [];
+  for (i = 0; a = es[i]; i++) {
+    if(a.rel.indexOf("style") != -1 && a.title) {
+      rs.push(a);
+    }
+  }
+  return rs;
+}
+
+function addStyleMenu() {
+  var as = styles();
+  var i, a, btns = "";
+  for(i=0; a = as[i]; i++) {
+    btns += "<li><a href='#' onclick=\"setActiveStyleSheet('"
+      + a.title + "'); return false;\">"
+      + a.title + "</a></li>"
+  }
+  if (as.length > 1) {
+    var h = "<div id='style-menu-holder'>"
+      + "<a href='#' onclick='styleMenu(); return false;'>Style &#9662;</a>"
+      + "<ul id='style-menu' class='hide'>" + btns + "</ul>"
+      + "</div>";
+    addMenuItem(h);
+  }
+}
+
+function setActiveStyleSheet(title) {
+  var as = styles();
+  var i, a, found;
+  for(i=0; a = as[i]; i++) {
+    a.disabled = true;
+          // need to do this always, some browsers are edge triggered
+    if(a.title == title) {
+      found = a;
+    }
+  }
+  if (found) {
+    found.disabled = false;
+    setCookie("haddock-style", title);
+  }
+  else {
+    as[0].disabled = false;
+    clearCookie("haddock-style");
+  }
+  styleMenu(false);
+}
+
+function resetStyle() {
+  var s = getCookie("haddock-style");
+  if (s) setActiveStyleSheet(s);
+}
+
+
+function styleMenu(show) {
+  var m = document.getElementById('style-menu');
+  if (m) toggleShow(m, show);
+}
+
+
+function pageLoad() {
+  addStyleMenu();
+  adjustForFrames();
+  resetStyle();
+  restoreCollapsed();
+}
+

File doc/hslogo-16.png

Added
New image

File doc/index-frames.html

View file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>asai-0.0.0.0: A minimal library for delimited continuations.</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script></head><body id="mini"><div id="module-list"><p class="caption">Modules</p><ul><li class="module"><a href="Control-Delimited.html" target="main">Control.Delimited</a></li><li class="module"><a href="Control-Delimited-Tutorial.html" target="main">Control.Delimited.Tutorial</a></li><li class="module"><a href="Control-Indexed-Monad.html" target="main">Control.Indexed.Monad</a></li></ul></div></body></html>

File doc/index.html

View file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>asai-0.0.0.0: A minimal library for delimited continuations.</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">asai-0.0.0.0: A minimal library for delimited continuations.</p></div><div id="content"><div id="description"><h1>asai-0.0.0.0: A minimal library for delimited continuations.</h1><div class="doc"><p>&quot;Genuine shift/reset in Haskell.&quot; This tiny library provides a
+monadic interface for delimited continuations with <em>answer type</em>
+<em>polymorphism</em>.  It is the work of Oleg Kiselyov, and is named in
+honor of Kenichi Asai.
+</p><p>To use this library, you should import <a href="Control-Delimited.html">Control.Delimited</a>.
+</p><p>See <a href="Control-Delimited-Tutorial.html">Control.Delimited.Tutorial</a> for a lengthy reference.
+</p></div></div><div id="module-list"><p class="caption">Modules</p><ul><li><span id="control.n.1" class="module collapser" onclick="toggleSection('n.1')">Control</span><ul id="section.n.1" class="show"><li><span class="module"><span id="control.n.1.1" class="collapser" onclick="toggleSection('n.1.1')">&nbsp;</span><a href="Control-Delimited.html">Control.Delimited</a></span><ul id="section.n.1.1" class="show"><li><span class="module"><a href="Control-Delimited-Tutorial.html">Control.Delimited.Tutorial</a></span></li></ul></li><li><span id="control.n.1.2" class="module collapser" onclick="toggleSection('n.1.2')">Indexed</span><ul id="section.n.1.2" class="show"><li><span class="module"><a href="Control-Indexed-Monad.html">Control.Indexed.Monad</a></span></li></ul></li></ul></li></ul></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.13.1</p></div></body></html>

File doc/mini_Control-Delimited-Tutorial.html

View file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Control.Delimited.Tutorial</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script></head><body id="mini"><div id="module-header"><p class="caption">Control.Delimited.Tutorial</p></div><div id="interface"><h1>Introduction
+</h1><h1>Notes on <code>do</code>-notation
+</h1><h1>References
+</h1></div></body></html>

File doc/mini_Control-Delimited.html

View file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Control.Delimited</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script></head><body id="mini"><div id="module-header"><p class="caption">Control.Delimited</p></div><div id="interface"><h1>Delimited continuations
+</h1><div class="top"><p class="src"><span class="keyword">data</span> <a href="Control-Delimited.html#t:Delim" target="main">Delim</a> s t b</p></div><div class="top"><p class="src"><a href="Control-Delimited.html#v:reset" target="main">reset</a></p></div><h2>A family of shift operators
+</h2><div class="top"><p class="src"><a href="Control-Delimited.html#v:shift0" target="main">shift0</a></p></div><div class="top"><p class="src"><a href="Control-Delimited.html#v:shift1" target="main">shift1</a></p></div><div class="top"><p class="src"><a href="Control-Delimited.html#v:shift2" target="main">shift2</a></p></div><h2>Executing delimited computations
+</h2><div class="top"><p class="src"><a href="Control-Delimited.html#v:runDelim" target="main">runDelim</a></p></div><h1>Re-exports for convenience
+</h1></div></body></html>

File doc/mini_Control-Indexed-Monad.html

View file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Control.Indexed.Monad</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script></head><body id="mini"><div id="module-header"><p class="caption">Control.Indexed.Monad</p></div><div id="interface"><h1>Parameterized monads
+</h1><div class="top"><p class="src"><span class="keyword">class</span> <a href="Control-Indexed-Monad.html#t:Monad-39-" target="main">Monad'</a> m</p></div><div class="top"><p class="src"><a href="Control-Indexed-Monad.html#v:-33--62--62--61-" target="main">(!&gt;&gt;=)</a></p></div><div class="top"><p class="src"><a href="Control-Indexed-Monad.html#v:-33--43--62--62-" target="main">(!+&gt;&gt;)</a></p></div></div></body></html>

File doc/minus.gif

Added
New image

File doc/ocean.css

View file
+/* @group Fundamentals */
+
+* { margin: 0; padding: 0 }
+
+/* Is this portable? */
+html {
+  background-color: white;
+  width: 100%;
+  height: 100%;
+}
+
+body {
+  background: white;
+  color: black;
+  text-align: left;
+  min-height: 100%;
+  position: relative;
+}
+
+p {
+  margin: 0.8em 0;
+}
+
+ul, ol {
+  margin: 0.8em 0 0.8em 2em;
+}
+
+dl {
+  margin: 0.8em 0;
+}
+
+dt {
+  font-weight: bold;
+}
+dd {
+  margin-left: 2em;
+}
+
+a { text-decoration: none; }
+a[href]:link { color: rgb(196,69,29); }
+a[href]:visited { color: rgb(171,105,84); }
+a[href]:hover { text-decoration:underline; }
+
+/* @end */
+
+/* @group Fonts & Sizes */
+
+/* Basic technique & IE workarounds from YUI 3
+   For reasons, see:
+      http://yui.yahooapis.com/3.1.1/build/cssfonts/fonts.css
+ */
+ 
+body {
+	font:13px/1.4 sans-serif;
+	*font-size:small; /* for IE */
+	*font:x-small; /* for IE in quirks mode */
+}
+
+h1 { font-size: 146.5%; /* 19pt */ } 
+h2 { font-size: 131%;   /* 17pt */ }
+h3 { font-size: 116%;   /* 15pt */ }
+h4 { font-size: 100%;   /* 13pt */ }
+h5 { font-size: 100%;   /* 13pt */ }
+
+select, input, button, textarea {
+	font:99% sans-serif;
+}
+
+table {
+	font-size:inherit;
+	font:100%;
+}
+
+pre, code, kbd, samp, tt, .src {
+	font-family:monospace;
+	*font-size:108%;
+	line-height: 124%;
+}
+
+.links, .link {
+  font-size: 85%; /* 11pt */
+}
+
+#module-header .caption {
+  font-size: 182%; /* 24pt */
+}
+
+.info  {
+  font-size: 85%; /* 11pt */
+}
+
+#table-of-contents, #synopsis  {
+  /* font-size: 85%; /* 11pt */
+}
+
+
+/* @end */
+
+/* @group Common */
+
+.caption, h1, h2, h3, h4, h5, h6 { 
+  font-weight: bold;
+  color: rgb(78,98,114);
+  margin: 0.8em 0 0.4em;
+}
+
+* + h1, * + h2, * + h3, * + h4, * + h5, * + h6 {
+  margin-top: 2em;
+}
+
+h1 + h2, h2 + h3, h3 + h4, h4 + h5, h5 + h6 {
+  margin-top: inherit;
+}
+
+ul.links {
+  list-style: none;
+  text-align: left;
+  float: right;
+  display: inline-table;
+  margin: 0 0 0 1em;
+}
+
+ul.links li {
+  display: inline;
+  border-left: 1px solid #d5d5d5; 
+  white-space: nowrap;
+  padding: 0;
+}
+
+ul.links li a {
+  padding: 0.2em 0.5em;
+}
+
+.hide { display: none; }
+.show { display: inherit; }
+.clear { clear: both; }
+
+.collapser {
+  background-image: url(minus.gif);
+  background-repeat: no-repeat;
+}
+.expander {
+  background-image: url(plus.gif);
+  background-repeat: no-repeat;
+}
+p.caption.collapser,
+p.caption.expander {
+  background-position: 0 0.4em;
+}
+.collapser, .expander {
+  padding-left: 14px;
+  margin-left: -14px;
+  cursor: pointer;
+}
+
+pre {
+  padding: 0.25em;
+  margin: 0.8em 0;
+  background: rgb(229,237,244);
+  overflow: auto;
+  border-bottom: 0.25em solid white;
+  /* white border adds some space below the box to compensate
+     for visual extra space that paragraphs have between baseline
+     and the bounding box */
+}
+
+.src {
+  background: #f0f0f0;
+  padding: 0.2em 0.5em;
+}
+
+.keyword { font-weight: normal; }
+.def { font-weight: bold; }
+
+
+/* @end */
+
+/* @group Page Structure */
+
+#content {
+  margin: 0 auto;
+  padding: 0 2em 6em;
+}
+
+#package-header {
+  background: rgb(41,56,69);
+  border-top: 5px solid rgb(78,98,114);
+  color: #ddd;
+  padding: 0.2em;
+  position: relative;
+  text-align: left;
+}
+
+#package-header .caption {
+  background: url(hslogo-16.png) no-repeat 0em;
+  color: white;
+  margin: 0 2em;
+  font-weight: normal;
+  font-style: normal;
+  padding-left: 2em;
+}
+
+#package-header a:link, #package-header a:visited { color: white; }
+#package-header a:hover { background: rgb(78,98,114); }
+
+#module-header .caption {
+  color: rgb(78,98,114);
+  font-weight: bold;
+  border-bottom: 1px solid #ddd;
+}
+
+table.info {
+  float: right;
+  padding: 0.5em 1em;
+  border: 1px solid #ddd;
+  color: rgb(78,98,114);
+  background-color: #fff;
+  max-width: 40%;
+  border-spacing: 0;
+  position: relative;
+  top: -0.5em;
+  margin: 0 0 0 2em;
+}
+
+.info th {
+	padding: 0 1em 0 0;
+}
+
+div#style-menu-holder {
+  position: relative;
+  z-index: 2;
+  display: inline;
+}
+
+#style-menu {
+  position: absolute;
+  z-index: 1;
+  overflow: visible;
+  background: #374c5e;
+  margin: 0;
+  text-align: center;
+  right: 0;
+  padding: 0;
+  top: 1.25em;
+}
+
+#style-menu li {
+	display: list-item;
+	border-style: none;
+	margin: 0;
+	padding: 0;
+	color: #000;
+	list-style-type: none;
+}
+
+#style-menu li + li {
+	border-top: 1px solid #919191;
+}
+
+#style-menu a {
+  width: 6em;
+  padding: 3px;
+  display: block;
+}
+
+#footer {
+  background: #ddd;
+  border-top: 1px solid #aaa;
+  padding: 0.5em 0;
+  color: #666;
+  text-align: center;
+  position: absolute;
+  bottom: 0;
+  width: 100%;
+  height: 3em;
+}
+
+/* @end */
+
+/* @group Front Matter */
+
+#table-of-contents {
+  float: right;
+  clear: right;
+  background: #faf9dc;
+  border: 1px solid #d8d7ad;
+  padding: 0.5em 1em;
+  max-width: 20em;
+  margin: 0.5em 0 1em 1em;
+}
+
+#table-of-contents .caption {
+  text-align: center;
+  margin: 0;
+}
+
+#table-of-contents ul {
+  list-style: none;
+  margin: 0;
+}
+
+#table-of-contents ul ul {
+  margin-left: 2em;
+}
+
+#description .caption {
+  display: none;
+}
+
+#synopsis {
+  display: none;
+}
+
+.no-frame #synopsis {
+  display: block;
+  position: fixed;
+  right: 0;
+  height: 80%;
+  top: 10%;
+  padding: 0;
+}
+
+#synopsis .caption {
+  float: left;
+  width: 29px;
+  color: rgba(255,255,255,0);
+  height: 110px;
+  margin: 0;
+  font-size: 1px;
+  padding: 0;
+}
+
+#synopsis p.caption.collapser {
+  background: url(synopsis.png) no-repeat -64px -8px;
+}
+
+#synopsis p.caption.expander {
+  background: url(synopsis.png) no-repeat 0px -8px;
+}
+
+#synopsis ul {
+  height: 100%;
+  overflow: auto;
+  padding: 0.5em;
+  margin: 0;
+}
+
+#synopsis ul ul {
+  overflow: hidden;
+}
+
+#synopsis ul,
+#synopsis ul li.src {
+  background-color: #faf9dc;
+  white-space: nowrap;
+  list-style: none;
+  margin-left: 0;
+}
+
+/* @end */
+
+/* @group Main Content */
+
+#interface div.top { margin: 2em 0; }
+#interface h1 + div.top,
+#interface h2 + div.top,
+#interface h3 + div.top,
+#interface h4 + div.top,
+#interface h5 + div.top {
+ 	margin-top: 1em;
+}
+#interface p.src .link {
+  float: right;
+  color: #919191;
+  border-left: 1px solid #919191;
+  background: #f0f0f0;
+  padding: 0 0.5em 0.2em;
+  margin: 0 -0.5em 0 0.5em;
+}
+
+#interface table { border-spacing: 2px; }
+#interface td {
+  vertical-align: top;
+  padding-left: 0.5em;
+}
+#interface td.src {
+  white-space: nowrap;
+}
+#interface td.doc p {
+  margin: 0;
+}
+#interface td.doc p + p {
+  margin-top: 0.8em;
+}
+
+.subs dl {
+  margin: 0;
+}
+
+.subs dt {
+  float: left;
+  clear: left;
+  display: block;
+  margin: 1px 0;
+}
+
+.subs dd {
+  float: right;
+  width: 90%;
+  display: block;
+  padding-left: 0.5em;
+  margin-bottom: 0.5em;
+}
+
+.subs dd.empty {
+  display: none;
+}
+
+.subs dd p {
+  margin: 0;
+}
+
+.top p.src {
+  border-top: 1px solid #ccc;
+}
+
+.subs, .doc {
+  /* use this selector for one level of indent */
+  padding-left: 2em;
+}
+
+.warning {
+  color: red;
+}
+
+.arguments {
+  margin-top: -0.4em;
+}
+.arguments .caption {
+  display: none;
+}
+
+.fields { padding-left: 1em; }
+
+.fields .caption { display: none; }
+
+.fields p { margin: 0 0; }
+
+/* this seems bulky to me
+.methods, .constructors {
+  background: #f8f8f8;
+  border: 1px solid #eee;
+}
+*/
+
+/* @end */
+
+/* @group Auxillary Pages */
+
+#mini {
+  margin: 0 auto;
+  padding: 0 1em 1em;
+}
+
+#mini > * {
+  font-size: 93%; /* 12pt */  
+}
+
+#mini #module-list .caption,
+#mini #module-header .caption {
+  font-size: 125%; /* 15pt */
+}
+
+#mini #interface h1,
+#mini #interface h2,
+#mini #interface h3,
+#mini #interface h4 {
+  font-size: 109%; /* 13pt */
+  margin: 1em 0 0;
+}
+
+#mini #interface .top,
+#mini #interface .src {
+  margin: 0;
+}
+
+#mini #module-list ul {
+  list-style: none;
+  margin: 0;
+}
+
+#alphabet ul {
+	list-style: none;
+	padding: 0;
+	margin: 0.5em 0 0;
+	text-align: center;
+}
+
+#alphabet li {
+	display: inline;
+	margin: 0 0.25em;
+}
+
+#alphabet a {
+	font-weight: bold;
+}
+
+#index .caption,
+#module-list .caption { font-size: 131%; /* 17pt */ }
+
+#index table {
+  margin-left: 2em;
+}
+
+#index .src {
+  font-weight: bold;
+}
+#index .alt {
+  font-size: 77%; /* 10pt */
+  font-style: italic;
+  padding-left: 2em;
+}
+
+#index td + td {
+  padding-left: 1em;
+}
+
+#module-list ul {
+  list-style: none;
+  margin: 0 0 0 2em;
+}
+
+#module-list li {
+  clear: right;
+}
+
+#module-list span.collapser,
+#module-list span.expander {
+  background-position: 0 0.3em;
+}
+
+#module-list .package {
+  float: right;
+}
+
+/* @end */

File doc/plus.gif

Added
New image

File doc/src/Control-Delimited-Tutorial.html

View file
+<?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>
+<head>
+<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
+<title>src/Control/Delimited/Tutorial.hs</title>
+<link type='text/css' rel='stylesheet' href='hscolour.css' />
+</head>
+<body>
+<pre><a name="line-1"></a><span class='hs-comment'>{-# OPTIONS_GHC -w #-}</span>
+<a name="line-2"></a><span class='hs-comment'>{-# LANGUAGE RebindableSyntax #-}</span>
+<a name="line-3"></a><span class='hs-comment'>-- |</span>
+<a name="line-4"></a><span class='hs-comment'>-- Module      : Control.Delimited.Tutorial</span>
+<a name="line-5"></a><span class='hs-comment'>-- Copyright   : (c) Oleg Kiselyov 2007-2012, (c) Austin Seipp 2012</span>
+<a name="line-6"></a><span class='hs-comment'>-- License     : MIT</span>
+<a name="line-7"></a><span class='hs-comment'>--</span>
+<a name="line-8"></a><span class='hs-comment'>-- Maintainer  : mad.one@gmail.com</span>
+<a name="line-9"></a><span class='hs-comment'>-- Stability   : experimental</span>
+<a name="line-10"></a><span class='hs-comment'>-- Portability : portable</span>
+<a name="line-11"></a><span class='hs-comment'>--</span>
+<a name="line-12"></a><span class='hs-comment'>-- This module provides a brief introductory tutorial in the</span>
+<a name="line-13"></a><span class='hs-comment'>-- \"Introduction\" section, followed by some discussion behind the</span>
+<a name="line-14"></a><span class='hs-comment'>-- theory of the library with references.</span>
+<a name="line-15"></a><span class='hs-comment'>--</span>
+<a name="line-16"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Delimited</span><span class='hs-varop'>.</span><span class='hs-conid'>Tutorial</span>
+<a name="line-17"></a>       <span class='hs-layout'>(</span> <span class='hs-comment'>-- * Introduction</span>
+<a name="line-18"></a>         <span class='hs-comment'>-- $intro</span>
+<a name="line-19"></a>
+<a name="line-20"></a>         <span class='hs-comment'>-- * Notes on @do@-notation</span>
+<a name="line-21"></a>         <span class='hs-comment'>-- $donotation</span>
+<a name="line-22"></a>
+<a name="line-23"></a>         <span class='hs-comment'>-- * References</span>
+<a name="line-24"></a>         <span class='hs-comment'>-- $refs</span>
+<a name="line-25"></a>       <span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
+<a name="line-26"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Prelude</span> <span class='hs-varid'>hiding</span> <span class='hs-layout'>(</span><span class='hs-varid'>return</span><span class='hs-layout'>,</span> <span class='hs-varid'>fail</span><span class='hs-layout'>,</span> <span class='hs-layout'>(</span><span class='hs-varop'>&gt;&gt;=</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-layout'>(</span><span class='hs-varop'>=&lt;&lt;</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
+<a name="line-27"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Delimited</span>
+<a name="line-28"></a>
+<a name="line-29"></a><span class='hs-comment'>--</span>
+<a name="line-30"></a><span class='hs-comment'>-- Aspects of RebindableSyntax</span>
+<a name="line-31"></a><span class='hs-comment'>--</span>
+<a name="line-32"></a>
+<a name="line-33"></a><a name="%3e%3e="></a><span class='hs-definition'>m</span> <span class='hs-varop'>&gt;&gt;=</span> <span class='hs-varid'>f</span>  <span class='hs-keyglyph'>=</span> <span class='hs-varid'>m</span> <span class='hs-varop'>!&gt;&gt;=</span> <span class='hs-varid'>f</span>
+<a name="line-34"></a><a name="return"></a><span class='hs-definition'>return</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>ret</span> <span class='hs-varid'>x</span>
+<a name="line-35"></a><a name="fail"></a><span class='hs-definition'>fail</span> <span class='hs-varid'>x</span>   <span class='hs-keyglyph'>=</span> <span class='hs-varid'>error</span> <span class='hs-varid'>x</span>
+<a name="line-36"></a><a name="=%3c%3c"></a><span class='hs-definition'>f</span> <span class='hs-varop'>=&lt;&lt;</span> <span class='hs-varid'>m</span>  <span class='hs-keyglyph'>=</span> <span class='hs-varid'>m</span> <span class='hs-varop'>!&gt;&gt;=</span> <span class='hs-varid'>f</span>
+<a name="line-37"></a>
+<a name="line-38"></a><span class='hs-comment'>{- $intro
+<a name="line-39"></a>
+<a name="line-40"></a>Lorem ipsum...
+<a name="line-41"></a>
+<a name="line-42"></a>&gt;&gt;&gt; runDelim $ reset $ (shift1 (\_ -&gt; return "hello") &gt;&gt;= \r -&gt; return (r + 1))
+<a name="line-43"></a>"hello"
+<a name="line-44"></a>
+<a name="line-45"></a>-}</span>
+<a name="line-46"></a>
+<a name="line-47"></a><span class='hs-comment'>{- $donotation
+<a name="line-48"></a>
+<a name="line-49"></a>Lorem ipsum...
+<a name="line-50"></a>
+<a name="line-51"></a>-}</span>
+<a name="line-52"></a>
+<a name="line-53"></a><span class='hs-comment'>{- $refs
+<a name="line-54"></a>
+<a name="line-55"></a>  * /Polymorphic Delimited Continuations/, by Asai, Kameyama in /APLAS '07/:
+<a name="line-56"></a>    &lt;<a href="http://logic.cs.tsukuba.ac.jp/~kam/paper/aplas07.pdf">http://logic.cs.tsukuba.ac.jp/~kam/paper/aplas07.pdf</a>&gt;
+<a name="line-57"></a>
+<a name="line-58"></a>  * /Genuine shift\reset in Haskell98/, by Kiselyov, on /haskell-cafe/:
+<a name="line-59"></a>    &lt;<a href="http://okmij.org/ftp/continuations/implementations.html#genuine-shift">http://okmij.org/ftp/continuations/implementations.html#genuine-shift</a>&gt;
+<a name="line-60"></a>
+<a name="line-61"></a>  * /Introduction to programming with shift and reset/, by Kiselyov, Asai, in /CW2011/:
+<a name="line-62"></a>    &lt;<a href="http://okmij.org/ftp/continuations/index.html#tutorial">http://okmij.org/ftp/continuations/index.html#tutorial</a>&gt;
+<a name="line-63"></a>
+<a name="line-64"></a>-}</span>
+</pre></body>
+</html>

File doc/src/Control-Delimited.html

View file
+<?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>
+<head>
+<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
+<title>src/Control/Delimited.hs</title>
+<link type='text/css' rel='stylesheet' href='hscolour.css' />
+</head>
+<body>
+<pre><a name="line-1"></a><span class='hs-comment'>{-# LANGUAGE RankNTypes #-}</span>
+<a name="line-2"></a><span class='hs-comment'>-- |</span>
+<a name="line-3"></a><span class='hs-comment'>-- Module      : Control.Delimited</span>
+<a name="line-4"></a><span class='hs-comment'>-- Copyright   : (c) Oleg Kiselyov 2007-2012, (c) Austin Seipp 2012</span>
+<a name="line-5"></a><span class='hs-comment'>-- License     : MIT</span>
+<a name="line-6"></a><span class='hs-comment'>--</span>
+<a name="line-7"></a><span class='hs-comment'>-- Maintainer  : mad.one@gmail.com</span>
+<a name="line-8"></a><span class='hs-comment'>-- Stability   : experimental</span>
+<a name="line-9"></a><span class='hs-comment'>-- Portability : Rank-2 types required</span>
+<a name="line-10"></a><span class='hs-comment'>--</span>
+<a name="line-11"></a><span class='hs-comment'>-- Delimited continuations featuring answer-type polymorphism, via</span>
+<a name="line-12"></a><span class='hs-comment'>-- parameterized monads.</span>
+<a name="line-13"></a><span class='hs-comment'>--</span>
+<a name="line-14"></a><span class='hs-comment'>-- There is a tutorial available in "Control.Delimited.Tutorial".</span>
+<a name="line-15"></a><span class='hs-comment'>--</span>
+<a name="line-16"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Delimited</span>
+<a name="line-17"></a>       <span class='hs-layout'>(</span> <span class='hs-comment'>-- * Delimited continuations</span>
+<a name="line-18"></a>         <span class='hs-conid'>Delim</span>     <span class='hs-comment'>-- :: * -&gt; * -&gt; * -&gt; *</span>
+<a name="line-19"></a>       <span class='hs-layout'>,</span> <span class='hs-varid'>reset</span>     <span class='hs-comment'>-- :: Delim s t s -&gt; Delim s' s' t</span>
+<a name="line-20"></a>
+<a name="line-21"></a>         <span class='hs-comment'>-- ** A family of shift operators</span>
+<a name="line-22"></a>       <span class='hs-layout'>,</span> <span class='hs-varid'>shift0</span>    <span class='hs-comment'>--</span>
+<a name="line-23"></a>       <span class='hs-layout'>,</span> <span class='hs-varid'>shift1</span>    <span class='hs-comment'>--</span>
+<a name="line-24"></a>       <span class='hs-layout'>,</span> <span class='hs-varid'>shift2</span>    <span class='hs-comment'>--</span>
+<a name="line-25"></a>
+<a name="line-26"></a>         <span class='hs-comment'>-- ** Executing delimited computations</span>
+<a name="line-27"></a>       <span class='hs-layout'>,</span> <span class='hs-varid'>runDelim</span>  <span class='hs-comment'>-- :: Delim t t t -&gt; t</span>
+<a name="line-28"></a>
+<a name="line-29"></a>         <span class='hs-comment'>-- * Re-exports for convenience</span>
+<a name="line-30"></a>       <span class='hs-layout'>,</span> <span class='hs-keyword'>module</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Indexed</span><span class='hs-varop'>.</span><span class='hs-conid'>Monad</span>
+<a name="line-31"></a>       <span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
+<a name="line-32"></a>
+<a name="line-33"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Indexed</span><span class='hs-varop'>.</span><span class='hs-conid'>Monad</span>
+<a name="line-34"></a>
+<a name="line-35"></a><a name="Delim"></a><span class='hs-comment'>-- | The type of a delimited continuation, which is answer-type polymorphic.</span>
+<a name="line-36"></a><a name="Delim"></a><span class='hs-comment'>--</span>
+<a name="line-37"></a><a name="Delim"></a><span class='hs-comment'>-- Functions of type @a -&gt; 'Delim' s t b@ can be thought of as</span>
+<a name="line-38"></a><a name="Delim"></a><span class='hs-comment'>-- functions of type @a \/ s -&gt; b \/ t@, which means given an @a@ we</span>
+<a name="line-39"></a><a name="Delim"></a><span class='hs-comment'>-- return a @b@, changing the /answer type/ of the continuation from</span>
+<a name="line-40"></a><a name="Delim"></a><span class='hs-comment'>-- @s@ to @t@.</span>
+<a name="line-41"></a><a name="Delim"></a><span class='hs-comment'>--</span>
+<a name="line-42"></a><a name="Delim"></a><span class='hs-comment'>-- If a 'Delim' does not capture the computation using one of the</span>
+<a name="line-43"></a><a name="Delim"></a><span class='hs-comment'>-- various @shift@ operators (or @shift@ does not change the answer</span>
+<a name="line-44"></a><a name="Delim"></a><span class='hs-comment'>-- type,) then the term is /polymorphic/ in the answer type.</span>
+<a name="line-45"></a><a name="Delim"></a><span class='hs-comment'>--</span>
+<a name="line-46"></a><a name="Delim"></a><span class='hs-comment'>-- &gt;&gt;&gt; :t runDelim $ reset $ shift2 ret !&gt;&gt;= \r -&gt; ret (r + (1 :: Int))</span>
+<a name="line-47"></a><a name="Delim"></a><span class='hs-comment'>-- runDelim $ reset $ shift2 ret !&gt;&gt;= \r -&gt; ret (r + (1 :: Int))</span>
+<a name="line-48"></a><a name="Delim"></a><span class='hs-comment'>--   :: Int -&gt; forall a'. Delim a' a' Int</span>
+<a name="line-49"></a><a name="Delim"></a><span class='hs-comment'>--</span>
+<a name="line-50"></a><a name="Delim"></a><span class='hs-comment'>-- Note how the quantified variable @a'@ is both the input and output</span>
+<a name="line-51"></a><a name="Delim"></a><span class='hs-comment'>-- answer type: thus, it cannot change from what is (in this case, the</span>
+<a name="line-52"></a><a name="Delim"></a><span class='hs-comment'>-- answer type of the enclosing 'reset' is 'Int'.) We use 'shift2'</span>
+<a name="line-53"></a><a name="Delim"></a><span class='hs-comment'>-- here, which uses rank-2 typing to ensure the type variable does not</span>
+<a name="line-54"></a><a name="Delim"></a><span class='hs-comment'>-- \'escape\', much like the @ST@ monad.</span>
+<a name="line-55"></a><a name="Delim"></a><span class='hs-keyword'>newtype</span> <span class='hs-conid'>Delim</span> <span class='hs-varid'>s</span> <span class='hs-varid'>t</span> <span class='hs-varid'>b</span>
+<a name="line-56"></a>  <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Delim</span> <span class='hs-layout'>{</span> <span class='hs-varid'>unDelim</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-varid'>b</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>s</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>t</span> <span class='hs-layout'>}</span>
+<a name="line-57"></a>
+<a name="line-58"></a><a name="instance%20Monad'%20Delim"></a><span class='hs-comment'>-- | Delimited continuations form a parameterized 'Monad''.</span>
+<a name="line-59"></a><a name="instance%20Monad'%20Delim"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>Monad'</span> <span class='hs-conid'>Delim</span> <span class='hs-keyword'>where</span>
+<a name="line-60"></a>  <span class='hs-varid'>ret</span> <span class='hs-varid'>x</span>            <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Delim</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>k</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>k</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span>
+<a name="line-61"></a>  <span class='hs-varid'>bind</span> <span class='hs-layout'>(</span><span class='hs-conid'>Delim</span> <span class='hs-varid'>f</span><span class='hs-layout'>)</span> <span class='hs-varid'>h</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Delim</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>k</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>f</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>s</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>unDelim</span> <span class='hs-layout'>(</span><span class='hs-varid'>h</span> <span class='hs-varid'>s</span><span class='hs-layout'>)</span> <span class='hs-varid'>k</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
+<a name="line-62"></a>
+<a name="line-63"></a><a name="reset"></a><span class='hs-comment'>-- | Delimit a computation.</span>
+<a name="line-64"></a><span class='hs-definition'>reset</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Delim</span> <span class='hs-varid'>s</span> <span class='hs-varid'>t</span> <span class='hs-varid'>s</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-conid'>Delim</span> <span class='hs-varid'>s'</span> <span class='hs-varid'>s'</span> <span class='hs-varid'>t</span>
+<a name="line-65"></a><span class='hs-definition'>reset</span> <span class='hs-layout'>(</span><span class='hs-conid'>Delim</span> <span class='hs-varid'>f</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Delim</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>k</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>k</span> <span class='hs-layout'>(</span><span class='hs-varid'>f</span> <span class='hs-varid'>id</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
+<a name="line-66"></a>
+<a name="line-67"></a><a name="shift0"></a><span class='hs-comment'>-- | Clear the current continuation and invoke our handler with it</span>
+<a name="line-68"></a><span class='hs-comment'>-- bound as a parameter.</span>
+<a name="line-69"></a><span class='hs-comment'>--</span>
+<a name="line-70"></a><span class='hs-comment'>-- This is the most pure definition of @shift@.</span>
+<a name="line-71"></a><span class='hs-definition'>shift0</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-layout'>(</span><span class='hs-varid'>b</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>s</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>t</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-conid'>Delim</span> <span class='hs-varid'>s</span> <span class='hs-varid'>t</span> <span class='hs-varid'>b</span>
+<a name="line-72"></a><span class='hs-definition'>shift0</span> <span class='hs-varid'>f</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Delim</span> <span class='hs-varid'>f</span>
+<a name="line-73"></a>
+<a name="line-74"></a><a name="shift1"></a><span class='hs-comment'>-- | Clear the current continuation and invoke our handler with it</span>
+<a name="line-75"></a><span class='hs-comment'>-- bound as a parameter.</span>
+<a name="line-76"></a><span class='hs-comment'>--</span>
+<a name="line-77"></a><span class='hs-comment'>-- This is a simple Haskell98 definition of @shift@ that does not enforce</span>
+<a name="line-78"></a><span class='hs-comment'>-- true answer type polymorphism by abstracting over the internal 's' and</span>
+<a name="line-79"></a><span class='hs-comment'>-- 't' type variables.</span>
+<a name="line-80"></a><span class='hs-definition'>shift1</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-layout'>(</span><span class='hs-varid'>b</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>s</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-conid'>Delim</span> <span class='hs-varid'>a</span> <span class='hs-varid'>t</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-conid'>Delim</span> <span class='hs-varid'>s</span> <span class='hs-varid'>t</span> <span class='hs-varid'>b</span>
+<a name="line-81"></a><span class='hs-definition'>shift1</span> <span class='hs-varid'>f</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Delim</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>k</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>unDelim</span> <span class='hs-layout'>(</span><span class='hs-varid'>f</span> <span class='hs-varid'>k</span><span class='hs-layout'>)</span> <span class='hs-varid'>id</span><span class='hs-layout'>)</span>
+<a name="line-82"></a>
+<a name="line-83"></a><a name="shift2"></a><span class='hs-comment'>-- | Clear the current continuation and invoke our handler with it</span>
+<a name="line-84"></a><span class='hs-comment'>-- bound as a paramter.</span>
+<a name="line-85"></a><span class='hs-comment'>--</span>
+<a name="line-86"></a><span class='hs-comment'>-- This definition of @shift@ uses Rank-2 types to ensure the answer</span>
+<a name="line-87"></a><span class='hs-comment'>-- type is in fact polymorphic: note the type of the captured continuation</span>
+<a name="line-88"></a><span class='hs-comment'>-- is of type @Delim t' t' s@.</span>
+<a name="line-89"></a><span class='hs-definition'>shift2</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-layout'>(</span><span class='hs-varid'>b</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-keyword'>forall</span> <span class='hs-varid'>a'</span><span class='hs-varop'>.</span>  <span class='hs-conid'>Delim</span> <span class='hs-varid'>a'</span> <span class='hs-varid'>a'</span> <span class='hs-varid'>s</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-conid'>Delim</span> <span class='hs-varid'>a</span> <span class='hs-varid'>t</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-conid'>Delim</span> <span class='hs-varid'>s</span> <span class='hs-varid'>t</span> <span class='hs-varid'>b</span>
+<a name="line-90"></a><span class='hs-definition'>shift2</span> <span class='hs-varid'>f</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Delim</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>k</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>unDelim</span> <span class='hs-layout'>(</span><span class='hs-varid'>f</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>t</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>ret</span> <span class='hs-layout'>(</span><span class='hs-varid'>k</span> <span class='hs-varid'>t</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <span class='hs-varid'>id</span><span class='hs-layout'>)</span>
+<a name="line-91"></a>
+<a name="line-92"></a><a name="runDelim"></a><span class='hs-comment'>-- | Run a delimited computation.</span>
+<a name="line-93"></a><span class='hs-definition'>runDelim</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Delim</span> <span class='hs-varid'>t</span> <span class='hs-varid'>t</span> <span class='hs-varid'>t</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>t</span>
+<a name="line-94"></a><span class='hs-definition'>runDelim</span> <span class='hs-layout'>(</span><span class='hs-conid'>Delim</span> <span class='hs-varid'>f</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>f</span> <span class='hs-varid'>id</span>
+</pre></body>
+</html>

File doc/src/Control-Indexed-Monad.html

View file
+<?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>
+<head>
+<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
+<title>src/Control/Indexed/Monad.hs</title>
+<link type='text/css' rel='stylesheet' href='hscolour.css' />
+</head>
+<body>
+<pre><a name="line-1"></a><span class='hs-comment'>-- |</span>
+<a name="line-2"></a><span class='hs-comment'>-- Module      : Control.Indexed.Monad</span>
+<a name="line-3"></a><span class='hs-comment'>-- Copyright   : (c) Oleg Kiselyov 2007-2012, (c) Austin Seipp 2012</span>
+<a name="line-4"></a><span class='hs-comment'>-- License     : MIT</span>
+<a name="line-5"></a><span class='hs-comment'>--</span>
+<a name="line-6"></a><span class='hs-comment'>-- Maintainer  : mad.one@gmail.com</span>
+<a name="line-7"></a><span class='hs-comment'>-- Stability   : experimental</span>
+<a name="line-8"></a><span class='hs-comment'>-- Portability : portable</span>
+<a name="line-9"></a><span class='hs-comment'>--</span>
+<a name="line-10"></a><span class='hs-comment'>-- Parameterized monads.</span>
+<a name="line-11"></a><span class='hs-comment'>--</span>
+<a name="line-12"></a><span class='hs-comment'>-- When using GHC with @RebindableSyntax@, it's possible to overload</span>
+<a name="line-13"></a><span class='hs-comment'>-- regular @do@-notation to use the 'Monad'' typeclass.</span>
+<a name="line-14"></a><span class='hs-comment'>--</span>
+<a name="line-15"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Indexed</span><span class='hs-varop'>.</span><span class='hs-conid'>Monad</span>
+<a name="line-16"></a>       <span class='hs-layout'>(</span> <span class='hs-comment'>-- * Parameterized monads</span>
+<a name="line-17"></a>         <span class='hs-conid'>Monad'</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span> <span class='hs-comment'>-- :: (* -&gt; * -&gt; * -&gt; *) -&gt; Constraint</span>
+<a name="line-18"></a>       <span class='hs-layout'>,</span> <span class='hs-layout'>(</span><span class='hs-varop'>!&gt;&gt;=</span><span class='hs-layout'>)</span>     <span class='hs-comment'>-- :: Monad' m =&gt; m b g s -&gt; (s -&gt; m a b t) -&gt; m a g t</span>
+<a name="line-19"></a>       <span class='hs-layout'>,</span> <span class='hs-layout'>(</span><span class='hs-varop'>!+&gt;&gt;</span><span class='hs-layout'>)</span>     <span class='hs-comment'>-- :: Monad' m =&gt; m b g s -&gt; m a b t -&gt; m a g t</span>
+<a name="line-20"></a>       <span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
+<a name="line-21"></a>
+<a name="line-22"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
+<a name="line-23"></a><span class='hs-comment'>-- Parameterized monads.</span>
+<a name="line-24"></a>
+<a name="line-25"></a><a name="Monad'"></a><span class='hs-comment'>-- | Parameterized monads.</span>
+<a name="line-26"></a><a name="Monad'"></a><span class='hs-comment'>--</span>
+<a name="line-27"></a><a name="Monad'"></a><span class='hs-comment'>-- Regular monads are automatically lifted into this class through a</span>
+<a name="line-28"></a><a name="Monad'"></a><span class='hs-comment'>-- (hidden) newtype constructor.</span>
+<a name="line-29"></a><a name="Monad'"></a><span class='hs-keyword'>class</span> <span class='hs-conid'>Monad'</span> <span class='hs-varid'>m</span> <span class='hs-keyword'>where</span>
+<a name="line-30"></a>  <span class='hs-comment'>-- | Parameterized 'Prelude.return'.</span>
+<a name="line-31"></a>  <span class='hs-varid'>ret</span>  <span class='hs-keyglyph'>::</span> <span class='hs-varid'>t</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span> <span class='hs-varid'>a</span> <span class='hs-varid'>t</span>
+<a name="line-32"></a>  <span class='hs-comment'>-- | Parameterized 'Prelude.&gt;&gt;='.</span>
+<a name="line-33"></a>  <span class='hs-varid'>bind</span> <span class='hs-keyglyph'>::</span> <span class='hs-varid'>m</span> <span class='hs-varid'>b</span> <span class='hs-varid'>g</span> <span class='hs-varid'>s</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-layout'>(</span><span class='hs-varid'>s</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span> <span class='hs-varid'>b</span> <span class='hs-varid'>t</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span> <span class='hs-varid'>g</span> <span class='hs-varid'>t</span>
+<a name="line-34"></a>
+<a name="line-35"></a><a name="MW"></a><span class='hs-comment'>-- | This newtype lifts any regular monad into a parameterized monad.</span>
+<a name="line-36"></a><a name="MW"></a><span class='hs-keyword'>newtype</span> <span class='hs-conid'>MW</span> <span class='hs-varid'>m</span> <span class='hs-varid'>p</span> <span class='hs-varid'>q</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>MW</span> <span class='hs-layout'>{</span> <span class='hs-varid'>unMW</span> <span class='hs-keyglyph'>::</span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span> <span class='hs-layout'>}</span>
+<a name="line-37"></a>
+<a name="line-38"></a><a name="instance%20Monad'%20(MW%20m)"></a><span class='hs-comment'>-- | This instances simply lifts regular instances of 'Monad'</span>
+<a name="line-39"></a><a name="instance%20Monad'%20(MW%20m)"></a><span class='hs-comment'>-- into instances of 'Monad''.</span>
+<a name="line-40"></a><a name="instance%20Monad'%20(MW%20m)"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>Monad</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'>=&gt;</span> <span class='hs-conid'>Monad'</span> <span class='hs-layout'>(</span><span class='hs-conid'>MW</span> <span class='hs-varid'>m</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
+<a name="line-41"></a>  <span class='hs-varid'>ret</span>         <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>MW</span> <span class='hs-layout'>(</span><span class='hs-varid'>return</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span>
+<a name="line-42"></a>  <span class='hs-varid'>bind</span> <span class='hs-layout'>(</span><span class='hs-conid'>MW</span> <span class='hs-varid'>m</span><span class='hs-layout'>)</span> <span class='hs-varid'>f</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>MW</span> <span class='hs-layout'>(</span><span class='hs-varid'>m</span> <span class='hs-varop'>&gt;&gt;=</span> <span class='hs-varid'>unMW</span> <span class='hs-varop'>.</span> <span class='hs-varid'>f</span><span class='hs-layout'>)</span>
+<a name="line-43"></a>
+<a name="line-44"></a><a name="!%3e%3e="></a><span class='hs-comment'>-- | Infix synonym for 'bind'.</span>
+<a name="line-45"></a><span class='hs-layout'>(</span><span class='hs-varop'>!&gt;&gt;=</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Monad'</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'>=&gt;</span> <span class='hs-varid'>m</span> <span class='hs-varid'>b</span> <span class='hs-varid'>g</span> <span class='hs-varid'>s</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-layout'>(</span><span class='hs-varid'>s</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span> <span class='hs-varid'>b</span> <span class='hs-varid'>t</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span> <span class='hs-varid'>g</span> <span class='hs-varid'>t</span>
+<a name="line-46"></a><a name="m"></a><span class='hs-definition'>m</span> <span class='hs-varop'>!&gt;&gt;=</span> <span class='hs-varid'>f</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>bind</span> <span class='hs-varid'>m</span> <span class='hs-varid'>f</span>
+<a name="line-47"></a><span class='hs-keyword'>infixl</span> <span class='hs-num'>1</span> <span class='hs-varop'>!&gt;&gt;=</span>
+<a name="line-48"></a>
+<a name="line-49"></a><a name="!+%3e%3e"></a><span class='hs-comment'>-- | Defined as:</span>
+<a name="line-50"></a><span class='hs-comment'>--</span>
+<a name="line-51"></a><span class='hs-comment'>-- @m1 !+&gt;&gt; m2 = bind m1 (const m2)@</span>
+<a name="line-52"></a><span class='hs-layout'>(</span><span class='hs-varop'>!+&gt;&gt;</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Monad'</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'>=&gt;</span> <span class='hs-varid'>m</span> <span class='hs-varid'>b</span> <span class='hs-varid'>g</span> <span class='hs-varid'>s</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span> <span class='hs-varid'>b</span> <span class='hs-varid'>t</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-varid'>m</span> <span class='hs-varid'>a</span> <span class='hs-varid'>g</span> <span class='hs-varid'>t</span>
+<a name="line-53"></a><a name="m1"></a><span class='hs-definition'>m1</span> <span class='hs-varop'>!+&gt;&gt;</span> <span class='hs-varid'>m2</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>bind</span> <span class='hs-varid'>m1</span> <span class='hs-layout'>(</span><span class='hs-varid'>const</span> <span class='hs-varid'>m2</span><span class='hs-layout'>)</span>
+<a name="line-54"></a><span class='hs-keyword'>infixl</span> <span class='hs-num'>1</span> <span class='hs-varop'>!+&gt;&gt;</span>
+</pre></body>
+</html>

File doc/src/hscolour.css

View file
+.hs-keyglyph, .hs-layout {color: red;}
+.hs-keyword {color: blue;}
+.hs-comment, .hs-comment a {color: green;}
+.hs-str, .hs-chr {color: teal;}
+.hs-keyword, .hs-conid, .hs-varid, .hs-conop, .hs-varop, .hs-num, .hs-cpp, .hs-sel, .hs-definition {}

File doc/synopsis.png

Added
New image