-
Notifications
You must be signed in to change notification settings - Fork 31
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
Refactor 'stream', add a few examples #705
Conversation
a541b08
to
eadf0cf
Compare
Also, I just tried using a "for-each" on characters, but it doesn't act the way I'd expect as per the pun: import stream
def main() = {
for[Char] { each("Hello") } { c =>
println(show(c) ++ " (" ++ show(c.toInt) ++ ")")
}
} as it prints an infinite stream of:
Similarly the code hangs in an infinite loop when I do: def main() = {
val list = collectList[Char] { each("Hello") }
println(list.map { (c: Char) => show(c) })
} which I'd presume would just output |
ceb7700
to
b69033d
Compare
9e44784
to
0a5a021
Compare
0a5a021
to
c6e2202
Compare
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.
LGTM (modulo small whitespace changes)
'stream' got slightly refactored (using `Any` everywhere now), fixed a few bugs, added a few examples of push streams, pull streams, their infinite variants, `limit`, `zip`, ... --------- Co-authored-by: Philipp Schuster <[email protected]>
'stream' got slightly refactored (using `Any` everywhere now), fixed a few bugs, added a few examples of push streams, pull streams, their infinite variants, `limit`, `zip`, ... --------- Co-authored-by: Philipp Schuster <[email protected]>
Update: 'stream' got slightly refactored (using
Any
everywhere now), fixed a few bugs, added a few examples of push streams, pull streams, their infinite variants,limit
,zip
, ...I added a few examples for the new stream stdlib into
examples/stdlib
.I'd also be happy to add some Nice ®️ example into the
stream.effekt
file itself (either into the doc comments or as anamespace examples { ... }
thing)I couldn't figure out how to useEDIT: solvedtake
properly in a sane (nice idiomatic) way, since it requires me to handlestop
and I couldn't find any nicely looking way to do that. Therefore all of these examples are just simple, finite push streams.I also tried adding
zip
in order to iterate through multiple streams in step, but I'm not sure how idiomatic it is (see comments below).@phischu, please let me know if I'm using the
stream
library as you envisioned it.If not, feel free to go ahead and change the examples so that they are closer to what you'd want. :)
TODO (in an ideal world)
zip
nicer to use?