Purely functional event-driven automata