shumbo / choreography-ts

Choreographic Programming in TypeScript
1 stars 1 forks source link

`no-unused-colocated-location` rule #8

Open shumbo opened 1 year ago

shumbo commented 1 year ago

Warn the user if colocated values are not used at some location.

type Locations = "alice" | "bob" | "carol"

const test: Choreography<Locations> = async ({
  locally,
  multicast,
}) => {
  const msgAtAlice = await locally("alice", () => "msg at alice");
  const colocatedMsg = await multicast("alice", ["bob", "carol"], msgAtAlice);
  await locally("bob", (unwrap) => {
    console.log("bob received the message", unwrap(colocatedMsg));
  })
  return [];
};

Here, colocatedMsg is of type Colocated<string, "alice" | "bob" | "carol"> and in particular, this multicast sends the value from Alice to Carol over the network. However, the value is not unwrapped at Carol. Write a rule to catch this type of error.

ImpregnableProgrammer commented 1 year ago

This is being worked on in pull request #30.