monadist 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,22 @@
1
+ require 'monadist'
2
+
3
+ words = %w[apple tree]
4
+
5
+ p Monadist::Continuation.unit(words).
6
+ fmap { |array| array.map &:length }.
7
+ run
8
+
9
+
10
+ words = nil
11
+
12
+
13
+
14
+ def maybe(value)
15
+ Monadist::Continuation.new { |next_block| next_block.call value unless value.nil? }
16
+ end
17
+
18
+
19
+
20
+ p maybe(words).
21
+ fmap { |array| array.map &:length }.
22
+ run
data/examples/general.rb CHANGED
@@ -3,8 +3,8 @@ require 'monadist/shims'
3
3
  require 'json'
4
4
 
5
5
  nothing = possibly_nil nil
6
- maybe = possibly_nil '{"first_name":"Sam", "last_name":"Vimes"}'
7
- list = list '{"first_name":"Granny", "last_name":"Weatherwax"}', '{"first_name":"Nanny", "last_name":"Ogg"}'
6
+ just_value = possibly_nil '{"first_name":"Sam", "last_name":"Vimes"}'
7
+ json_list = list ['{"first_name":"Granny", "last_name":"Weatherwax"}', '{"first_name":"Nanny", "last_name":"Ogg"}']
8
8
  continuation = with '{"first_name":"Fred", "last_name":"Colon"}'
9
9
  meanwhile = meanwhile_with '{"first_name":"Nobby", "last_name":"Nobbs"}'
10
10
 
@@ -19,8 +19,8 @@ end
19
19
 
20
20
 
21
21
  p full_name(nothing).value
22
- p full_name(maybe).value
23
- p full_name(list).values
22
+ p full_name(just_value).value
23
+ p full_name(json_list).values
24
24
  full_name(continuation).run { |full_name| p full_name }
25
25
 
26
26
  full_name(meanwhile).run { |full_name| p full_name }
@@ -4,8 +4,8 @@ end
4
4
 
5
5
 
6
6
 
7
- def list(*values)
8
- Monadist::List.unit *values
7
+ def list(value)
8
+ Monadist::List.unit value
9
9
  end
10
10
 
11
11
 
@@ -1,3 +1,3 @@
1
1
  module Monadist
2
- VERSION = '0.1'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -2,6 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  describe Monadist do
4
4
  it 'should have a version number' do
5
- expect(Monadist::VERSION).to eq '0.1'
5
+ expect(Monadist::VERSION).to eq '0.1.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monadist
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-18 00:00:00.000000000 Z
12
+ date: 2014-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -75,6 +75,7 @@ files:
75
75
  - LICENSE.txt
76
76
  - README.md
77
77
  - Rakefile
78
+ - examples/continuation/acting_as_maybe.rb
78
79
  - examples/continuation/github_fetch_original.rb
79
80
  - examples/continuation/github_fetch_refactored_continuation.rb
80
81
  - examples/continuation/github_fetch_refactored_meanwhile.rb