prelude 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. data/CHANGELOG +25 -1
  2. data/README +11 -12
  3. data/Rakefile +6 -10
  4. data/lib/prelude.rb +36 -91
  5. data/lib/prelude/{tuple.rb → array_list.rb} +30 -27
  6. data/lib/prelude/functions.rb +414 -0
  7. data/lib/prelude/functors.rb +72 -0
  8. data/lib/prelude/lambda.rb +89 -0
  9. data/lib/prelude/minimal_array_list.rb +61 -0
  10. data/lib/prelude/monad.rb +11 -15
  11. data/lib/prelude/proper_list.rb +47 -0
  12. data/lib/prelude/proper_ruby_list.rb +48 -0
  13. data/lib/prelude/util.rb +33 -0
  14. data/test/tc_functions.rb +801 -0
  15. data/test/tc_monad.rb +21 -41
  16. data/test/ts_prelude.rb +2 -8
  17. metadata +13 -36
  18. data/doc/classes/Kernel.html +0 -198
  19. data/doc/classes/Prelude.html +0 -241
  20. data/doc/classes/Prelude/EmptyListError.html +0 -113
  21. data/doc/classes/Prelude/List.html +0 -2692
  22. data/doc/classes/Prelude/MissingFunctionError.html +0 -113
  23. data/doc/classes/Prelude/Monad.html +0 -283
  24. data/doc/classes/Prelude/Tuple.html +0 -217
  25. data/doc/classes/Proc.html +0 -198
  26. data/doc/classes/Symbol.html +0 -219
  27. data/doc/created.rid +0 -1
  28. data/doc/files/CHANGELOG.html +0 -122
  29. data/doc/files/README.html +0 -328
  30. data/doc/files/TODO.html +0 -95
  31. data/doc/files/lib/prelude/list_rb.html +0 -83
  32. data/doc/files/lib/prelude/monad_rb.html +0 -83
  33. data/doc/files/lib/prelude/tuple_rb.html +0 -83
  34. data/doc/files/lib/prelude_rb.html +0 -98
  35. data/doc/fr_class_index.html +0 -35
  36. data/doc/fr_file_index.html +0 -33
  37. data/doc/fr_method_index.html +0 -140
  38. data/doc/index.html +0 -27
  39. data/doc/rdoc-style.css +0 -208
  40. data/lib/prelude/list.rb +0 -588
  41. data/test/tc_higher.rb +0 -89
  42. data/test/tc_list.rb +0 -777
  43. data/test/tc_tuple.rb +0 -82
