-
Notifications
You must be signed in to change notification settings - Fork 147
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
Fixup documentation. #397
Fixup documentation. #397
Conversation
Actual thunks in the Haskell sense are a fairly common way of implementing lazy streams, as: data Thunk a = Thunk (() -> a)
data Stream a = Nil | Cons a (Thunk (Stream a)) To actually get data from the stream you force the thunk: force :: Thunk a -> a
force t = t ()
toList :: Stream a -> Thunk [a]
toList Nil = Thunk \_ -> []
toList (Cons head tail) = Thunk \_ -> ([head] :: force (toList (force tail))) Since all the forcing in I think "causing a thunk" actually refers to forcing. I've no idea how Highland's laziness is actually implemented though 😁 Code examples are written in an eager pseudo-Haskell. Here's a more complete implementation of Javascript (well, Sweet.js) lazy streams. |
@@ -2241,8 +2249,12 @@ Stream.prototype.uniqBy = function (compare) { | |||
exposeMethod('uniqBy'); | |||
|
|||
/** | |||
* Takes all unique values in a stream. | |||
* It uses uniqBy internally, using the strict equality === operator to define unicity | |||
* Filters out all duplicate values from the stream and keep only the first |
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.
/s/keep/keeps
Nice work! |
I see. That makes sense. 3.0.0 streams are implemented in a similar way as your Haskell example. Every stream has a generator function that gets called when you call I think I'll try to reword this so that it doesn't suggest that pulling data from the stream is a thunk. |
Ok. I've addressed @svozza's comment and replaced "cause a thunk" with the slightly more verbose "consume the stream". Better terminology welcome. |
+1 for "consume the stream". I wonder what @caolan thinks about it? |
* var checkExists = _.wrapCallback(fs.exists); | ||
* function checkExists(file) { | ||
* return _(function (push, next) { | ||
* fs.exists(file, function (exists) { |
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.
Should we be using deprecated Node.js functions in the examples?
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 thought about just changing it to fs.access
, but the other side of that argument is, "should we be using a function that doesn't exist in 0.10 when we technically support it?"
That said, Node 4 is the LTS version, so maybe not many people use 0.10 anymore. I don't feel strongly about it though, so if you don't think it matters, then I'm happy to change it.
I added some deprecation warnings for the things we are changing in 3.0.0, and changed the use of |
Good idea with the deprecation warnings. LGTM. |
I only meant to update
uniq
to stop saying that it's implemented viauniqBy
but ended up doing a pass over the entire documentation...Most of the changes are adding formatting and type annotations for arguments, though I've clarified the wording in certain cases.
I also have a question. The docs mentions this at one point
My familiarity with the term
thunk
is in this context: https://en.wikipedia.org/wiki/Thunk. Basically, it's a chunk of code, which is not the way it's being used here. Is this usage of the term common?