funkr 0.0.30 → 0.0.40

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cb4f5366a7c1c68082cb5982e5cd7700440d94344fdfb8cdff7bd94b723bb4a
4
- data.tar.gz: 4c79978d034dbbc0fc650644808ca3de77efa6e934770a4602d09ea042891c01
3
+ metadata.gz: f5649962b565534f862b38ae383b658c1a5488822f5827ec87c1eb811d5c3037
4
+ data.tar.gz: e56a95ae98fd9d7d58d8da6243f4788ef078727a46af8ddd230be2ff926bd5fd
5
5
  SHA512:
6
- metadata.gz: e2767fe18dbf634574240a8b40acf5a8d42f2caa0770605a3b9b5e25ff62b9307552088da7a381f9c3a5e5ee3cb2b9dd2a6db93f7d8034b7ad6641d595cc5307
7
- data.tar.gz: c7110ff660fb041f5f09b63bff32e187c99fccfec855d75d1be99993115f1654255144185140cdd1b47dffc4c78d3a8d2fac0e4d60fe9ab2ab120ef05726c6ed
6
+ metadata.gz: 9f18403815d1715943156f2298babd16436a6979f75f86edbc8bb72e09e4b8f2a3d543a7c798ee61a4d21c42489afffad84cbba7d9a215dfaccc4da086d0f3a5
7
+ data.tar.gz: 8e82ba816b2a0b9fab4c1764a670364d137fbdf813699f5627448863a1565d8625a59b40f0273a5a265bc81fef6749afc4bfaaeefd9b22f415b0e5c4cd6c2f03
@@ -41,11 +41,20 @@ module Funkr
41
41
  @data.map(&:inspect).join(", ") )
42
42
  end
43
43
 
44
+
45
+ def ==(o)
46
+ case o
47
+ when ADT then self.normal_form == o.normal_form
48
+ else false
49
+ end
50
+ end
51
+
52
+ def normal_form; [@const, *@data]; end
53
+
44
54
  private
45
55
 
46
56
  attr_reader :const, :data
47
57
 
48
- def normal_form; [@const, *@data]; end
49
58
 
50
59
  def self.build_adt(constructs)
51
60
  constructs.each do |c,*d|
@@ -39,10 +39,6 @@ module Funkr
39
39
  proxy_comp(other){|a,b| a <=> b}
40
40
  end
41
41
 
42
- def ==(other)
43
- proxy_comp(other){|a,b| a == b}
44
- end
45
-
46
42
  def <(other)
47
43
  proxy_comp(other){|a,b| a < b}
48
44
  end
@@ -59,6 +55,9 @@ module Funkr
59
55
  proxy_comp(other){|a,b| a >= b}
60
56
  end
61
57
 
58
+ def applicative_equal?(other)
59
+ proxy_comp(other){|a,b| a == b}
60
+ end
62
61
 
63
62
  private
64
63
 
@@ -1,3 +1,3 @@
1
1
  module Funkr
2
- VERSION = "0.0.30"
2
+ VERSION = "0.0.40"
3
3
  end
@@ -16,7 +16,6 @@ class TestMaybe < Test::Unit::TestCase
16
16
 
17
17
  def test_map
18
18
  assert_equal(j(6), j(5).map{|v| v+1 })
19
- assert_equal(n, j(5).map{|v| v+1})
20
19
  end
21
20
 
22
21
  def test_curry_lift
@@ -57,8 +56,10 @@ class TestMaybe < Test::Unit::TestCase
57
56
  assert_equal(j(true), j(3) < j(7))
58
57
  assert_equal(n, j(4) <=> n)
59
58
  assert_equal(n, n <=> j(2))
59
+ assert_equal(j(false), j(5).applicative_equal?(j(7)))
60
60
  end
61
61
 
62
+
62
63
  def test_unbox
63
64
  assert_equal(5, j(5).unbox)
64
65
  assert_equal(5, j(5).unbox(2))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: funkr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.30
4
+ version: 0.0.40
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Rivier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-16 00:00:00.000000000 Z
11
+ date: 2020-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake