-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fantasy land update #166
Merged
Merged
Fantasy land update #166
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f9857f3
Move toJSON to the correct place so it functions for all streams
208c472
Deprecate old fantasy land methods and add newer spec fantasy land me…
26937c0
move flatMap to flyd.chain
bf8d6ba
deprecate promise swallowing in favour of flyd.fromPromise
b7e017d
add fantasy-land module and auto fix eslint errors
439fd27
change tests to use s.pipe instead of old fantasy land methods
5031e34
add typescript definitions
9a7bc8c
Get coverage up
b10cb31
Add documentation
5afb43b
Address issues brought up in code review
6d72aa2
fix test case
12b2433
Fix issue with documenation of chain
9670e02
Fixes to typescript types, and fixes chain not preserving order
808aae2
deprecate promise swallowing
6f715c4
actually implement the Applicative specification
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the FL-standard
s.chain(fn)
or the staticchain(fn)(s)
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about them? can you elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whether I can use them instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have never seen the syntax like here in this context. Any motivation for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's actually no FL-standard
s.chain(fn)
.If you read the spec, there's a requirement for a prefixed
fantasy-land/chain
to comply with the spec.flyd.chain
can be used in a number of ways:fantasy-land/chain
All of these ways are functionally equivalent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean here:
https://github.com/fantasyland/fantasy-land#chain-method
As a monad,
flyd.stream
object has to implement the.chain
method.I didn't mean the prefixed methods.
They are in addition, more for the library creators and the situation
when you have low level libraries used by higher level ones.
However, there is no higher level library for
flyd
.I can see the other ways, but none of them is really as usable,
they are more for a low level library.
So I would need to write a micro-wrapper of my own,
which I shall do if the direct methods won't be supported out of the box,
but I've thought it might be useful for more people than just me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the part of the spec I linked says:
Meaning it's the prefixed methods that matter. Unprefixed methods are not part of the spec and as such can for the most part be treated as having undefined behaviour.
Now we really have 2 camps when it comes to FP in JS, there's the Haskell camp, and the Scala camp.
The Scala camp prefers method chaining and the Haskell camp prefers function composition.
To me, the pipe method should make both camps happy.
The function composition camp can write:
and the method chaining camp can write:
Note: chain and map could also be imported from flyd, but I wanted to show that other libraries supporting the fantasy-land spec can be used too.