funkr 0.0.5 → 0.0.6

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.
data/lib/funkr.rb CHANGED
@@ -1,3 +1,7 @@
1
+ if RUBY_VERSION.split(".")[0..1] == ["1","8"] then
2
+ require 'funkr/compat/1.8'
3
+ end
4
+
1
5
  module Funkr
2
- # nada ...
6
+ # constructs defined in submodules
3
7
  end
@@ -0,0 +1,49 @@
1
+ class Proc
2
+
3
+ def curry
4
+ case self.arity
5
+ when 2 then curry2
6
+ when 3 then curry3
7
+ when 4 then curry4
8
+ when 5 then curry5
9
+ else raise "Can't curry more than 5 arguments"
10
+ end
11
+ end
12
+
13
+ def curry2
14
+ lambda{|a|
15
+ lambda{|b| self.call(a,b)}}
16
+ end
17
+
18
+ def curry3
19
+ lambda{|a|
20
+ lambda{|b|
21
+ lambda{|c| self.call(a,b,c)}}}
22
+ end
23
+
24
+ def curry4
25
+ lambda{|a|
26
+ lambda{|b|
27
+ lambda{|c|
28
+ lambda{|d| self.call(a,b,c,d)}}}}
29
+ end
30
+
31
+ def curry5
32
+ lambda{|a|
33
+ lambda{|b|
34
+ lambda{|c|
35
+ lambda{|d|
36
+ lambda{|e| self.call(a,b,c,d,e)}}}}}
37
+ end
38
+
39
+ end
40
+
41
+ class Object
42
+ def define_singleton_method(name, &block)
43
+ singleton = class << self; self end
44
+ singleton.send(:define_method, name) do |*args|
45
+ block.call(*args)
46
+ end
47
+ end
48
+ end
49
+
@@ -71,7 +71,6 @@ module Funkr
71
71
  end
72
72
  end
73
73
 
74
-
75
74
  class << self
76
75
  alias unit just
77
76
  alias pure just
data/lib/funkr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Funkr
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/test/tests.rb CHANGED
@@ -1,4 +1,7 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
2
+
1
3
  require 'rubygems'
4
+ require 'funkr'
2
5
  require 'funkr/types'
3
6
  require 'funkr/extensions'
4
7
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: funkr
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 19
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 5
9
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
10
11
  platform: ruby
11
12
  authors:
12
13
  - Paul Rivier
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-03-11 00:00:00 +01:00
18
+ date: 2011-03-14 00:00:00 +01:00
18
19
  default_executable:
19
20
  dependencies: []
20
21
 
@@ -41,6 +42,7 @@ files:
41
42
  - lib/funkr/categories/functor.rb
42
43
  - lib/funkr/categories/monad.rb
43
44
  - lib/funkr/categories/monoid.rb
45
+ - lib/funkr/compat/1.8.rb
44
46
  - lib/funkr/extensions.rb
45
47
  - lib/funkr/extensions/array.rb
46
48
  - lib/funkr/extensions/fixnum.rb
@@ -63,6 +65,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
65
  requirements:
64
66
  - - ">="
65
67
  - !ruby/object:Gem::Version
68
+ hash: 3
66
69
  segments:
67
70
  - 0
68
71
  version: "0"
@@ -71,13 +74,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
74
  requirements:
72
75
  - - ">="
73
76
  - !ruby/object:Gem::Version
77
+ hash: 3
74
78
  segments:
75
79
  - 0
76
80
  version: "0"
77
81
  requirements: []
78
82
 
79
83
  rubyforge_project: funkr
80
- rubygems_version: 1.3.7
84
+ rubygems_version: 1.4.2
81
85
  signing_key:
82
86
  specification_version: 3
83
87
  summary: "[EXPERIMENTAL] Some functionnal constructs for ruby"