Stream: beginners

Topic: Canonical way of combining multiple results in roc


view this post on Zulip Nikolaus Wettstein (Jan 04 2023 at 14:50):

After reading the FAQ, specifically the section about why there is no Maybe in the stdlib, I rewrote this solution (from advent of code) to a version without a Maybe. Is this the canonical way of combining multiple results? Or should I write a map2? And why isn't there a map2 in the stdlib?

Btw: I'm having a great time with roc so far! I'm very curious how roc will perform and feel on a large production code base in the future!

view this post on Zulip Ayaz Hafiz (Jan 04 2023 at 15:13):

Yeah, there is no map2 in the stdlib currently. You could also do something like

Result.try result1 \ok1 -> Result.try result2 \ok2 -> Ok {ok1, ok2}

which is functionally equivalent to map2

view this post on Zulip Nikolaus Wettstein (Jan 04 2023 at 15:16):

Thank you!


Last updated: Jul 06 2025 at 12:14 UTC