Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a proto!() macro #44

Open
laumann opened this issue May 24, 2018 · 1 comment
Open

Add a proto!() macro #44

laumann opened this issue May 24, 2018 · 1 comment

Comments

@laumann
Copy link
Collaborator

laumann commented May 24, 2018

Suggestion is to add a macro for writing the session types down.

Something like:

proto!{Atm, Client,
    ?<Id>,
    +[
        act: &[
            ?<u64>, !<u64>, act;
            ?<u64>, +[act; act];
            !<u64>;
            eps
        ];
        eps
    ]
}

where

  • ?<T>, P denotes Recv<T, P>
  • !<T>, P denotes Send<T, P>
  • +[A; B; C] is Choose<A, Choose<B, C>>
  • &[A; B; C] is Offer<A, Offer<B, C>>
  • t: P should be Rec<P>. Any occurrences of t in P should be replaced with an appropriate Var<N> construct
  • eps is just Eps

The output of proto!() is then two type aliases:

type Atm = ...;
type Client = <Atm as HasDual>::Dual;

This should replace the current constructs like this:

type Atm = Recv<Id, Choose<Rec<AtmInner>, Eps>>;

type AtmInner = Offer<AtmDeposit, Offer<AtmWithdraw, Offer<AtmBalance, Eps>>>;

type AtmDeposit = Recv<u64, Send<u64, Var<Z>>>;
type AtmWithdraw = Recv<u64, Choose<Var<Z>, Var<Z>>>;
type AtmBalance = Send<u64, Var<Z>>;

type Client = <Atm as HasDual>::Dual;
@laumann
Copy link
Collaborator Author

laumann commented May 24, 2018

Maybe more readable if labels were supported:

proto!{Atm, Client,
    ?<Id>,
    +[
        act. &[
            deposit: ?<u64>, !<u64>, act;
            withdraw: ?<u64>, +[ok: act; err: act];
            balance: !<u64>;
            exit: eps
        ];
        eps
    ]
}

Recursion labels could then be followed by . and branch labels be followed by : to separate the two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant