arrows 0.0.6 → 0.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2ba1c064128e5483f807aa5367fa65bdd302598
4
- data.tar.gz: 18024be7545a1a587b2d7c86a743b3f20c99e62a
3
+ metadata.gz: bb1d6b49e76a181dd98eb7bcde57d2f0c84b6602
4
+ data.tar.gz: 8b47d2612b4a9a869afa8b2e562c0cecb34368fe
5
5
  SHA512:
6
- metadata.gz: fafb6881ac9cafa72974919a52bb141c9ecb3fb33674ccc784609be69e32980fc0366acbfb889182798b66111298061bce72a3cc501673ca9b3ff366cd1ff718
7
- data.tar.gz: ba107db1e9864f19086282c19a4fa51248743faad98f16735826c7a0e99ac82fda5ffd09afced6d94b41a4dbb88176fcb364c96d96db5bd54ce3f0f6cf182b16
6
+ metadata.gz: 67cc2d97b5389402faa9c2158804ce58337a2922116441427a5bb376c76fa7b513c71e95d0a6802bbdda8d222cd503612a7fd017c989500823239820736abf12
7
+ data.tar.gz: 24efe4588f422bea91b67a15f44b45f0fc5e109c63f3766747cc72df8934ac9defbcaf51820e4f6528fcdf1c64af6a3f9fe91ceaf5d5a4835e5dda151f137f1e
data/arrows.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Thomas Chen"]
10
10
  spec.email = ["foxnewsnetwork@gmail.com"]
11
11
  spec.summary = %q{Functional programming with composable, applicable, and arrowable functions.}
12
- spec.description = %q{Introduces a Arrows::Proc class which allows for piping processes.}
12
+ spec.description = %q{Haskell-like Arrow functionality to procs, includes commonly useful functional junk such as function composition, fanout, functor map composition, parallel composition, fork composition, context lifting, and memoization.}
13
13
  spec.homepage = "http://github.com/foxnewsnetwork/arrows"
14
14
  spec.license = "MIT"
15
15
 
data/lib/arrows/proc.rb CHANGED
@@ -23,4 +23,10 @@ class Arrows::Proc < Proc
23
23
  def ^(f)
24
24
  Arrows.fork self, f
25
25
  end
26
+
27
+ # Returns a memoizing version of this proc
28
+ def memoize
29
+ cache = {}
30
+ Arrows.lift -> (args) { cache.has_key?(args) ? cache[args] : (cache[args] = self[args]) }
31
+ end
26
32
  end
@@ -1,3 +1,3 @@
1
1
  module Arrows
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -5,6 +5,14 @@ RSpec.describe Arrows::Proc do
5
5
  subject { Arrows::ID }
6
6
  specify { should be_a Proc }
7
7
  end
8
+ context 'memoize' do
9
+ let(:plus_random) { -> (x) { x + rand(9999999999) } }
10
+ let(:twelve) { Arrows.lift 4 }
11
+ let(:twenty_two) { (twelve >> plus_random).memoize }
12
+ subject { twenty_two.call }
13
+ specify { should eq twenty_two.call }
14
+ end
15
+
8
16
  context '>> composition' do
9
17
  let(:times2) { -> (x) { x * 2 } }
10
18
  let(:plus3) { -> (x) { x + 3 } }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arrows
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Chen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-10 00:00:00.000000000 Z
11
+ date: 2014-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,7 +66,9 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2.3'
69
- description: Introduces a Arrows::Proc class which allows for piping processes.
69
+ description: Haskell-like Arrow functionality to procs, includes commonly useful functional
70
+ junk such as function composition, fanout, functor map composition, parallel composition,
71
+ fork composition, context lifting, and memoization.
70
72
  email:
71
73
  - foxnewsnetwork@gmail.com
72
74
  executables: []