Comments (3)
OK, I am not sure yet, but I think I've found an impure approach that achieves the sharing:
const Task = structGetter("Task")
(Task => k => Task(thisify(o => {
o.runTask = (res, rej) => k(x => {
o.runTask = l => l(x); // A
return res(x);
}, rej);
return o;
})));
Line A
is a destructive update. It isn't harmful though, because it simply replaces the asynchrnous computation with its result wrapped in a continuation. This shouldn't change the behavior of the program, as long as referential transparency holds.
Additionally, error cases are not shared as desired.
However, I need to test this in larger projects first.
from scriptum.
The last sharing approach also defers the impure effect (the destructive update of the Task
object) to the execution of the Task
computation when everything is impure anyways. That means everything remains pure until you run runTask
. Pure sharing so to speak.
from scriptum.
I've just tested it in a larger code base and it works as expected. This was a major issue and I am quite relieved that I could solve it. This issue can probably be closed in the next few days.
from scriptum.
Related Issues (20)
- Kind mismatches may throw unintentionally HOT 1
- `Functor` instance for the function type doesn't type validate
- Higher-rank types seem to be not always type safe HOT 1
- Codomain preservation fails with partially applied types
- > No description provided.
- tail recursion modulo cons doesn't work for higher order calls HOT 1
- adapt stream consumer to new Stream API HOT 1
- Does `Observable.Done` needs an argument for some edge cases? HOT 1
- Add right biased `Either` type to encode short circution instead of error HOT 1
- Add `Validate` type that collects exceptions HOT 1
- List combinators should rely on strict `foldl` and non-strict `foldr` HOT 1
- Can arrays be reconciled with lazy evaluation?
- Define `Eq` type class and implement all instances
- add `Serial.allObj`/`Parallel.allObj` HOT 1
- Define potential variant types with `variant` HOT 1
- Resolve deferred code dependencies in type dicts as well
- Derive `Sex`/`Pex` from `Serial`/`Parallel` + `Except.T` transformer HOT 1
- `A.empty` doesn't work due to mutations HOT 2
- Adjust existing monad transformers to new encoding HOT 1
- Can `S.once`/`P.once` be deleted? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scriptum.