Comments (7)
Yes. This is tricky.
from fantasy-land.
Importing discussion with @Twisol about equality and the event loop.
My understanding of what has been said:
- Promises/A+ forbids the argument to
then
to be called synchronously. - Depending on the notion of equality, the monad laws may require the argument to
then
to be called synchronously. - @Twisol has experienced challenges that led to distinguishing
Present
andFuture
promises, in order to have predictable ordering of side effects.
My suggestion is to work out a notion of equality for promises that allows the laws to hold regardless of synchrony, and to order side effects with the usual concurrency control mechanisms. The notion of equality must not forbid such mechanisms from working - waiting on a mutex before delivering a value should be equivalent to delivering it immediately.
The implication for Fantasy Land is simply that equality should be defined by the monad/functor/values in question, and that side effects remain up to the programmer to sort out.
from fantasy-land.
Just to clarify, you advocate pushing the issue of side-effects downstream to the individual monad implementations?
from fantasy-land.
Exactly.
from fantasy-land.
Okay. I don't really have a problem with that, but I would hate to see a monad implementation that didn't adequately address it somehow.
from fantasy-land.
I agree with the concern. In the case of promises + concurrency side effects the two are clearly intimately related so worth discussion in the docs for any implementation of promises.
But I would expect most monad implementations to pass the buck downstream to users, especially data-oriented monads such as List
, Maybe
, Either
, or the free monad. Wouldn't make much sense to talk about side effects in those cases; hopefully programmers know what they are getting into when they use side-effects in a list comprehension (I do this all the time via knockout + underscore).
But I want to emphasize that this issue is a necessary discussion in all cases, even the very simple ones, because [1, 2, 3] === [1, 2, 3]
is false, as is {inLeft: 1} === {inLeft: 1}
from fantasy-land.
That's fair. I think we should have a section of the spec on things that must be addressed somehow downstream, even if we don't prescribe a particular approach. These things seem to come up because of the imperative domain, and they can't be naively ignored.
from fantasy-land.
Related Issues (20)
- [Question] Type signature for ap HOT 2
- Adding Folktale to implementations.md
- Equivalent for Serial typeclass? HOT 1
- Is really necessary specify "No parts of <...> value should be checked"? HOT 11
- Add Traversable1 HOT 3
- Help understanding use of identity in Traversable laws HOT 2
- Fantasy Land specification version number HOT 1
- Switch to Symbols HOT 2
- Wrong argument in Traversable HOT 4
- Is monet.js compatible? HOT 1
- Why FL specifies the ChainRec typeclass when there is the trampoline monad? HOT 7
- What does "and" mean? HOT 2
- Can someone explain me how I should understand Semigroup? HOT 5
- Remove all OOP features HOT 21
- Traversable and Foldable use multiple variables as arguments HOT 12
- Profunctor should require Contravariant HOT 10
- Implementation of `Compose` is confusing HOT 3
- should Chain properties depends on fantasy-land/ap (and possibly .map)? HOT 4
- Why putting "fantasy-land/" before everything in readme? HOT 3
- Is `Pair` a valid instance of `MonadRec`?
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 fantasy-land.