cucapra / packet-scheduling

MIT License
3 stars 0 forks source link

Factor policy functions into their own module #50

Closed polybeandip closed 3 months ago

polybeandip commented 3 months ago

In the spirit of #47, here's more cleanup! Previously, we had two "policy functions" living in different modules:

This PR moves these two functions into a single new module Policy. There's two nice upshots to this:

  1. we can delete Eval and Util.
  2. we can construct a new type Policy.t, which is Ast.policy without the Var constructor. This way, we don't need to raise exceptions to handle the Var case when pattern matching: for instance, notice exception NonTerminal doesn't exist anymore and Policy.to_string never raises an exception.
polybeandip commented 3 months ago

I guess I'm not too too worried, because if a user does create a divergence, they will quickly be forced to bring the types back into tandem. This is because we have a method that converts from Ast.policy to Policy.t, and OCaml will yell at them if that method is no longer kosher.

Agreed, I had this exact thought and came to the same conclusion!

Shall we just flag this fact with comments in both the type declarations (something like, Changes to this type must also be reflected in in )?

Done in a6de267.