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

Type inference fails for tee after a pivot (?) #1149

Open
MingweiSamuel opened this issue Apr 9, 2024 · 3 comments
Open

Type inference fails for tee after a pivot (?) #1149

MingweiSamuel opened this issue Apr 9, 2024 · 3 comments
Labels
bug Something isn't working hydroflow syntax Hydroflow's custom surface syntax

Comments

@MingweiSamuel
Copy link
Member

MingweiSamuel commented Apr 9, 2024

#[multiplatform_test]
pub fn test_fold_zip() {
    let mut df = hydroflow::hydroflow_syntax! {
        stream1 = source_iter(1..=10);
        stream2 = source_iter_delta(3..=5) -> map(Max::new);
        sum_of_stream2 = stream2 -> lattice_reduce() -> tee();

        filtered_stream1 = stream1
            -> [0]filtered_stream2;
        sum_of_stream2 -> identity::<Max<_>>() -> [1]filtered_stream2;

        filtered_stream2 = zip()
            -> filter(|(value, sum_of_stream2)| {
                // This is not monotonic.
                value <= sum_of_stream2.as_reveal_ref()
            })
            -> map(|(x, _max)| (context.current_tick(), x))
            -> assert_eq([(0, 1), (0, 2), (0, 3), (0, 4), (0, 5)]);

        // Optional:
        sum_of_stream2
            -> map(|x| (context.current_tick(), x.into_reveal()))
            -> assert_eq([(0, 3), (0, 4), (0, 5), (0, 6), (0, 7)]);
    };

    assert_graphvis_snapshots!(df);

    df.run_available(); // Should return quickly and not hang
}

A few initial attempts to rearrange codegen to fix the type inference proved fruitless

(This example can work by making the final map |x: Max<_>| ...)

@MingweiSamuel MingweiSamuel added bug Something isn't working hydroflow syntax Hydroflow's custom surface syntax labels Apr 9, 2024
@MingweiSamuel
Copy link
Member Author

A stop-gap would be to let tee() take a type parameter (probably allow union() as well for symmetry)

@shadaj
Copy link
Member

shadaj commented Apr 10, 2024

Seeing very similar behavior when a for_each after a pivot (source_stream -> map -> for_each fails to type infer the input to the for_each even if the map has an explicit output type).

@MingweiSamuel
Copy link
Member Author

#980

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hydroflow syntax Hydroflow's custom surface syntax
Projects
None yet
Development

No branches or pull requests

2 participants