Without in-band signaling, it will never be possible for Consumer have a โreturn valueโ if Producer returns first. If the manufacturer is returning, this means that the Consumer must be locked in anticipation of the required value. Consumer will never start again and therefore will never be able to return until Consumer receives an in-band signal with the requested value.
Just because an alarm within a range does not mean that it should be icky. We can transform the Producer , which can return to the Producer , which, as we know, does not return (its return type is forall r' . r' ), capture return and redirect it downstream. We do this forever if another request comes back.
returnDownstream :: Monad m => Proxy a' ab' bmr -> Proxy a' ab' (Either rb) mr' returnDownstream = (forever . respond . Left =<<) . (respond . Right <\\)
At the end of Consumer you need to explicitly handle what to do when the request ed value, but instead of receiving a response (in Right ), you get the return value of the upstream producer (in Left ).
source share