doc/classes/Prelude/Monad.html in prelude-0.0.2 vs doc/classes/Prelude/Monad.html in prelude-0.0.3
- old
+ new
@@ -3,11 +3,11 @@
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" xml:lang="en" lang="en">
<head>
- <title>Class: Prelude::Monad</title>
+ <title>Module: Prelude::Monad</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
@@ -47,11 +47,11 @@
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
- <td><strong>Class</strong></td>
+ <td><strong>Module</strong></td>
<td class="class-name-in-header">Prelude::Monad</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
@@ -60,16 +60,10 @@
</a>
<br />
</td>
</tr>
- <tr class="top-aligned-row">
- <td><strong>Parent:</strong></td>
- <td>
- Array
- </td>
- </tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
@@ -78,30 +72,28 @@
<div id="contextContent">
<div id="description">
<p>
-$Id: monad.rb 7 2006-09-06 17:03:26Z prelude $
+$Id: monad.rb 13 2006-09-11 05:19:16Z prelude $
</p>
-<p>
-The <a href="Monad.html">Monad</a> is an Array only in an implementation
-sence of the word
-</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
- <a href="#M000011">bind</a>
- <a href="#M000009">empty</a>
- <a href="#M000010">join</a>
- <a href="#M000008">wrap</a>
+ <a href="#M000015"><<</a>
+ <a href="#M000014">bind</a>
+ <a href="#M000012">empty</a>
+ <a href="#M000013">join</a>
+ <a href="#M000011">unwrap</a>
+ <a href="#M000010">wrap</a>
</div>
</div>
</div>
@@ -109,108 +101,173 @@
<!-- if includes -->
<div id="section">
+ <div id="constants-list">
+ <h3 class="section-bar">Constants</h3>
+ <div class="name-list">
+ <table summary="Constants">
+ <tr class="top-aligned-row context-row">
+ <td class="context-item-name">State</td>
+ <td>=</td>
+ <td class="context-item-value">{}</td>
+ </tr>
+ </table>
+ </div>
+ </div>
+
<!-- if method_list -->
<div id="methods">
- <h3 class="section-bar">Public Instance methods</h3>
+ <h3 class="section-bar">Public Class methods</h3>
- <div id="method-M000011" class="method-detail">
- <a name="M000011"></a>
+ <div id="method-M000013" class="method-detail">
+ <a name="M000013"></a>
<div class="method-heading">
- <a href="#M000011" class="method-signature">
- <span class="method-name">bind</span><span class="method-args">(&block)</span>
+ <a href="#M000013" class="method-signature">
+ <span class="method-name">join</span><span class="method-args">(arr)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
- onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
- <div class="method-source-code" id="M000011-source">
+ onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
+ <div class="method-source-code" id="M000013-source">
<pre>
<span class="ruby-comment cmt"># File lib/prelude/monad.rb, line 45</span>
-45: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">bind</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
-46: <span class="ruby-identifier">map</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>).<span class="ruby-identifier">join</span>
-47: <span class="ruby-keyword kw">end</span>
+45: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Monad</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">arr</span>)
+46: <span class="ruby-identifier">r</span> = []
+47: <span class="ruby-identifier">arr</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">push</span> <span class="ruby-operator">*</span><span class="ruby-identifier">a</span>}
+48: <span class="ruby-identifier">r</span>
+49: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
- <div id="method-M000009" class="method-detail">
- <a name="M000009"></a>
+ <h3 class="section-bar">Public Instance methods</h3>
+ <div id="method-M000015" class="method-detail">
+ <a name="M000015"></a>
+
<div class="method-heading">
- <a href="#M000009" class="method-signature">
- <span class="method-name">empty</span><span class="method-args">()</span>
+ <span class="method-name"><<</span><span class="method-args">(f=nil)</span>
+ </div>
+
+ <div class="method-description">
+ <p>
+Alias for <a href="Monad.html#M000014">bind</a>
+</p>
+ </div>
+ </div>
+
+ <div id="method-M000014" class="method-detail">
+ <a name="M000014"></a>
+
+ <div class="method-heading">
+ <a href="#M000014" class="method-signature">
+ <span class="method-name">bind</span><span class="method-args">(f=nil)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
- onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
- <div class="method-source-code" id="M000009-source">
+ onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
+ <div class="method-source-code" id="M000014-source">
<pre>
- <span class="ruby-comment cmt"># File lib/prelude/monad.rb, line 35</span>
-35: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">empty</span>
-36: []
-37: <span class="ruby-keyword kw">end</span>
+ <span class="ruby-comment cmt"># File lib/prelude/monad.rb, line 51</span>
+51: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">bind</span>(<span class="ruby-identifier">f</span>=<span class="ruby-keyword kw">nil</span>)
+52: <span class="ruby-keyword kw">case</span>
+53: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Symbol</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Method</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Proc</span>) <span class="ruby-operator">:</span>
+54: <span class="ruby-constant">State</span>[<span class="ruby-identifier">object_id</span>] = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">to_proc</span>.<span class="ruby-identifier">call</span>(<span class="ruby-constant">State</span>[<span class="ruby-identifier">object_id</span>])
+55: <span class="ruby-keyword kw">self</span>
+56:
+57: <span class="ruby-comment cmt"># when f.kind_of?(Proc) :</span>
+58: <span class="ruby-comment cmt"># State[object_id] = f.call(State[object_id])</span>
+59: <span class="ruby-comment cmt"># self</span>
+60:
+61: <span class="ruby-keyword kw">else</span>
+62: <span class="ruby-identifier">f</span>
+63: <span class="ruby-keyword kw">end</span> <span class="ruby-comment cmt"># case</span>
+64: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
- <div id="method-M000010" class="method-detail">
- <a name="M000010"></a>
+ <div id="method-M000012" class="method-detail">
+ <a name="M000012"></a>
<div class="method-heading">
- <a href="#M000010" class="method-signature">
- <span class="method-name">join</span><span class="method-args">()</span>
+ <a href="#M000012" class="method-signature">
+ <span class="method-name">empty</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
- onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
- <div class="method-source-code" id="M000010-source">
+ onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
+ <div class="method-source-code" id="M000012-source">
<pre>
- <span class="ruby-comment cmt"># File lib/prelude/monad.rb, line 39</span>
-39: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">join</span>
-40: <span class="ruby-identifier">r</span> = []
-41: <span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">push</span> <span class="ruby-operator">*</span><span class="ruby-identifier">a</span>}
-42: <span class="ruby-identifier">r</span>
+ <span class="ruby-comment cmt"># File lib/prelude/monad.rb, line 40</span>
+40: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">empty</span>
+41: <span class="ruby-constant">State</span>[<span class="ruby-identifier">object_id</span>] = <span class="ruby-keyword kw">nil</span>
+42: <span class="ruby-keyword kw">self</span>
43: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
- <div id="method-M000008" class="method-detail">
- <a name="M000008"></a>
+ <div id="method-M000011" class="method-detail">
+ <a name="M000011"></a>
<div class="method-heading">
- <a href="#M000008" class="method-signature">
- <span class="method-name">wrap</span><span class="method-args">(v)</span>
+ <a href="#M000011" class="method-signature">
+ <span class="method-name">unwrap</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
- onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
- <div class="method-source-code" id="M000008-source">
+ onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
+ <div class="method-source-code" id="M000011-source">
<pre>
+ <span class="ruby-comment cmt"># File lib/prelude/monad.rb, line 36</span>
+36: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unwrap</span>
+37: <span class="ruby-constant">State</span>[<span class="ruby-identifier">object_id</span>]
+38: <span class="ruby-keyword kw">end</span>
+</pre>
+ </div>
+ </div>
+ </div>
+
+ <div id="method-M000010" class="method-detail">
+ <a name="M000010"></a>
+
+ <div class="method-heading">
+ <a href="#M000010" class="method-signature">
+ <span class="method-name">wrap</span><span class="method-args">()</span>
+ </a>
+ </div>
+
+ <div class="method-description">
+ <p><a class="source-toggle" href="#"
+ onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
+ <div class="method-source-code" id="M000010-source">
+<pre>
<span class="ruby-comment cmt"># File lib/prelude/monad.rb, line 31</span>
-31: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">wrap</span>(<span class="ruby-identifier">v</span>)
-32: [<span class="ruby-identifier">v</span>]
-33: <span class="ruby-keyword kw">end</span>
+31: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">wrap</span>
+32: <span class="ruby-constant">State</span>[<span class="ruby-identifier">object_id</span>] = <span class="ruby-keyword kw">self</span>
+33: <span class="ruby-keyword kw">self</span>
+34: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
\ No newline at end of file