prelude 0.0.1 → 0.0.2

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.
@@ -0,0 +1,166 @@
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="#M000002">curry</a>&nbsp;&nbsp;
90
+ <a href="#M000001">to_proc</a>&nbsp;&nbsp;
91
+ </div>
92
+ </div>
93
+
94
+ </div>
95
+
96
+
97
+ <!-- if includes -->
98
+
99
+ <div id="section">
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+ <!-- if method_list -->
109
+ <div id="methods">
110
+ <h3 class="section-bar">Public Instance methods</h3>
111
+
112
+ <div id="method-M000002" class="method-detail">
113
+ <a name="M000002"></a>
114
+
115
+ <div class="method-heading">
116
+ <a href="#M000002" class="method-signature">
117
+ <span class="method-name">curry</span><span class="method-args">(one, *args)</span>
118
+ </a>
119
+ </div>
120
+
121
+ <div class="method-description">
122
+ <p><a class="source-toggle" href="#"
123
+ onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
124
+ <div class="method-source-code" id="M000002-source">
125
+ <pre>
126
+ <span class="ruby-comment cmt"># File lib/prelude.rb, line 42</span>
127
+ 42: <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>)
128
+ 43: <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>) }
129
+ 44: <span class="ruby-keyword kw">end</span>
130
+ </pre>
131
+ </div>
132
+ </div>
133
+ </div>
134
+
135
+ <div id="method-M000001" class="method-detail">
136
+ <a name="M000001"></a>
137
+
138
+ <div class="method-heading">
139
+ <a href="#M000001" class="method-signature">
140
+ <span class="method-name">to_proc</span><span class="method-args">()</span>
141
+ </a>
142
+ </div>
143
+
144
+ <div class="method-description">
145
+ <p><a class="source-toggle" href="#"
146
+ onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
147
+ <div class="method-source-code" id="M000001-source">
148
+ <pre>
149
+ <span class="ruby-comment cmt"># File lib/prelude.rb, line 38</span>
150
+ 38: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_proc</span>
151
+ 39: <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>) }
152
+ 40: <span class="ruby-keyword kw">end</span>
153
+ </pre>
154
+ </div>
155
+ </div>
156
+ </div>
157
+
158
+
159
+ </div>
160
+
161
+
162
+ </div>
163
+
164
+
165
+ </body>
166
+ </html>
@@ -0,0 +1 @@
1
+ Wed Sep 06 12:06:33 Central Daylight Time 2006
@@ -0,0 +1,115 @@
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 7 2006-09-06 17:03:26Z prelude $
61
+ </p>
62
+ <h2>09/06/06 - Release 0.0.2</h2>
63
+ <ul>
64
+ <li>Expanded README and moved references from sources into it.
65
+
66
+ </li>
67
+ <li>Fixed Tuple&#8217;s implementation.
68
+
69
+ </li>
70
+ <li>Added custom documentation template.
71
+
72
+ </li>
73
+ <li>Changed licensing from GPL to Lesser GPL
74
+
75
+ </li>
76
+ <li>Expanded Monad&#8217;s implementation
77
+
78
+ </li>
79
+ </ul>
80
+ <h2>08/24/06 - Release 0.0.1</h2>
81
+ <ul>
82
+ <li>A very preliminary version for public comments. Only parts of List class
83
+ were implemented.
84
+
85
+ </li>
86
+ </ul>
87
+
88
+ </div>
89
+
90
+
91
+ </div>
92
+
93
+
94
+ </div>
95
+
96
+
97
+ <!-- if includes -->
98
+
99
+ <div id="section">
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+ <!-- if method_list -->
109
+
110
+
111
+ </div>
112
+
113
+
114
+ </body>
115
+ </html>
@@ -0,0 +1,328 @@
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: README</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><a href="../classes/Prelude.html">Prelude</a> - a Haskell-like functional library</h1>
59
+ <p>
60
+ $Id: README 7 2006-09-06 17:03:26Z prelude $
61
+ </p>
62
+ <p>
63
+ <b>WARNING</b> <tt>The project is still in a very preliminary state. Only
64
+ List was partially implemented. Feel free to contribute.</tt>
65
+ </p>
66
+ <p>
67
+ Project home is at <a
68
+ href="http://rubyforge.org/projects/prelude">rubyforge.org/projects/prelude</a>/
69
+ </p>
70
+ <h2>The goal</h2>
71
+ <p>
72
+ The general idea is that functional programming provides many benefits,
73
+ which are not directly available in Ruby out of the box. This library will,
74
+ hopefully, provide an infrastructure for the use of most Haskell&#8217;s
75
+ functional idioms. It will also facilitate a more or less direct port to
76
+ Ruby of algorithms and data structures already developed by functional
77
+ community. I deem infinite lists, monads, and higher-level functions to be
78
+ most useful functional contribution to the general purpose programming.
79
+ </p>
80
+ <p>
81
+ I do believe the old math&#8217;s maxim that &quot;new notation leads to
82
+ new results.&quot;
83
+ </p>
84
+ <h2>Features</h2>
85
+ <p>
86
+ As of right now, i.e., release 0.0.x, the feature list is pretty much a
87
+ wish list, so treat it accordingly.
88
+ </p>
89
+ <h3>Rather curious collection of operations on lists</h3>
90
+ <p>
91
+ Haskell&#8217;s lists are different from Ruby&#8217;s arrays in many ways.
92
+ First of all, there are more operations defined on lists and the naming
93
+ convention is different. Since Haskell&#8217;s (or Lisp&#8217;s) lists play
94
+ a fundamental role in everything functional, their implementation seems
95
+ necessary. Here are the goals for list&#8217;s implementation:
96
+ </p>
97
+ <ul>
98
+ <li>Most, if not all, functions, i.e., <tt>head</tt>, <tt>tail</tt>,
99
+ <tt>last</tt>, <tt>first</tt>, <tt>concat</tt>, etc.
100
+
101
+ </li>
102
+ <li>Assignment compatibility with Ruby&#8217;s native arrays. For example,
103
+ these operations should be correct:
104
+
105
+ <pre>
106
+ List a = List.new([1, 2, 3])
107
+ b = [3, 4, 5]
108
+ List c = a+b
109
+ a[1] = 10
110
+ b[2] = a[3]
111
+ a &lt;&lt; 3 &lt;&lt; 4
112
+ </pre>
113
+ <p>
114
+ &#8230;and so on.
115
+ </p>
116
+ </li>
117
+ <li>List comprehension. It&#8217;s mostly covered by Ruby&#8217;s own
118
+ functionality, but some semantic refinements may be needed.
119
+
120
+ </li>
121
+ <li>Infinite lists. It might look like this:
122
+
123
+ <pre>
124
+ List ones = List.new([1]) { ones } # =&gt; [1,... ]
125
+ ones.take 3 # =&gt; [1, 1, 1]
126
+ </pre>
127
+ <p>
128
+ This functionality is being developed by the Lazilists project, see <a
129
+ href="http://lazylist.rubyforge.org">lazylist.rubyforge.org</a>
130
+ </p>
131
+ </li>
132
+ <li>What else?
133
+
134
+ </li>
135
+ </ul>
136
+ <h3>Reinforced Ruby&#8217;s Lambda-calculus</h3>
137
+ <p>
138
+ While implementing majority of the Lambda world is relatively trivial in
139
+ Ruby, some of the recursive beauty might be lost. Consider <tt>foldl</tt>,
140
+ for example. The classic recursive definition like this
141
+ </p>
142
+ <pre>
143
+ def foldl(s, &amp;block)
144
+ empty? ? s : tail.foldl(block.call(s, head), &amp;block)
145
+ end
146
+ </pre>
147
+ <p>
148
+ croaks on about 800+ elements integer lists, but more rubyish and compact
149
+ </p>
150
+ <pre>
151
+ def foldl(s, &amp;block)
152
+ inject(s){ |a,b| block.call(a,b) }
153
+ end
154
+ </pre>
155
+ <p>
156
+ does not possess any of the classic&#8217;s functional elegance. It means
157
+ that for practical applications Ruby&#8217;s recursions need to be fixed or
158
+ somehow re-implemented in the <a href="../classes/Prelude.html">Prelude</a>
159
+ library.
160
+ </p>
161
+ <h3>Higher-order functions</h3>
162
+ <p>
163
+ It is a very good thing, that Ruby allows functions to be good citizens
164
+ including being passed to other functions and returned from them. These
165
+ need to be added to complete the picture:
166
+ </p>
167
+ <ul>
168
+ <li>Function combinations. Consider:
169
+
170
+ <pre>
171
+ add5 = proc {|x| x+5}
172
+ add6 = proc {|x| x+6}
173
+ add11 = add5 &lt;&lt; add6
174
+ </pre>
175
+ <p>
176
+ I.e., the <tt>add5</tt> is an absolutely generic algorithm expressed in
177
+ terms of other functions as long as <tt>add5</tt> takes as an argument and
178
+ <tt>add6</tt> returns an object for which operation <tt>+</tt> is defined.
179
+ </p>
180
+ </li>
181
+ <li>Currying, as in
182
+
183
+ <pre>
184
+ add5 = (proc {|x,y,z| x+y+z}).curry(5)
185
+ add5.call(3, 2) # =&gt; 10
186
+ </pre>
187
+ <p>
188
+ More convenient syntax is desirable.
189
+ </p>
190
+ </li>
191
+ <li>What else?
192
+
193
+ </li>
194
+ </ul>
195
+ <h3>Monads</h3>
196
+ <p>
197
+ This is where all the previous trouble should start paying off allowing an
198
+ application to be structured like this:
199
+ </p>
200
+ <pre>
201
+ result &lt;&lt; connect &lt;&lt; do_something &lt;&lt; delete_something &lt;&lt; with(params)
202
+ </pre>
203
+ <p>
204
+ Writing tutorials for monadic computations became a little industry in
205
+ itself, see <a
206
+ href="http://nomaware.com/monads/html/index.html">nomaware.com/monads/html/index.html</a>
207
+ to get started. More monadic resources are here: <a
208
+ href="http://haskell.org/haskellwiki/Books_and_tutorials#Using_monads">haskell.org/haskellwiki/Books_and_tutorials#Using_monads</a>
209
+ </p>
210
+ <h3>What else</h3>
211
+ <p>
212
+ These features will be nice to have in a second release of the library:
213
+ </p>
214
+ <ul>
215
+ <li>General purpose monadic parser library similar to Parsec, see <a
216
+ href="http://www.cs.uu.nl/~daan/parsec.html">www.cs.uu.nl/~daan/parsec.html</a>
217
+
218
+ </li>
219
+ <li>Tools for automatic program verification and algebraic proofs
220
+
221
+ </li>
222
+ <li>What else
223
+
224
+ </li>
225
+ </ul>
226
+ <h2>What&#8217;s in a name</h2>
227
+ <p>
228
+ Since most of the functionality to be implemented here is defined in
229
+ Haskell&#8217;s prelude package, the name <b><a
230
+ href="../classes/Prelude.html">Prelude</a></b> seemed natural.
231
+ </p>
232
+ <h2>Download</h2>
233
+ <p>
234
+ The latest <a href="../classes/Prelude.html">Prelude</a> library version
235
+ can be downloaded from <a
236
+ href="http://rubyforge.org/frs/?group_id=2096">rubyforge.org/frs/?group_id=2096</a>
237
+ </p>
238
+ <h2>Installation</h2>
239
+ <p>
240
+ You can install <a href="../classes/Prelude.html">Prelude</a> library with
241
+ the following command.
242
+ </p>
243
+ <pre>
244
+ % gem install prelude
245
+ </pre>
246
+ <h2>License</h2>
247
+ <p>
248
+ <a href="../classes/Prelude.html">Prelude</a> library is released under the
249
+ Lesser GPL license, see <a
250
+ href="http://www.gnu.org/licenses/lgpl.txt">www.gnu.org/licenses/lgpl.txt</a>
251
+ </p>
252
+ <h2>Support</h2>
253
+ <p>
254
+ Please use the following:
255
+ </p>
256
+ <ul>
257
+ <li>forums on Rubyforge for general discussions, <a
258
+ href="http://rubyforge.org/forum/?group_id=2096">rubyforge.org/forum/?group_id=2096</a>
259
+
260
+ </li>
261
+ <li>trackers to submit bugs or feature requests, <a
262
+ href="http://rubyforge.org/tracker/?group_id=2096">rubyforge.org/tracker/?group_id=2096</a>
263
+
264
+ </li>
265
+ <li>to contact the author, send mail to prelude rubyforge org
266
+
267
+ </li>
268
+ </ul>
269
+ <h2>References</h2>
270
+ <p>
271
+ The authors of the project were inspired by the following works:
272
+ </p>
273
+ <ol>
274
+ <li>An article, probably by Gavin Sinclair, at <a
275
+ href="http://blogs.pragprog.com/cgi-bin/pragdave.cgi/Tech/Ruby/ToProc.rdoc">blogs.pragprog.com/cgi-bin/pragdave.cgi/Tech/Ruby/ToProc.rdoc</a>
276
+ regarding <a href="../classes/Symbol.html#M000001">Symbol#to_proc</a>
277
+ function in Ruby Extension project, <a
278
+ href="http://extensions.rubyforge.org">extensions.rubyforge.org</a>
279
+
280
+ </li>
281
+ <li>An elaborate port of Perl&#8217;s Sub::Curry library by Ross Bamford, <a
282
+ href="http://rubyforge.org/projects/rubymurray">rubyforge.org/projects/rubymurray</a>
283
+
284
+ </li>
285
+ <li>An early implementation of Haskell&#8217;s lists as Ruby arrays by Hipster
286
+ (a.k.a. Michel van de Ven). His original sketch can be found at <a
287
+ href="http://www.xs4all.nl/~hipster/lib/ruby/haskell">www.xs4all.nl/~hipster/lib/ruby/haskell</a>
288
+
289
+ </li>
290
+ <li>An article by Christopher Williams &quot;Late to the Party&quot; posted at
291
+ <a
292
+ href="http://cwilliams.textdriven.com/pages/monads">cwilliams.textdriven.com/pages/monads</a>
293
+
294
+ </li>
295
+ <li>Several articles on monads by MenTaLguY, see <a
296
+ href="http://moonbase.rydia.net/mental/writings/programming/monads-in-ruby/00introduction.html">moonbase.rydia.net/mental/writings/programming/monads-in-ruby/00introduction.html</a>
297
+
298
+ </li>
299
+ </ol>
300
+
301
+ </div>
302
+
303
+
304
+ </div>
305
+
306
+
307
+ </div>
308
+
309
+
310
+ <!-- if includes -->
311
+
312
+ <div id="section">
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+ <!-- if method_list -->
322
+
323
+
324
+ </div>
325
+
326
+
327
+ </body>
328
+ </html>