sclass HuffmanTree is BitIO { settable Node root; /* algebraic Node { constructor Branch { settable Node zero; settable Node one; } constructor Leaf { settable byte literal; } } */ abstract static class Node is BitIO {} static class Branch > Node { settable Node zero; settable Node one; public void readWrite(BitHead head) { head.writeBit(1); head.exchange(zero); head.exchange(one); } } static class Leaf > Node { settable byte literal; *() {} *(int literal) { literal((byte) literal); } public void readWrite(BitHead head) { head.writeBit(0); head.writeByte(literal); } } public void readWrite(BitHead head) { node.readWrite(head); } }