Stream: beginners

Topic: lazy sequence


view this post on Zulip drew (Aug 26 2024 at 21:45):

Does roc have a "lazy list" or "infinite sequence" or stream, etc? I'm thinking about all the things I normally use for advent of code.

view this post on Zulip Brendan Hansknecht (Aug 26 2024 at 22:13):

Nope

view this post on Zulip Brendan Hansknecht (Aug 26 2024 at 22:13):

Can be built up in userland, but nothing exists in the standard library or language

view this post on Zulip drew (Aug 26 2024 at 22:17):

got it, thanks. i’m guessing this means no package either.

view this post on Zulip drew (Aug 26 2024 at 22:22):

i may see if i can build one, but i know there are a lot of tricky bits in implementing something like this well

view this post on Zulip Brendan Hansknecht (Aug 26 2024 at 22:25):

I think someone was messing around with streams before on Zulip, but no idea the state

view this post on Zulip drew (Aug 27 2024 at 02:11):

awkward https://gist.github.com/drewolson/6c1f5157e84a6c387faca0646d91e04a

view this post on Zulip drew (Aug 27 2024 at 02:14):

i solved it!

view this post on Zulip drew (Aug 27 2024 at 02:14):

my nil definition was typed nil : Stream a but should be nil : Stream _

view this post on Zulip Luke Boswell (Aug 27 2024 at 02:24):

I'm interested to know why there is a difference there.

My guess is that this might be related to polymorphism or something. Like once you use the top level nil function it's type becomes fixed to whatever it was used as. So maybe you need to make it a thunk like nil: {} -> Steam a for it to work with different types?

view this post on Zulip drew (Aug 27 2024 at 02:24):

i'll gist this if / when i actually get it working

view this post on Zulip drew (Aug 27 2024 at 02:26):

yeah i'm running into a few more type issues with this right now

view this post on Zulip drew (Aug 27 2024 at 03:51):

i'm hitting all sorts of compiler bugs :smile:

view this post on Zulip drew (Aug 27 2024 at 03:56):

this is what i have so far, it compiles https://gist.github.com/drewolson/774cc1e16c75510eefb9066a1395f780

view this post on Zulip drew (Aug 27 2024 at 03:56):

but when i try to use it ... bad things happen to the compiler

view this post on Zulip Kilian Vounckx (Aug 27 2024 at 05:30):

I was playing around with something similar a few months ago. There should be some things about is on a zulip thread somewhere. I named it Iter, so maybe that helps for looking. If I remember correctly, everything compiled back then as well, but crashed when running

view this post on Zulip Brendan Hansknecht (Aug 27 2024 at 06:32):

Hopefully the new lambdaset changes that have been tested outside of roc and need to be ported to roc will fix a lot of the issues here.

view this post on Zulip drew (Aug 27 2024 at 14:43):

somewhat related -- is there a good way to catch up on all the "ongoing" stuff around language changes? maybe the answer is "this zullip" :smile:

view this post on Zulip Anton (Aug 27 2024 at 14:50):

The big things are on this page, recently closed PRs could also be a good way to follow. And yeah zulip if you want to follow everything :)

view this post on Zulip drew (Aug 27 2024 at 14:55):

The language seems to be shaping up nicely and i'm excited to use it for more stuff (initially advent of code), but things still feel a bit too seg-fault-y to do so, mostly i'm trying to understand when to keep checking back.

view this post on Zulip Anton (Aug 27 2024 at 15:03):

but things still feel a bit too seg-fault-y to do so

Yeah, we are aware. We've been landing a lot of big changes lately, hopefully we'll have more time to focus on reliability in the near future. You can check this github search query to see if the amount of segfaults has reduced :)

view this post on Zulip drew (Aug 27 2024 at 15:05):

awesome!

view this post on Zulip Brendan Hansknecht (Aug 27 2024 at 16:42):

As a note, most of the segfaults I think come from more complex uses of the language (though the compiler can also crash relatively easily, but many of those go away once roc check errors are fixed). So if you do more imperative style of code with less lambdas and deeply captured data (like a lazy sequence), the language tends to be able to do a lot. But yeah....still not hard to break.

view this post on Zulip drew (Aug 27 2024 at 16:44):

fair. i don’t have a good intuition of what is “complex” right now. a few months ago i segfaulted on arg parsing, but that seems resolved by merging weaver. i swear i’m not trying to be complex for complexity’s sake :grinning:

view this post on Zulip Brendan Hansknecht (Aug 27 2024 at 16:52):

Sorry, not trying to call you out.

Generally speaking for Roc today, complex in terms of breaking the compiler tends to be lots of nested lambdas. Parser combinators happen to be that. So do lazy sequences. I think a lot of nice functional programming concepts fall into this category sadly. It also is not clear when things will break. Sometimes these features fully work. Other times they break with something that feels simple.

view this post on Zulip drew (Aug 27 2024 at 17:01):

Brendan Hansknecht said:

Sorry, not trying to call you out.

Not at all. The perspective is actually very useful. Every new ecosystem has things that are simple or complex based on their current strengths.


Last updated: Jul 05 2025 at 12:14 UTC