mangrove 0.4.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,176 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.9.34
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "README";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="file_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'>
61
+ <h1 id="label-Mangrove">Mangrove</h1>
62
+
63
+ <p>Mangrove provides type utility to use with Sorbet.</p>
64
+
65
+ <p>You can do something like this with the gem.</p>
66
+
67
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>MyClass</span>
68
+ <span class='id identifier rubyid_extend'>extend</span> <span class='const'>T</span><span class='op'>::</span><span class='const'>Sig</span>
69
+
70
+ <span class='id identifier rubyid_include'>include</span> <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/ControlFlow.html" title="Mangrove::ControlFlow (module)">ControlFlow</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/ControlFlow/Handler.html" title="Mangrove::ControlFlow::Handler (module)">Handler</a></span></span>
71
+
72
+ <span class='id identifier rubyid_sig'>sig</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_params'>params</span><span class='lparen'>(</span><span class='label'>numbers:</span> <span class='const'>T</span><span class='op'>::</span><span class='const'>Enumerable</span><span class='lbracket'>[</span><span class='const'>Integer</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result.html" title="Mangrove::Result (module)">Result</a></span></span><span class='lbracket'>[</span><span class='const'>T</span><span class='op'>::</span><span class='const'>Array</span><span class='lbracket'>[</span><span class='const'>Integer</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='const'>String</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
73
+ <span class='kw'>def</span> <span class='id identifier rubyid_divide_arguments_by_3'>divide_arguments_by_3</span><span class='lparen'>(</span><span class='id identifier rubyid_numbers'>numbers</span><span class='rparen'>)</span>
74
+ <span class='id identifier rubyid_divided_nubmers'>divided_nubmers</span> <span class='op'>=</span> <span class='id identifier rubyid_numbers'>numbers</span>
75
+ <span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_number'>number</span><span class='op'>|</span>
76
+ <span class='kw'>if</span> <span class='id identifier rubyid_number'>number</span> <span class='op'>%</span> <span class='int'>3</span> <span class='op'>==</span> <span class='int'>0</span>
77
+ <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result.html" title="Mangrove::Result (module)">Result</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result/Ok.html" title="Mangrove::Result::Ok (class)">Ok</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Mangrove/Result/Ok.html#initialize-instance_method" title="Mangrove::Result::Ok#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_number'>number</span> <span class='op'>/</span> <span class='int'>3</span><span class='rparen'>)</span>
78
+ <span class='kw'>else</span>
79
+ <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result.html" title="Mangrove::Result (module)">Result</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result/Err.html" title="Mangrove::Result::Err (class)">Err</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Mangrove/Result/Err.html#initialize-instance_method" title="Mangrove::Result::Err#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>number </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_number'>number</span><span class='embexpr_end'>}</span><span class='tstring_content'> is not divisible by 3</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
80
+ <span class='kw'>end</span>
81
+ <span class='rbrace'>}</span>
82
+ <span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:unwrap!</span><span class='rparen'>)</span>
83
+
84
+ <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result.html" title="Mangrove::Result (module)">Result</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result/Ok.html" title="Mangrove::Result::Ok (class)">Ok</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Mangrove/Result/Ok.html#initialize-instance_method" title="Mangrove::Result::Ok#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_divided_nubmers'>divided_nubmers</span><span class='rparen'>)</span>
85
+ <span class='kw'>end</span>
86
+ <span class='kw'>end</span>
87
+
88
+ <span class='id identifier rubyid_expect'>expect</span><span class='lparen'>(</span><span class='const'>MyClass</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='period'>.</span><span class='id identifier rubyid_divide_arguments_by_3'>divide_arguments_by_3</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>3</span><span class='comma'>,</span> <span class='int'>4</span><span class='comma'>,</span> <span class='int'>6</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to'>to</span> <span class='id identifier rubyid_eq'>eq</span> <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result.html" title="Mangrove::Result (module)">Result</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result/Err.html" title="Mangrove::Result::Err (class)">Err</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Mangrove/Result/Err.html#initialize-instance_method" title="Mangrove::Result::Err#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>number 4 is not divisible by 3</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
89
+ <span class='id identifier rubyid_expect'>expect</span><span class='lparen'>(</span><span class='const'>MyClass</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='period'>.</span><span class='id identifier rubyid_divide_arguments_by_3'>divide_arguments_by_3</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>3</span><span class='comma'>,</span> <span class='int'>6</span><span class='comma'>,</span> <span class='int'>9</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to'>to</span> <span class='id identifier rubyid_eq'>eq</span> <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result.html" title="Mangrove::Result (module)">Result</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result/Ok.html" title="Mangrove::Result::Ok (class)">Ok</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Mangrove/Result/Ok.html#initialize-instance_method" title="Mangrove::Result::Ok#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>2</span><span class='comma'>,</span> <span class='int'>3</span><span class='rbracket'>]</span><span class='rparen'>)</span>
90
+ </code></pre>
91
+
92
+ <p>Other examples are available at href="https://github.com/kazzix14/mangrove/tree/main/spec"></a>.</p>
93
+
94
+ <h2 id="label-Features">Features</h2>
95
+
96
+ <p>Most features are not implemented.</p>
97
+ <ul><li>
98
+ <p>[x] Option Type (Partially Implemented)</p>
99
+ </li><li>
100
+ <p>[x] Auto propagation like Rust’s <code>?</code> (formerly <code>try!</code>)</p>
101
+ </li><li>
102
+ <p>[x] Result Type (Partially Implemented)</p>
103
+ </li><li>
104
+ <p>[x] Auto propagation like Rust’s <code>?</code> (formerly <code>try!</code>)</p>
105
+ </li><li>
106
+ <p>[ ] Builder type (Not implemented)</p>
107
+ </li><li>
108
+ <p>[ ] Auto Implementation</p>
109
+ </li><li>
110
+ <p>[ ] TODO</p>
111
+ </li></ul>
112
+
113
+ <h2 id="label-Installation">Installation</h2>
114
+
115
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_bundle'>bundle</span> <span class='id identifier rubyid_add'>add</span> <span class='id identifier rubyid_mangrove'>mangrove</span>
116
+ </code></pre>
117
+
118
+ <h2 id="label-Usage">Usage</h2>
119
+
120
+ <p>Documentation is available <a href="https://kazzix14.github.io/mangrove/">here</a>. For more concrete examples, see href="https://github.com/kazzix14/mangrove/tree/main/spec"></a>.</p>
121
+
122
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result.html" title="Mangrove::Result (module)">Result</a></span></span><span class='lbracket'>[</span><span class='const'>OkType</span><span class='comma'>,</span> <span class='const'>ErrType</span><span class='rbracket'>]</span>
123
+ <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result.html" title="Mangrove::Result (module)">Result</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result/Ok.html" title="Mangrove::Result::Ok (class)">Ok</a></span></span><span class='lbracket'>[</span><span class='const'>OkType</span><span class='comma'>,</span> <span class='const'>ErrType</span><span class='rbracket'>]</span>
124
+ <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result.html" title="Mangrove::Result (module)">Result</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result/Err.html" title="Mangrove::Result::Err (class)">Err</a></span></span><span class='lbracket'>[</span><span class='const'>OkType</span><span class='comma'>,</span> <span class='const'>ErrType</span><span class='rbracket'>]</span>
125
+ <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Option.html" title="Mangrove::Option (module)">Option</a></span></span><span class='lbracket'>[</span><span class='const'>InnerType</span><span class='rbracket'>]</span>
126
+ <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Option.html" title="Mangrove::Option (module)">Option</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Option/Some.html" title="Mangrove::Option::Some (class)">Some</a></span></span><span class='lbracket'>[</span><span class='const'>InnerType</span><span class='rbracket'>]</span>
127
+ <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Option.html" title="Mangrove::Option (module)">Option</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Option/None.html" title="Mangrove::Option::None (class)">None</a></span></span><span class='lbracket'>[</span><span class='const'>InnerType</span><span class='rbracket'>]</span>
128
+
129
+ <span class='id identifier rubyid_my_ok'>my_ok</span> <span class='op'>=</span> <span class='const'>Result</span><span class='op'>::</span><span class='const'>Ok</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>my value</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
130
+ <span class='id identifier rubyid_my_err'>my_err</span> <span class='op'>=</span> <span class='const'>Result</span><span class='op'>::</span><span class='const'>Err</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>my err</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
131
+ <span class='id identifier rubyid_my_some'>my_some</span> <span class='op'>=</span> <span class='const'>Option</span><span class='op'>::</span><span class='const'>Some</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='int'>1234</span><span class='rparen'>)</span>
132
+ <span class='id identifier rubyid_my_none'>my_none</span> <span class='op'>=</span> <span class='const'>Option</span><span class='op'>::</span><span class='const'>None</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
133
+
134
+ <span class='comment'># Including this Module into your class appends rescue clause into its methods. Results to `Option#unwrap!` and `Result#unwrap!` propagates to calling method like Ruet&#39;s `?` operator.
135
+ </span><span class='comment'># https://doc.rust-lang.org/reference/expressions/operator-expr.html#the-question-mark-operator
136
+ </span><span class='id identifier rubyid_include'>include</span> <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/ControlFlow.html" title="Mangrove::ControlFlow (module)">ControlFlow</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/ControlFlow/Handler.html" title="Mangrove::ControlFlow::Handler (module)">Handler</a></span></span>
137
+ </code></pre>
138
+
139
+ <h2 id="label-Commands">Commands</h2>
140
+
141
+ <pre class="code ruby"><code class="ruby">git config core.hooksPath hooks
142
+ bundle exec tapioca init
143
+ bundle exec tapioca gems
144
+ bundle exec tapioca dsl
145
+ bundle exec tapioca check-shims
146
+ bundle exec tapioca init
147
+ bundle exec rspec -f d
148
+ bundle exec rubocop -DESP
149
+ bundle exec srb typecheck
150
+ bundle exec ordinare --check
151
+ bundle exec ruboclean
152
+ bundle exec yardoc -o docs/ --plugin yard-sorbet
153
+ rake build
154
+ rake release
155
+ </code></pre>
156
+
157
+ <h2 id="label-Development">Development</h2>
158
+
159
+ <p>After checking out the repo, run <code>bin/setup</code> to install dependencies. Then, run <code>rake test</code> to run the tests. You can also run <code>bin/console</code> for an interactive prompt that will allow you to experiment.</p>
160
+
161
+ <p>To install this gem onto your local machine, run <code>bundle exec rake install</code>. To release a new version, update the version number in <code>version.rb</code>, and then run <code>bundle exec rake release</code>, which will create a git tag for the version, push git commits and the created tag, and push the <code>.gem</code> file to <a href="https://rubygems.org">rubygems.org</a>.</p>
162
+
163
+ <h2 id="label-Contributing">Contributing</h2>
164
+
165
+ <p>Bug reports and pull requests are welcome on GitHub at <a href="https://github.com/kazzix14/mangrove">github.com/kazzix14/mangrove</a>.</p>
166
+ </div></div>
167
+
168
+ <div id="footer">
169
+ Generated on Fri Sep 1 17:32:57 2023 by
170
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
171
+ 0.9.34 (ruby-3.2.2).
172
+ </div>
173
+
174
+ </div>
175
+ </body>
176
+ </html>
@@ -0,0 +1,56 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
+ <meta charset="utf-8" />
6
+
7
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" />
8
+
9
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" />
10
+
11
+
12
+
13
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
16
+
17
+
18
+ <title>File List</title>
19
+ <base id="base_target" target="_parent" />
20
+ </head>
21
+ <body>
22
+ <div id="content">
23
+ <div class="fixed_header">
24
+ <h1 id="full_list_header">File List</h1>
25
+ <div id="full_list_nav">
26
+
27
+ <span><a target="_self" href="class_list.html">
28
+ Classes
29
+ </a></span>
30
+
31
+ <span><a target="_self" href="method_list.html">
32
+ Methods
33
+ </a></span>
34
+
35
+ <span><a target="_self" href="file_list.html">
36
+ Files
37
+ </a></span>
38
+
39
+ </div>
40
+
41
+ <div id="search">Search: <input type="text" /></div>
42
+ </div>
43
+
44
+ <ul id="full_list" class="file">
45
+
46
+
47
+ <li id="object_README" class="odd">
48
+ <div class="item"><span class="object_link"><a href="index.html" title="README">README</a></span></div>
49
+ </li>
50
+
51
+
52
+
53
+ </ul>
54
+ </div>
55
+ </body>
56
+ </html>
data/docs/frames.html ADDED
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Documentation by YARD 0.9.34</title>
6
+ </head>
7
+ <script type="text/javascript">
8
+ var match = unescape(window.location.hash).match(/^#!(.+)/);
9
+ var name = match ? match[1] : 'index.html';
10
+ name = name.replace(/^(\w+):\/\//, '').replace(/^\/\//, '');
11
+ window.top.location = name;
12
+ </script>
13
+ <noscript>
14
+ <h1>Oops!</h1>
15
+ <h2>YARD requires JavaScript!</h2>
16
+ </noscript>
17
+ </html>
data/docs/index.html ADDED
@@ -0,0 +1,176 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.9.34
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "README";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'>
61
+ <h1 id="label-Mangrove">Mangrove</h1>
62
+
63
+ <p>Mangrove provides type utility to use with Sorbet.</p>
64
+
65
+ <p>You can do something like this with the gem.</p>
66
+
67
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>MyClass</span>
68
+ <span class='id identifier rubyid_extend'>extend</span> <span class='const'>T</span><span class='op'>::</span><span class='const'>Sig</span>
69
+
70
+ <span class='id identifier rubyid_include'>include</span> <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/ControlFlow.html" title="Mangrove::ControlFlow (module)">ControlFlow</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/ControlFlow/Handler.html" title="Mangrove::ControlFlow::Handler (module)">Handler</a></span></span>
71
+
72
+ <span class='id identifier rubyid_sig'>sig</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_params'>params</span><span class='lparen'>(</span><span class='label'>numbers:</span> <span class='const'>T</span><span class='op'>::</span><span class='const'>Enumerable</span><span class='lbracket'>[</span><span class='const'>Integer</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result.html" title="Mangrove::Result (module)">Result</a></span></span><span class='lbracket'>[</span><span class='const'>T</span><span class='op'>::</span><span class='const'>Array</span><span class='lbracket'>[</span><span class='const'>Integer</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='const'>String</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
73
+ <span class='kw'>def</span> <span class='id identifier rubyid_divide_arguments_by_3'>divide_arguments_by_3</span><span class='lparen'>(</span><span class='id identifier rubyid_numbers'>numbers</span><span class='rparen'>)</span>
74
+ <span class='id identifier rubyid_divided_nubmers'>divided_nubmers</span> <span class='op'>=</span> <span class='id identifier rubyid_numbers'>numbers</span>
75
+ <span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_number'>number</span><span class='op'>|</span>
76
+ <span class='kw'>if</span> <span class='id identifier rubyid_number'>number</span> <span class='op'>%</span> <span class='int'>3</span> <span class='op'>==</span> <span class='int'>0</span>
77
+ <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result.html" title="Mangrove::Result (module)">Result</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result/Ok.html" title="Mangrove::Result::Ok (class)">Ok</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Mangrove/Result/Ok.html#initialize-instance_method" title="Mangrove::Result::Ok#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_number'>number</span> <span class='op'>/</span> <span class='int'>3</span><span class='rparen'>)</span>
78
+ <span class='kw'>else</span>
79
+ <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result.html" title="Mangrove::Result (module)">Result</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result/Err.html" title="Mangrove::Result::Err (class)">Err</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Mangrove/Result/Err.html#initialize-instance_method" title="Mangrove::Result::Err#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>number </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_number'>number</span><span class='embexpr_end'>}</span><span class='tstring_content'> is not divisible by 3</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
80
+ <span class='kw'>end</span>
81
+ <span class='rbrace'>}</span>
82
+ <span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:unwrap!</span><span class='rparen'>)</span>
83
+
84
+ <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result.html" title="Mangrove::Result (module)">Result</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result/Ok.html" title="Mangrove::Result::Ok (class)">Ok</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Mangrove/Result/Ok.html#initialize-instance_method" title="Mangrove::Result::Ok#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_divided_nubmers'>divided_nubmers</span><span class='rparen'>)</span>
85
+ <span class='kw'>end</span>
86
+ <span class='kw'>end</span>
87
+
88
+ <span class='id identifier rubyid_expect'>expect</span><span class='lparen'>(</span><span class='const'>MyClass</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='period'>.</span><span class='id identifier rubyid_divide_arguments_by_3'>divide_arguments_by_3</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>3</span><span class='comma'>,</span> <span class='int'>4</span><span class='comma'>,</span> <span class='int'>6</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to'>to</span> <span class='id identifier rubyid_eq'>eq</span> <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result.html" title="Mangrove::Result (module)">Result</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result/Err.html" title="Mangrove::Result::Err (class)">Err</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Mangrove/Result/Err.html#initialize-instance_method" title="Mangrove::Result::Err#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>number 4 is not divisible by 3</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
89
+ <span class='id identifier rubyid_expect'>expect</span><span class='lparen'>(</span><span class='const'>MyClass</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='period'>.</span><span class='id identifier rubyid_divide_arguments_by_3'>divide_arguments_by_3</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>3</span><span class='comma'>,</span> <span class='int'>6</span><span class='comma'>,</span> <span class='int'>9</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to'>to</span> <span class='id identifier rubyid_eq'>eq</span> <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result.html" title="Mangrove::Result (module)">Result</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result/Ok.html" title="Mangrove::Result::Ok (class)">Ok</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Mangrove/Result/Ok.html#initialize-instance_method" title="Mangrove::Result::Ok#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>2</span><span class='comma'>,</span> <span class='int'>3</span><span class='rbracket'>]</span><span class='rparen'>)</span>
90
+ </code></pre>
91
+
92
+ <p>Other examples are available at href="https://github.com/kazzix14/mangrove/tree/main/spec"></a>.</p>
93
+
94
+ <h2 id="label-Features">Features</h2>
95
+
96
+ <p>Most features are not implemented.</p>
97
+ <ul><li>
98
+ <p>[x] Option Type (Partially Implemented)</p>
99
+ </li><li>
100
+ <p>[x] Auto propagation like Rust’s <code>?</code> (formerly <code>try!</code>)</p>
101
+ </li><li>
102
+ <p>[x] Result Type (Partially Implemented)</p>
103
+ </li><li>
104
+ <p>[x] Auto propagation like Rust’s <code>?</code> (formerly <code>try!</code>)</p>
105
+ </li><li>
106
+ <p>[ ] Builder type (Not implemented)</p>
107
+ </li><li>
108
+ <p>[ ] Auto Implementation</p>
109
+ </li><li>
110
+ <p>[ ] TODO</p>
111
+ </li></ul>
112
+
113
+ <h2 id="label-Installation">Installation</h2>
114
+
115
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_bundle'>bundle</span> <span class='id identifier rubyid_add'>add</span> <span class='id identifier rubyid_mangrove'>mangrove</span>
116
+ </code></pre>
117
+
118
+ <h2 id="label-Usage">Usage</h2>
119
+
120
+ <p>Documentation is available <a href="https://kazzix14.github.io/mangrove/">here</a>. For more concrete examples, see href="https://github.com/kazzix14/mangrove/tree/main/spec"></a>.</p>
121
+
122
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result.html" title="Mangrove::Result (module)">Result</a></span></span><span class='lbracket'>[</span><span class='const'>OkType</span><span class='comma'>,</span> <span class='const'>ErrType</span><span class='rbracket'>]</span>
123
+ <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result.html" title="Mangrove::Result (module)">Result</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result/Ok.html" title="Mangrove::Result::Ok (class)">Ok</a></span></span><span class='lbracket'>[</span><span class='const'>OkType</span><span class='comma'>,</span> <span class='const'>ErrType</span><span class='rbracket'>]</span>
124
+ <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result.html" title="Mangrove::Result (module)">Result</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Result/Err.html" title="Mangrove::Result::Err (class)">Err</a></span></span><span class='lbracket'>[</span><span class='const'>OkType</span><span class='comma'>,</span> <span class='const'>ErrType</span><span class='rbracket'>]</span>
125
+ <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Option.html" title="Mangrove::Option (module)">Option</a></span></span><span class='lbracket'>[</span><span class='const'>InnerType</span><span class='rbracket'>]</span>
126
+ <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Option.html" title="Mangrove::Option (module)">Option</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Option/Some.html" title="Mangrove::Option::Some (class)">Some</a></span></span><span class='lbracket'>[</span><span class='const'>InnerType</span><span class='rbracket'>]</span>
127
+ <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Option.html" title="Mangrove::Option (module)">Option</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/Option/None.html" title="Mangrove::Option::None (class)">None</a></span></span><span class='lbracket'>[</span><span class='const'>InnerType</span><span class='rbracket'>]</span>
128
+
129
+ <span class='id identifier rubyid_my_ok'>my_ok</span> <span class='op'>=</span> <span class='const'>Result</span><span class='op'>::</span><span class='const'>Ok</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>my value</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
130
+ <span class='id identifier rubyid_my_err'>my_err</span> <span class='op'>=</span> <span class='const'>Result</span><span class='op'>::</span><span class='const'>Err</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>my err</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
131
+ <span class='id identifier rubyid_my_some'>my_some</span> <span class='op'>=</span> <span class='const'>Option</span><span class='op'>::</span><span class='const'>Some</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='int'>1234</span><span class='rparen'>)</span>
132
+ <span class='id identifier rubyid_my_none'>my_none</span> <span class='op'>=</span> <span class='const'>Option</span><span class='op'>::</span><span class='const'>None</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
133
+
134
+ <span class='comment'># Including this Module into your class appends rescue clause into its methods. Results to `Option#unwrap!` and `Result#unwrap!` propagates to calling method like Ruet&#39;s `?` operator.
135
+ </span><span class='comment'># https://doc.rust-lang.org/reference/expressions/operator-expr.html#the-question-mark-operator
136
+ </span><span class='id identifier rubyid_include'>include</span> <span class='const'><span class='object_link'><a href="Mangrove.html" title="Mangrove (module)">Mangrove</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/ControlFlow.html" title="Mangrove::ControlFlow (module)">ControlFlow</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mangrove/ControlFlow/Handler.html" title="Mangrove::ControlFlow::Handler (module)">Handler</a></span></span>
137
+ </code></pre>
138
+
139
+ <h2 id="label-Commands">Commands</h2>
140
+
141
+ <pre class="code ruby"><code class="ruby">git config core.hooksPath hooks
142
+ bundle exec tapioca init
143
+ bundle exec tapioca gems
144
+ bundle exec tapioca dsl
145
+ bundle exec tapioca check-shims
146
+ bundle exec tapioca init
147
+ bundle exec rspec -f d
148
+ bundle exec rubocop -DESP
149
+ bundle exec srb typecheck
150
+ bundle exec ordinare --check
151
+ bundle exec ruboclean
152
+ bundle exec yardoc -o docs/ --plugin yard-sorbet
153
+ rake build
154
+ rake release
155
+ </code></pre>
156
+
157
+ <h2 id="label-Development">Development</h2>
158
+
159
+ <p>After checking out the repo, run <code>bin/setup</code> to install dependencies. Then, run <code>rake test</code> to run the tests. You can also run <code>bin/console</code> for an interactive prompt that will allow you to experiment.</p>
160
+
161
+ <p>To install this gem onto your local machine, run <code>bundle exec rake install</code>. To release a new version, update the version number in <code>version.rb</code>, and then run <code>bundle exec rake release</code>, which will create a git tag for the version, push git commits and the created tag, and push the <code>.gem</code> file to <a href="https://rubygems.org">rubygems.org</a>.</p>
162
+
163
+ <h2 id="label-Contributing">Contributing</h2>
164
+
165
+ <p>Bug reports and pull requests are welcome on GitHub at <a href="https://github.com/kazzix14/mangrove">github.com/kazzix14/mangrove</a>.</p>
166
+ </div></div>
167
+
168
+ <div id="footer">
169
+ Generated on Fri Sep 1 17:32:57 2023 by
170
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
171
+ 0.9.34 (ruby-3.2.2).
172
+ </div>
173
+
174
+ </div>
175
+ </body>
176
+ </html>