@@ -1,198 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: Proc</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">Proc</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../files/lib/prelude_rb.html">
59
- lib/prelude.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- <tr class="top-aligned-row">
66
- <td><strong>Parent:</strong></td>
67
- <td>
68
- Object
69
- </td>
70
- </tr>
71
- </table>
72
- </div>
73
- <!-- banner header -->
74
-
75
- <div id="bodyContent">
76
-
77
-
78
-
79
- <div id="contextContent">
80
-
81
-
82
-
83
- </div>
84
-
85
- <div id="method-list">
86
- <h3 class="section-bar">Methods</h3>
87
-
88
- <div class="name-list">
89
- <a href="#M000006">**</a>&nbsp;&nbsp;
90
- <a href="#M000005">curry</a>&nbsp;&nbsp;
91
- </div>
92
- </div>
93
-
94
- </div>
95
-
96
-
97
- <!-- if includes -->
98
-
99
- <div id="section">
100
-
101
-
102
-
103
- <div id="aliases-list">
104
- <h3 class="section-bar">External Aliases</h3>
105
-
106
- <div class="name-list">
107
- <table summary="aliases">
108
- <tr class="top-aligned-row context-row">
109
- <td class="context-item-name">call</td>
110
- <td>-&gt;</td>
111
- <td class="context-item-value">~</td>
112
- </tr>
113
- <tr class="top-aligned-row context-row">
114
- <td>&nbsp;</td>
115
- <td colspan="2" class="context-item-desc">
116
- Syntaxic sugar for something like this: ~head(list), i.e., gives actual
117
- head instead of proc that can do it if called.
118
-
119
- </td>
120
- </tr>
121
- </table>
122
- </div>
123
- </div>
124
-
125
-
126
-
127
-
128
-
129
- <!-- if method_list -->
130
- <div id="methods">
131
- <h3 class="section-bar">Public Instance methods</h3>
132
-
133
- <div id="method-M000006" class="method-detail">
134
- <a name="M000006"></a>
135
-
136
- <div class="method-heading">
137
- <a href="#M000006" class="method-signature">
138
- <span class="method-name">**</span><span class="method-args">(*args)</span>
139
- </a>
140
- </div>
141
-
142
- <div class="method-description">
143
- <p>
144
- This is will serve as an infix composition operator for procs. If between
145
- two procs, returns composition proc, executes left proc otherwise.
146
- </p>
147
- <p><a class="source-toggle" href="#"
148
- onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
149
- <div class="method-source-code" id="M000006-source">
150
- <pre>
151
- <span class="ruby-comment cmt"># File lib/prelude.rb, line 99</span>
152
- 99: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">**</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
153
- 100: <span class="ruby-keyword kw">if</span> (<span class="ruby-value">1</span><span class="ruby-operator">==</span><span class="ruby-identifier">args</span>.<span class="ruby-identifier">length</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Proc</span>)
154
- 101: <span class="ruby-identifier">lambda</span> {<span class="ruby-operator">|</span><span class="ruby-operator">*</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">call</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">a</span>)) }
155
- 102: <span class="ruby-keyword kw">else</span>
156
- 103: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">call</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>.<span class="ruby-identifier">flatten</span>)
157
- 104: <span class="ruby-keyword kw">end</span>
158
- 105: <span class="ruby-keyword kw">end</span>
159
- </pre>
160
- </div>
161
- </div>
162
- </div>
163
-
164
- <div id="method-M000005" class="method-detail">
165
- <a name="M000005"></a>
166
-
167
- <div class="method-heading">
168
- <a href="#M000005" class="method-signature">
169
- <span class="method-name">curry</span><span class="method-args">(one, *args)</span>
170
- </a>
171
- </div>
172
-
173
- <div class="method-description">
174
- <p>
175
- FIXIT
176
- </p>
177
- <p><a class="source-toggle" href="#"
178
- onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
179
- <div class="method-source-code" id="M000005-source">
180
- <pre>
181
- <span class="ruby-comment cmt"># File lib/prelude.rb, line 93</span>
182
- 93: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">curry</span>(<span class="ruby-identifier">one</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
183
- 94: <span class="ruby-identifier">lambda</span> { <span class="ruby-operator">|</span><span class="ruby-operator">*</span><span class="ruby-identifier">args</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">one</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)}
184
- 95: <span class="ruby-keyword kw">end</span>
185
- </pre>
186
- </div>
187
- </div>
188
- </div>
189
-
190
-
191
- </div>
192
-
193
-
194
- </div>
195
-
196
-
197
- </body>
198
- </html>
@@ -1,219 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: Symbol</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">Symbol</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../files/lib/prelude_rb.html">
59
- lib/prelude.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- <tr class="top-aligned-row">
66
- <td><strong>Parent:</strong></td>
67
- <td>
68
- Object
69
- </td>
70
- </tr>
71
- </table>
72
- </div>
73
- <!-- banner header -->
74
-
75
- <div id="bodyContent">
76
-
77
-
78
-
79
- <div id="contextContent">
80
-
81
-
82
-
83
- </div>
84
-
85
- <div id="method-list">
86
- <h3 class="section-bar">Methods</h3>
87
-
88
- <div class="name-list">
89
- <a href="#M000004">**</a>&nbsp;&nbsp;
90
- <a href="#M000002">-@</a>&nbsp;&nbsp;
91
- <a href="#M000003">curry</a>&nbsp;&nbsp;
92
- <a href="#M000001">to_proc</a>&nbsp;&nbsp;
93
- </div>
94
- </div>
95
-
96
- </div>
97
-
98
-
99
- <!-- if includes -->
100
-
101
- <div id="section">
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
- <!-- if method_list -->
111
- <div id="methods">
112
- <h3 class="section-bar">Public Instance methods</h3>
113
-
114
- <div id="method-M000004" class="method-detail">
115
- <a name="M000004"></a>
116
-
117
- <div class="method-heading">
118
- <a href="#M000004" class="method-signature">
119
- <span class="method-name">**</span><span class="method-args">(*args)</span>
120
- </a>
121
- </div>
122
-
123
- <div class="method-description">
124
- <p>
125
- This is will serve as an infix composition operator for symbols. If between
126
- two symbols, returns composition proc, executes left symbol otherwise.
127
- </p>
128
- <p><a class="source-toggle" href="#"
129
- onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
130
- <div class="method-source-code" id="M000004-source">
131
- <pre>
132
- <span class="ruby-comment cmt"># File lib/prelude.rb, line 77</span>
133
- 77: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">**</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
134
- 78: <span class="ruby-keyword kw">if</span> (<span class="ruby-value">1</span><span class="ruby-operator">==</span><span class="ruby-identifier">args</span>.<span class="ruby-identifier">length</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Symbol</span>)
135
- 79: <span class="ruby-identifier">proc</span> {<span class="ruby-operator">|</span><span class="ruby-operator">*</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_proc</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">call</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">a</span>)) }
136
- 80: <span class="ruby-keyword kw">else</span>
137
- 81: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_proc</span>.<span class="ruby-identifier">call</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>.<span class="ruby-identifier">flatten</span>)
138
- 82: <span class="ruby-keyword kw">end</span>
139
- 83: <span class="ruby-keyword kw">end</span>
140
- </pre>
141
- </div>
142
- </div>
143
- </div>
144
-
145
- <div id="method-M000002" class="method-detail">
146
- <a name="M000002"></a>
147
-
148
- <div class="method-heading">
149
- <span class="method-name">-@</span><span class="method-args">()</span>
150
- </div>
151
-
152
- <div class="method-description">
153
- <p>
154
- Alias for <a href="Symbol.html#M000001">to_proc</a>
155
- </p>
156
- </div>
157
- </div>
158
-
159
- <div id="method-M000003" class="method-detail">
160
- <a name="M000003"></a>
161
-
162
- <div class="method-heading">
163
- <a href="#M000003" class="method-signature">
164
- <span class="method-name">curry</span><span class="method-args">(one, *args)</span>
165
- </a>
166
- </div>
167
-
168
- <div class="method-description">
169
- <p>
170
- FIXIT
171
- </p>
172
- <p><a class="source-toggle" href="#"
173
- onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
174
- <div class="method-source-code" id="M000003-source">
175
- <pre>
176
- <span class="ruby-comment cmt"># File lib/prelude.rb, line 71</span>
177
- 71: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">curry</span>(<span class="ruby-identifier">one</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
178
- 72: <span class="ruby-identifier">proc</span> { <span class="ruby-operator">|</span><span class="ruby-operator">*</span><span class="ruby-identifier">args</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_proc</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">one</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>) }
179
- 73: <span class="ruby-keyword kw">end</span>
180
- </pre>
181
- </div>
182
- </div>
183
- </div>
184
-
185
- <div id="method-M000001" class="method-detail">
186
- <a name="M000001"></a>
187
-
188
- <div class="method-heading">
189
- <a href="#M000001" class="method-signature">
190
- <span class="method-name">to_proc</span><span class="method-args">()</span>
191
- </a>
192
- </div>
193
-
194
- <div class="method-description">
195
- <p>
196
- Converts a symbol to a proc object
197
- </p>
198
- <p><a class="source-toggle" href="#"
199
- onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
200
- <div class="method-source-code" id="M000001-source">
201
- <pre>
202
- <span class="ruby-comment cmt"># File lib/prelude.rb, line 63</span>
203
- 63: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_proc</span>
204
- 64: <span class="ruby-identifier">proc</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">obj</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span><span class="ruby-operator">|</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">send</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>) }
205
- 65: <span class="ruby-keyword kw">end</span>
206
- </pre>
207
- </div>
208
- </div>
209
- </div>
210
-
211
-
212
- </div>
213
-
214
-
215
- </div>
216
-
217
-
218
- </body>
219
- </html>
@@ -1 +0,0 @@
1
- Sun Sep 17 18:35:07 Central Daylight Time 2006
@@ -1,122 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>File: CHANGELOG</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <!-- banner header -->
50
-
51
- <div id="bodyContent">
52
-
53
-
54
-
55
- <div id="contextContent">
56
-
57
- <div id="description">
58
- <h1>CHANGELOG</h1>
59
- <p>
60
- $Id: CHANGELOG 17 2006-09-17 18:03:15Z prelude $
61
- </p>
62
- <h2>09/17/06 - Release 0.0.3</h2>
63
- <ul>
64
- <li>Converted List from being functional-like to fully functional, i.e., all
65
- its methods return functions.
66
-
67
- </li>
68
- </ul>
69
- <h2>09/06/06 - Release 0.0.2</h2>
70
- <ul>
71
- <li>Expanded README and moved references from sources into it.
72
-
73
- </li>
74
- <li>Fixed Tuple&#8217;s implementation.
75
-
76
- </li>
77
- <li>Added custom documentation template.
78
-
79
- </li>
80
- <li>Changed licensing from GPL to Lesser GPL
81
-
82
- </li>
83
- <li>Expanded Monad&#8217;s implementation
84
-
85
- </li>
86
- </ul>
87
- <h2>08/24/06 - Release 0.0.1</h2>
88
- <ul>
89
- <li>A very preliminary version for public comments. Only parts of List class
90
- were implemented.
91
-
92
- </li>
93
- </ul>
94
-
95
- </div>
96
-
97
-
98
- </div>
99
-
100
-
101
- </div>
102
-
103
-
104
- <!-- if includes -->
105
-
106
- <div id="section">
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
- <!-- if method_list -->
116
-
117
-
118
- </div>
119
-
120
-
121
- </body>
122
- </html>