hydro-project / hydroflow

Hydro's low-level dataflow runtime
https://hydro.run/docs/hydroflow/
Apache License 2.0
470 stars 34 forks source link

Bug info about demux_enum #1201

Closed neurusL closed 3 months ago

neurusL commented 4 months ago

Hi, we are a team from Carnegie Mellon University using Hydroflow for reactive programming. The idea Hydroflow representing code as dataflow is really inspiring and convenient for us to use. Thanks for your great project! A slight issue we encounter is when we use the operator demux_enum, the debug info auto-generated by rust compiler is a bit confusing. For example, we didn't notice there's a requirement for exhaustive matching for succeeding dataflow of demux_enum, while the error message is, for example:

   --> src/server.rs:33:29
   |
33 |       let mut hf: Hydroflow = hydroflow_syntax! {
   |  _____________________________^
34 | |         // Define shared inbound and outbound channels
35 | |         outbound_chan = union() -> dest_sink_serde(outbound);
36 | |         inbound_chan = source_stream_serde(inbound)
...  |
72 | |      
73 | |     };
   | |_____^ expected `(_, ())`, found `()`
   |
   = note:  expected tuple `(_, ())`
           found unit type `()`

Another example is when succeeding dataflow's input type doesn't match demux_enum's output type, the error message refers to demux_enum rather than succeeding dataflow, for example:

  --> src/server.rs:39:16
   |
39 |             -> demux_enum::<MessageWithAddr>();
   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(SocketAddr,)`, found `()`
   |
   = note:  expected tuple `(std::net::SocketAddr,)`
           found unit type `()`
   = note: required for `(impl Pusherator<Item = ()>, (_, ()))` to implement `PusheratorListForItems<((std::net::SocketAddr,), ((std::net::SocketAddr,), ()))>`
   = note: 3 redundant requirements hidden
   = note: required for `(impl Pusherator<Item = (SocketAddr,)>, (impl Pusherator<Item = (SocketAddr,)>, (..., ...)))` to implement `PusheratorListForItems<((std::net::SocketAddr,), ((std::net::SocketAddr,), ((std::net::SocketAddr, protocol::Entry), ((std::net::SocketAddr,), ((std::net::SocketAddr,), ())))))>`

We feel like maybe in future sprints, you can improve these bug reports to make Hydroflow more user friendly. Thanks!

MingweiSamuel commented 4 months ago

Will simplify the implementation a bit. Hands a bit tied by the way macros work, but should be a bit better #1204

MingweiSamuel commented 3 months ago

Can't really make the error messages perfect due to how proc macros work but they should be a lot better now. Feel free to post any weird error messages you get and we can see if it can be improved further

neurusL commented 3 months ago

Thanks a lot! It's indeed more readable now.