Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Improve formatting

  • Loading branch information...
commit c8979abb4c960d1ceaacb02b1c02b1a2c10b3776 1 parent 5068fc0
authored July 16, 2011

Showing 1 changed file with 1 addition and 68 deletions. Show diff stats Hide diff stats

  1. 69  README.markdown
69  README.markdown
Source Rendered
... ...
@@ -1,5 +1,3 @@
1  
-<!--
2  
-
3 1
 Haskell Joinads
4 2
 ===============
5 3
 
@@ -71,69 +69,4 @@ for arrow syntax][3] implemented by Ross Paterson.
71 69
   [2]: http://tomasp.net/blog/speculative-par-monad.aspx
72 70
   [3]: http://hackage.haskell.org/package/arrowp
73 71
   [4]: http://github.com/tpetricek/Haskell.ParMonad
74  
-  [5]: http://themonadreader.files.wordpress.com/2011/07/issue18.pdf
75  
-
76  
--->
77  
-
78  
-<h1>Haskell Joinads</h1>
79  
-
80  
-<p>This source repository contains the implementation of <em>joinads</em> for the Haskell language.
81  
-The design of the extension is described in a paper [Extending Monads with Pattern Matching][1],
82  
-which provides more details about the langauge extension and gives numerous examples.</p>
83  
-
84  
-<p>The language extension adds <code>docase</code> construct to Haskell. Similarly to the <code>do</code> notation,
85  
-the construct can be used with any type that provides instance for a certain type class.
86  
-In case of <code>do</code>, the type class is <code>Monad</code>. To support <code>docase</code>, type must implement a
87  
-<code>Joinad</code> type cass that extends <code>Monad</code> with three additional operators that represent
88  
-non-deterministic <em>choice</em> between computations, <em>parallel composition</em> of computations
89  
-and <em>aliasing</em> of computations).</p>
90  
-
91  
-<p>The following example uses the instance for [the <code>Par</code> monad][2]. It implements a function
92  
-that recursively processes a tree and returns <code>True</code> when the tree contains element that 
93  
-matches the specified predicate:</p>
94  
-
95  
-<pre><code>all :: (a -&gt; Bool) -&gt; Tree a -&gt; Par Bool
96  
-
97  
-all p (Leaf v)           = return (p v)
98  
-all p (Node left right)  = 
99  
-  docase (all p left, all p right) of
100  
-    (False, ?)    -&gt; return False
101  
-    (?, False)    -&gt; return False
102  
-    (allL, allR)  -&gt; return (allL &amp;&amp; allR)
103  
-</code></pre>
104  
-
105  
-<p>The <code>docase</code> syntax is similar to pattern matching using <code>case</code>, but works on monadic computations.
106  
-The monadic computation <code>Par a</code> represents a task that can be executed (using a parallel scheduler)
107  
-and eventually returns a value of type <code>a</code>. </p>
108  
-
109  
-<p>In the above example, the <code>docase</code> construct creates a computation that starts processing
110  
-left and right sub-trees in parallel. When any of the sub-tasks completes and returns <code>False</code>,
111  
-we already know that the overall result will be <code>False</code>, so we don't need to wait for the
112  
-completion of the second task. This expressed using the <code>?</code> pattern in the first and the
113  
-second clause. Finally, the last clause handles the case when we need to wait for both of the
114  
-values before producing the result.</p>
115  
-
116  
-<h2>Organization</h2>
117  
-
118  
-<p>The <code>docase</code> extension is currently implemented using a pre-processor that takes Haskell'98 
119  
-code with the <code>docase</code> extension and translates it into standard Haskell'98 source (it replaces
120  
-<code>docase</code> with calls to standard functions). The pre-processor is based on the [pre-processor
121  
-for arrow syntax][3] implemented by Ross Paterson.</p>
122  
-
123  
-<ul style="margin-left:20px">
124  
-<li><p><strong>Preprocessor</strong> directory contains the implementation of the pre-processor. It
125  
-can be compiled using the <code>Makefile</code> provided and then executed using 
126  
-the command: <code>joinadsp.exe Sample.jhs &gt; Sample.hs</code></p></li>
127  
-<li><p><strong>Samples</strong> includes numerous examples that use joinads. It includes <code>Joinad</code> instance
128  
-for the <code>Maybe</code> type and types mentioned in the paper (parsers that can be used for
129  
-input validation, parallelsim monad used above and simple cooperative parallelism 
130  
-monad using resumptions).</p></li>
131  
-<li><p><strong>ParMonad</strong> includes core parts of the <code>Par</code> monad that is used in the parallel programming
132  
-samples. The implementation is extended to support speculative parallelism (see a separate
133  
-[a blog post][2]). a complete modified implementation is available in a [separate
134  
-project][4]</p></li>
135  
-<li><p><strong>Comprehensions</strong> shows several examples that use <em>generalized zip comprehensions</em> 
136  
-(or <em>parallel monad comprehensions</em>) to write similar examples as those that use
137  
-<code>docase</code> notation. Zip comprehensions are a generalization of parallel list comprehensions
138  
-and overlap with joinads. For more information see an article in [The Monad.Reader Issue 18][5].</p></li>
139  
-</ul>
  72
+  [5]: http://themonadreader.files.wordpress.com/2011/07/issue18.pdf

0 notes on commit c8979ab

Please sign in to comment.
Something went wrong with that request. Please try again.