Skip to content
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

Allow merge to produce union #224

Merged
merged 1 commit into from
May 10, 2018
Merged

Allow merge to produce union #224

merged 1 commit into from
May 10, 2018

Conversation

briancavalier
Copy link
Member

As per recent discussion, this loosens the type of the 2-stream merge to accept streams of different types and produce a stream of the union.

At first, this might seem unsafe because you might accidentally call merge with different types, say A and B when you didn't mean to. However, since the resulting stream has a union type, A | B, when you try to use it, for example by mapping it with a function A => C, the type checker will prevent it. Thus, I believe this is entirely safe, while adding some flexibility for situations where you might actually want to construct a union.

const s2 = now('a')
const s = merge(s1, s2)

runEffects(s, newDefaultScheduler())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange test, but I guess it’s a type assertion test in the IDE. I’m not sure 🤔 it is okay, or do the node tests also check types?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see the path is test/flow

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, see the readme in test/flow. It'd probably be better to try to get typechecking working in merge's regular unit tests. I tried briefly, but something must not be right in our flow config, since I couldn't get type checking to fail when it should :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants