Location Polymorphism

Another feature of ChoRus is location polymorphism. Location polymorphism allows choreographies to be defined using generic locations. These locations can then be instantiated with concrete locations, allowing the choreography to be executed on different locations.

To define a location-polymorphic choreography, you need to create a generic struct that takes a type parameter that implements the ChoreographyLocation trait. When instantiating the choreography, you can pass a concrete location.

fn main() {
extern crate chorus_lib;
use chorus_lib::core::{ChoreoOp, Choreography, ChoreographyLocation, Projector, Located, Superposition, Runner, LocationSet};
use chorus_lib::transport::local::{LocalTransport, LocalTransportChannelBuilder};
struct Alice;
struct Bob;
struct Carol;
let transport_channel = LocalTransportChannelBuilder::new().with(Alice).with(Bob).with(Carol).build();
let alice_transport = LocalTransport::new(Alice, transport_channel.clone());
let bob_transport = LocalTransport::new(Bob, transport_channel.clone());
let carol_transport = LocalTransport::new(Carol, transport_channel.clone());
struct LocationPolymorphicChoreography<L1: ChoreographyLocation> {
    location: L1,

impl<L1: ChoreographyLocation> Choreography for LocationPolymorphicChoreography<L1> {
    type L = LocationSet!(L1);
    fn run(self, op: &impl ChoreoOp<Self::L>) {
        op.locally(self.location, |_| {
            println!("Hello, World!");

let alice_say_hello = LocationPolymorphicChoreography {
    location: Alice,
let bob_say_hello = LocationPolymorphicChoreography {
    location: Bob,