""" See "The Purely Functional Software Deployment Model", fig. 5.2 [1]. [1]: E. Dolstra, “The purely functional software deployment model,” Ph.D., Universeit Utrecht, Utrecht, NL, 2006. [Online]. Available: https://edolstra.github.io/pubs/phd-thesis.pdf """ from abc import ABCMeta, abstractmethod import dataclasses import struct from pathlib import Path from typing import Protocol import unicodedata class Writable(Protocol): """Realistically could just be IOBase but this is more constrained""" def write(self, data: bytes, /) -> int: ... @dataclasses.dataclass class NarListener: data: Writable def literal(self, data: bytes): self.data.write(data) def int_(self, v: int): self.literal(struct.pack('