ruff 0.0.2
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 +7 -0
- data/.gitignore +59 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +20 -0
- data/LICENSE +21 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/lib/ruff.rb +17 -0
- data/lib/ruff/effect.rb +12 -0
- data/lib/ruff/handler.rb +60 -0
- data/lib/ruff/objects.rb +15 -0
- data/lib/ruff/version.rb +3 -0
- data/ruff.gemspec +26 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3e1d601e4f8fc1c747d2e01df257b9b4c16924ee1c4f37802b5f7224b8ee6b9b
|
4
|
+
data.tar.gz: 6c7d3dfffcdfce09b91a8c88fa509bc3d0e4adf02d6f2fe74af3db5556af1b97
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4119ed8d393989929859c02b5982403a00c1b0a64e3cd6de69803c63b1c6df71ca160c7f30f6b26f77c7cbd6d464475fdd282a14fe226953e35e818415168967
|
7
|
+
data.tar.gz: 3fe820594df98146b5c6990d69d0e29af7691733042f9cdc22b02a31251913cc1825d899deb88d5150b50f414e94abca94248c6b54e7712088bbe4ab327791f8
|
data/.gitignore
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
|
2
|
+
# Created by https://www.gitignore.io/api/ruby
|
3
|
+
# Edit at https://www.gitignore.io/?templates=ruby
|
4
|
+
|
5
|
+
### Ruby ###
|
6
|
+
*.gem
|
7
|
+
*.rbc
|
8
|
+
/.config
|
9
|
+
/coverage/
|
10
|
+
/InstalledFiles
|
11
|
+
/pkg/
|
12
|
+
/spec/reports/
|
13
|
+
/spec/examples.txt
|
14
|
+
/test/tmp/
|
15
|
+
/test/version_tmp/
|
16
|
+
/tmp/
|
17
|
+
|
18
|
+
# Used by dotenv library to load environment variables.
|
19
|
+
# .env
|
20
|
+
|
21
|
+
# Ignore Byebug command history file.
|
22
|
+
.byebug_history
|
23
|
+
|
24
|
+
## Specific to RubyMotion:
|
25
|
+
.dat*
|
26
|
+
.repl_history
|
27
|
+
build/
|
28
|
+
*.bridgesupport
|
29
|
+
build-iPhoneOS/
|
30
|
+
build-iPhoneSimulator/
|
31
|
+
|
32
|
+
## Specific to RubyMotion (use of CocoaPods):
|
33
|
+
#
|
34
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
35
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
36
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
37
|
+
# vendor/Pods/
|
38
|
+
|
39
|
+
## Documentation cache and generated files:
|
40
|
+
/.yardoc/
|
41
|
+
/_yardoc/
|
42
|
+
/doc/
|
43
|
+
/rdoc/
|
44
|
+
|
45
|
+
## Environment normalization:
|
46
|
+
/.bundle/
|
47
|
+
/vendor/bundle
|
48
|
+
/lib/bundler/man/
|
49
|
+
|
50
|
+
# for a library or gem, you might want to ignore these files since the code is
|
51
|
+
# intended to run in multiple environments; otherwise, check them in:
|
52
|
+
# Gemfile.lock
|
53
|
+
# .ruby-version
|
54
|
+
# .ruby-gemset
|
55
|
+
|
56
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
57
|
+
.rvmrc
|
58
|
+
|
59
|
+
# End of https://www.gitignore.io/api/ruby
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 Nymphium
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
ruff
|
2
|
+
==
|
3
|
+
|
4
|
+
ONE-SHOT Algebraic Effects Library for Ruby!
|
5
|
+
|
6
|
+
```ruby
|
7
|
+
require 'ruff'
|
8
|
+
|
9
|
+
double = Ruff.instance
|
10
|
+
log = Ruff.instance
|
11
|
+
|
12
|
+
h1 = Ruff.handler.on(double, ->(k, v){
|
13
|
+
k[v * 2]
|
14
|
+
})
|
15
|
+
|
16
|
+
h2 = Ruff.handler.on(log, ->(k, msg){
|
17
|
+
k[]
|
18
|
+
puts "logger: #{msg}"
|
19
|
+
})
|
20
|
+
|
21
|
+
h1.run{
|
22
|
+
h2.run{
|
23
|
+
v = double.perform 2
|
24
|
+
log.perform (v + 2)
|
25
|
+
puts "ok"
|
26
|
+
}
|
27
|
+
}
|
28
|
+
# ==> prints
|
29
|
+
# ok
|
30
|
+
# logger: 6
|
31
|
+
```
|
data/Rakefile
ADDED
data/lib/ruff.rb
ADDED
data/lib/ruff/effect.rb
ADDED
data/lib/ruff/handler.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
module Ruff
|
2
|
+
class Handler
|
3
|
+
def initialize
|
4
|
+
@handlers = Hash.new
|
5
|
+
end
|
6
|
+
|
7
|
+
def on(eff, prc)
|
8
|
+
@handlers[eff.id] = prc
|
9
|
+
|
10
|
+
self
|
11
|
+
end
|
12
|
+
|
13
|
+
def run(&prc)
|
14
|
+
co = Fiber.new &prc
|
15
|
+
continue = nil
|
16
|
+
rehandles = nil
|
17
|
+
|
18
|
+
handle = ->(r) {
|
19
|
+
if r.is_a? Eff
|
20
|
+
if effh = @handlers[r.id]
|
21
|
+
effh[continue, *r.args]
|
22
|
+
else
|
23
|
+
Fiber.yield (Resend.new r, continue)
|
24
|
+
end
|
25
|
+
elsif r.is_a? Resend
|
26
|
+
if effh = @handlers[r.eff.id]
|
27
|
+
effh[rehandles[r.k], *r.eff.args]
|
28
|
+
else
|
29
|
+
Fiber.yield (Resend.new r, rehandles[r.k])
|
30
|
+
end
|
31
|
+
else
|
32
|
+
r
|
33
|
+
end
|
34
|
+
}
|
35
|
+
|
36
|
+
rehandles = ->(k){
|
37
|
+
newh = self.class.new
|
38
|
+
def newh.add_handler id, h
|
39
|
+
@handlers[id] = h
|
40
|
+
end
|
41
|
+
|
42
|
+
@handlers.each{|id, h|
|
43
|
+
newh.add_handler id, h
|
44
|
+
}
|
45
|
+
|
46
|
+
->(*args) {
|
47
|
+
newh.run {
|
48
|
+
k[*args]
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
continue = ->(*arg) {
|
54
|
+
handle[co.resume(*arg)]
|
55
|
+
}
|
56
|
+
|
57
|
+
continue[nil]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/ruff/objects.rb
ADDED
data/lib/ruff/version.rb
ADDED
data/ruff.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "ruff/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ruff"
|
8
|
+
spec.version = Ruff::VERSION
|
9
|
+
spec.authors = ["nymphium"]
|
10
|
+
spec.email = ["s1311350@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{ONE-SHOT Algebraic Effects for Ruby!}
|
13
|
+
spec.description = %q{ONE-SHOT Algebraic Effects for Ruby!}
|
14
|
+
spec.homepage = "https://github.com/nymphium/ruff"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruff
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- nymphium
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: ONE-SHOT Algebraic Effects for Ruby!
|
42
|
+
email:
|
43
|
+
- s1311350@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- LICENSE
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/ruff.rb
|
55
|
+
- lib/ruff/effect.rb
|
56
|
+
- lib/ruff/handler.rb
|
57
|
+
- lib/ruff/objects.rb
|
58
|
+
- lib/ruff/version.rb
|
59
|
+
- ruff.gemspec
|
60
|
+
homepage: https://github.com/nymphium/ruff
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubygems_version: 3.0.4
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: ONE-SHOT Algebraic Effects for Ruby!
|
83
|
+
test_files: []
|