effection 0.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9a86f883e64b3beecf0bb56e8f469ee6ce6e8d9e23606c0fd3594ca9a37f8105
4
+ data.tar.gz: aaf90c77c5cdf7155e43738f2d515cc0a6ab449515be049b30e5fc3b65cb3554
5
+ SHA512:
6
+ metadata.gz: e50e4b0107cab6d046d8719599c2e9e738e1a557e8316aee5a146b9518ab860dde2964851786ebe6b1360e4b93e9d94b146adb81a259264da57cb021520226eb
7
+ data.tar.gz: 823aabec55b71800d6cc2effda8dd5364c8914fb4eb40234c46933dd559165c28a76751cbe571b6e62077ce33da2b8c62541b8808852fe1eab1b5a28a44a4cce
@@ -0,0 +1,141 @@
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ lerna-debug.log*
8
+
9
+ # Diagnostic reports (https://nodejs.org/api/report.html)
10
+ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11
+
12
+ # Runtime data
13
+ pids
14
+ *.pid
15
+ *.seed
16
+ *.pid.lock
17
+
18
+ # Directory for instrumented libs generated by jscoverage/JSCover
19
+ lib-cov
20
+
21
+ # Coverage directory used by tools like istanbul
22
+ coverage
23
+ *.lcov
24
+
25
+ # nyc test coverage
26
+ .nyc_output
27
+
28
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29
+ .grunt
30
+
31
+ # Bower dependency directory (https://bower.io/)
32
+ bower_components
33
+
34
+ # node-waf configuration
35
+ .lock-wscript
36
+
37
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
38
+ build/Release
39
+
40
+ # Dependency directories
41
+ node_modules/
42
+ jspm_packages/
43
+
44
+ # Snowpack dependency directory (https://snowpack.dev/)
45
+ web_modules/
46
+
47
+ # TypeScript cache
48
+ *.tsbuildinfo
49
+
50
+ # Optional npm cache directory
51
+ .npm
52
+
53
+ # Optional eslint cache
54
+ .eslintcache
55
+
56
+ # Microbundle cache
57
+ .rpt2_cache/
58
+ .rts2_cache_cjs/
59
+ .rts2_cache_es/
60
+ .rts2_cache_umd/
61
+
62
+ # Optional REPL history
63
+ .node_repl_history
64
+
65
+ # Output of 'npm pack'
66
+ *.tgz
67
+
68
+ # Yarn Integrity file
69
+ .yarn-integrity
70
+
71
+ # dotenv environment variables file
72
+ .env
73
+ .env.test
74
+
75
+ # parcel-bundler cache (https://parceljs.org/)
76
+ .cache
77
+ .parcel-cache
78
+
79
+ # Next.js build output
80
+ .next
81
+ out
82
+
83
+ # Nuxt.js build / generate output
84
+ .nuxt
85
+ dist
86
+
87
+ # Gatsby files
88
+ .cache/
89
+ # Comment in the public line in if your project uses Gatsby and not Next.js
90
+ # https://nextjs.org/blog/next-9-1#public-directory-support
91
+ # public
92
+
93
+ # vuepress build output
94
+ .vuepress/dist
95
+
96
+ # Serverless directories
97
+ .serverless/
98
+
99
+ # FuseBox cache
100
+ .fusebox/
101
+
102
+ # DynamoDB Local files
103
+ .dynamodb/
104
+
105
+ # TernJS port file
106
+ .tern-port
107
+
108
+ # Stores VSCode versions used for testing VSCode extensions
109
+ .vscode-test
110
+
111
+ # yarn v2
112
+ .yarn/cache
113
+ .yarn/unplugged
114
+ .yarn/build-state.yml
115
+ .yarn/install-state.gz
116
+ .pnp.*
117
+
118
+ #Haskell
119
+ dist
120
+ dist-*
121
+ cabal-dev
122
+ *.o
123
+ *.hi
124
+ *.hie
125
+ *.chi
126
+ *.chs.h
127
+ *.dyn_o
128
+ *.dyn_hi
129
+ .hpc
130
+ .hsenv
131
+ .cabal-sandbox/
132
+ cabal.sandbox.config
133
+ *.prof
134
+ *.aux
135
+ *.hp
136
+ *.eventlog
137
+ .stack-work/
138
+ cabal.project.local
139
+ cabal.project.local~
140
+ .HTF/
141
+ .ghc.environment.*
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ gem 'minitest'
8
+
9
+ # gem "rails"
@@ -0,0 +1,13 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ minitest (5.14.2)
5
+
6
+ PLATFORMS
7
+ ruby
8
+
9
+ DEPENDENCIES
10
+ minitest
11
+
12
+ BUNDLED WITH
13
+ 2.1.4
@@ -0,0 +1,11 @@
1
+ require "rake/testtask"
2
+
3
+ task :install do
4
+ `bundle`
5
+ end
6
+
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.libs << "test"
9
+ t.libs << "lib"
10
+ t.test_files = FileList["./test/**/test_*.rb"]
11
+ end
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'effection'
3
+ s.version = '0.0.0'
4
+ s.date = '2020-11-03'
5
+ s.summary = "Algebraic effects for ruby"
6
+ s.description = "Now you can use Algebraic effects in ruby and it's so easy!"
7
+ s.authors = ["j-schectman"]
8
+ s.email = 'emotional@sensitivejon.com'
9
+ s.files = Dir.chdir(File.expand_path('..', __FILE__)) do
10
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
11
+ end
12
+ s.homepage = 'https://rubygems.org/gems/effection'
13
+ s.license = 'MIT'
14
+ end
@@ -0,0 +1 @@
1
+ require './effection/effects.rb'
@@ -0,0 +1,64 @@
1
+ require 'fiber'
2
+
3
+ class Effects
4
+ def initialize(initial_handlers = {}, parent = nil, &block)
5
+ @handlers = initial_handlers
6
+ @fib = Fiber.new(&block)
7
+ @parent = parent
8
+ __next()
9
+ end
10
+
11
+ def self.with(**initial_handlers, &block)
12
+ parent = nil
13
+ begin
14
+ Fiber.yield -> effector {
15
+ parent = effector
16
+ }
17
+ rescue FiberError
18
+ # Ignore it if it's Can't yield from Root fiber, for now? I guess
19
+ end
20
+ Effects.new(initial_handlers, parent, &block)
21
+ end
22
+
23
+ def self.listen(message, &handler)
24
+ Fiber.yield -> effector {
25
+ effector.__add_handler(message, &handler)
26
+ }
27
+ end
28
+
29
+ def self.effection(message, *args)
30
+ Fiber.yield -> effector {
31
+ effector.__handle(message, *args)
32
+ }
33
+ end
34
+
35
+ def effection(message, *args)
36
+ Fiber.yield -> effector {
37
+ effector.__handle(message, *args)
38
+ }
39
+ end
40
+
41
+ def __next(*newVal)
42
+ if @fib.alive?
43
+ # This state is paused here and then will only be hit when the containing fiber calls Yield.
44
+ cb = @fib.resume(*newVal)
45
+ ret_val = cb
46
+ if cb != nil and cb.respond_to? :call
47
+ ret_val = cb.(self)
48
+ end
49
+ __next(ret_val)
50
+ end
51
+ end
52
+
53
+ def __add_handler(message, &handler)
54
+ @handlers[message] = handler
55
+ end
56
+
57
+ def __handle(message, *args)
58
+ if @handlers[message]
59
+ res_with = @handlers[message].(*args)
60
+ elsif @parent != nil
61
+ res_with = @parent.effection(message, *args)
62
+ end
63
+ end
64
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: effection
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - j-schectman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-11-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Now you can use Algebraic effects in ruby and it's so easy!
14
+ email: emotional@sensitivejon.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".gitignore"
20
+ - Gemfile
21
+ - Gemfile.lock
22
+ - Rakefile
23
+ - effection.gemspec
24
+ - lib/effection.rb
25
+ - lib/effection/effects.rb
26
+ homepage: https://rubygems.org/gems/effection
27
+ licenses:
28
+ - MIT
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubygems_version: 3.1.2
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: Algebraic effects for ruby
49
+ test_files: []