ShapeOfMatter / MultiChor

Type-safe and efficient choreographies for Haskell, with multiply-located values, multi-cast, and location-set polymorphism.
Other
7 stars 0 forks source link

Functor-based shallow send #22

Open ShapeOfMatter opened 7 months ago

ShapeOfMatter commented 7 months ago

I'm pretty sure this will have to get baked in as a primitive. Given that it's not fully general; that's unfortunate. Anyway, the point is that we can get ~50% of the way to patching the efficiency gap to chor-lambda if we have an op like

sendShallow :: (Functor f, Show1 f)
                           => Member l ps
                           -> (Member l ls, Located ls (f (Located ms a)))
                           -> Subset rs ps
                           -> Choreo ps m (Located rs (f (Located ms a))

What this would do/how it would work is it would apply void to the located functor, send that, and the recipient would map const Empty over it to replay the ()s with "not here". This would let one send a top level structure without sending all the data. Afterward, everyone would be able to branch on the outer functor's structure, even though only ms would be able to unwrap its contents.

ShapeOfMatter commented 5 months ago

The difficulty here is that some recipients may already know the inner data, and they should retain the abilty to use it. so this likely needs to be done after soem refinements to avoid redundant sends, and also when we have some tools for handling set intersections and unions.