Fs2: Add cats.Align instance for fs2.Stream

Created on 28 Jan 2020  路  5Comments  路  Source: typelevel/fs2

Should be fairly similar to the zip implementation

All 5 comments

i'd be happy to pick this up

I'm new to FS2 so apologies if it's a stupid question, but is there a case where it's possible to return anything other than Both[A, B]? Or is returing Align.Left and Align.Right exactly the point of this work?

What would we do in the case where we have

streamA.align(streamB)

where streamA is Stream.constant("1") and streamB is Stream.empty - looking at the docs for Align, we'd be returning an infinite Stream of Align.Left(1) - would this be the correct behaviour, or would we do what we do in zip and align only when we have values in both streams?

@bobbyrauchenberg good question!
You are right that returning Ior.Left and Ior.Right in addition to Ior.Both is exactly the point of this work. To answer your question, yes you would get an infinite stream of Left(1).

Hey @bobbyrauchenberg, that seems to me like the correct behavior. The longer of the two streams will result in having values as Left xor Right at the end, but the prefix will always be Both. This could probably be made into a nice property test.

This was fixed by #1791

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gvolpe picture gvolpe  路  10Comments

diesalbla picture diesalbla  路  5Comments

mpilquist picture mpilquist  路  12Comments

gvolpe picture gvolpe  路  9Comments

zainab-ali picture zainab-ali  路  15Comments