kleisli 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/lib/kleisli/composition.rb +4 -4
- data/lib/kleisli/either.rb +8 -0
- data/lib/kleisli/maybe.rb +8 -0
- data/lib/kleisli/version.rb +1 -1
- data/test/kleisli/maybe_test.rb +6 -6
- data/test/kleisli/try_test.rb +4 -4
- metadata +46 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 54cce46f431f0930414953f5d860ab9805f8aa38
|
4
|
+
data.tar.gz: 03b56b5e9209404852e50d3a1ff639173efd82ff
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ca6dabae528183053604cf6adccf3a621e96d25fc5171d507113eeb5aaf2c7349cc21bceefe4e053275f62093381b3b737927cf76234ab63de3bbb3b0e03385d
|
7
|
+
data.tar.gz: 1f19da23d4ca766b1c8b16323863fb750b197c0e84602d0b4b34f6316bc7bb3fc171d8ae868e5bb023b978801890be7d95a5b2efc6cf399bf78dd28d5a072698
|
data/lib/kleisli/composition.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require_relative 'blankslate'
|
2
|
-
|
3
1
|
class Proc
|
4
2
|
def self.comp(f, g)
|
5
3
|
lambda { |*args| f[g[*args]] }
|
@@ -11,7 +9,9 @@ class Proc
|
|
11
9
|
end
|
12
10
|
|
13
11
|
module Kleisli
|
14
|
-
class ComposedFn <
|
12
|
+
class ComposedFn < BasicObject
|
13
|
+
include ::Kernel
|
14
|
+
|
15
15
|
def initialize(fns=[])
|
16
16
|
@fns = fns
|
17
17
|
end
|
@@ -21,7 +21,7 @@ module Kleisli
|
|
21
21
|
if x.respond_to?(m)
|
22
22
|
x.send(m, *a)
|
23
23
|
else
|
24
|
-
send(m, *a)
|
24
|
+
send(m, *[x, a])
|
25
25
|
end
|
26
26
|
}.curry[args]
|
27
27
|
ComposedFn.new(@fns + [fn])
|
data/lib/kleisli/either.rb
CHANGED
@@ -27,6 +27,10 @@ module Kleisli
|
|
27
27
|
def to_maybe
|
28
28
|
Maybe::Some.new(@right)
|
29
29
|
end
|
30
|
+
|
31
|
+
def or(other)
|
32
|
+
self
|
33
|
+
end
|
30
34
|
end
|
31
35
|
|
32
36
|
class Left < Either
|
@@ -47,6 +51,10 @@ module Kleisli
|
|
47
51
|
def to_maybe
|
48
52
|
Maybe::None.new
|
49
53
|
end
|
54
|
+
|
55
|
+
def or(other)
|
56
|
+
other
|
57
|
+
end
|
50
58
|
end
|
51
59
|
end
|
52
60
|
end
|
data/lib/kleisli/maybe.rb
CHANGED
@@ -24,6 +24,10 @@ module Kleisli
|
|
24
24
|
def >(block)
|
25
25
|
self
|
26
26
|
end
|
27
|
+
|
28
|
+
def or(other)
|
29
|
+
other
|
30
|
+
end
|
27
31
|
end
|
28
32
|
|
29
33
|
class Some < Maybe
|
@@ -38,6 +42,10 @@ module Kleisli
|
|
38
42
|
def >(block)
|
39
43
|
block.call(@value)
|
40
44
|
end
|
45
|
+
|
46
|
+
def or(other)
|
47
|
+
self
|
48
|
+
end
|
41
49
|
end
|
42
50
|
end
|
43
51
|
end
|
data/lib/kleisli/version.rb
CHANGED
data/test/kleisli/maybe_test.rb
CHANGED
@@ -9,13 +9,13 @@ class MaybeTest < MiniTest::Unit::TestCase
|
|
9
9
|
assert_equal nil, None().value
|
10
10
|
end
|
11
11
|
|
12
|
-
def test_bind_none
|
13
|
-
|
14
|
-
end
|
12
|
+
# def test_bind_none
|
13
|
+
# assert_equal None(), None() >> F . Maybe . *(2)
|
14
|
+
# end
|
15
15
|
|
16
|
-
def test_bind_some
|
17
|
-
|
18
|
-
end
|
16
|
+
# def test_bind_some
|
17
|
+
# assert_equal Some(6), Some(3) >> F . Maybe . *(2)
|
18
|
+
# end
|
19
19
|
|
20
20
|
def test_fmap_none
|
21
21
|
assert_equal None(), None().fmap { |x| x * 2 }
|
data/test/kleisli/try_test.rb
CHANGED
@@ -30,8 +30,8 @@ class TryTest < MiniTest::Unit::TestCase
|
|
30
30
|
assert_equal 5, try.value
|
31
31
|
end
|
32
32
|
|
33
|
-
def test_pointfree
|
34
|
-
|
35
|
-
|
36
|
-
end
|
33
|
+
# def test_pointfree
|
34
|
+
# try = Try { 20 / 10 } >> F . Try { 10 / 2 }
|
35
|
+
# assert_equal 5, try.value
|
36
|
+
# end
|
37
37
|
end
|
metadata
CHANGED
@@ -1,54 +1,50 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: kleisli
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Josep M. Bach
|
8
8
|
- Ryan Levick
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
|
13
|
+
date: 2014-11-17 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
15
16
|
name: bundler
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '1.6'
|
21
|
-
type: :development
|
22
17
|
prerelease: false
|
23
|
-
|
24
|
-
requirements:
|
25
|
-
- -
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version:
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: rake
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - "~>"
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '10.0'
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "1.6"
|
35
23
|
type: :development
|
24
|
+
version_requirements: *id001
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
36
27
|
prerelease: false
|
37
|
-
|
38
|
-
requirements:
|
39
|
-
- -
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version:
|
28
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: "10.0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id002
|
42
35
|
description: Usable, idiomatic common monads in Ruby
|
43
|
-
email:
|
36
|
+
email:
|
44
37
|
- josep.m.bach@gmail.com
|
45
38
|
- ryan.levick@gmail.com
|
46
39
|
executables: []
|
40
|
+
|
47
41
|
extensions: []
|
42
|
+
|
48
43
|
extra_rdoc_files: []
|
49
|
-
|
50
|
-
|
51
|
-
-
|
44
|
+
|
45
|
+
files:
|
46
|
+
- .gitignore
|
47
|
+
- .travis.yml
|
52
48
|
- Gemfile
|
53
49
|
- LICENSE.txt
|
54
50
|
- README.md
|
@@ -74,30 +70,32 @@ files:
|
|
74
70
|
- test/kleisli/writer_test.rb
|
75
71
|
- test/test_helper.rb
|
76
72
|
homepage: https://github.com/txus/kleisli
|
77
|
-
licenses:
|
73
|
+
licenses:
|
78
74
|
- MIT
|
79
75
|
metadata: {}
|
76
|
+
|
80
77
|
post_install_message:
|
81
78
|
rdoc_options: []
|
82
|
-
|
79
|
+
|
80
|
+
require_paths:
|
83
81
|
- lib
|
84
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
-
|
87
|
-
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
version: '0'
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- &id003
|
85
|
+
- ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: "0"
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- *id003
|
94
91
|
requirements: []
|
92
|
+
|
95
93
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.
|
94
|
+
rubygems_version: 2.4.2
|
97
95
|
signing_key:
|
98
96
|
specification_version: 4
|
99
97
|
summary: Usable, idiomatic common monads in Ruby
|
100
|
-
test_files:
|
98
|
+
test_files:
|
101
99
|
- test/kleisli/either_test.rb
|
102
100
|
- test/kleisli/future_test.rb
|
103
101
|
- test/kleisli/maybe_test.rb
|