(it was years ago but)
Encoding this state-machine:
https://wr.mondet.org/smondet/ocaml2015/img/target_graph.jpg (from these slides)
using polymorphic variants to enforce that “a given state can come only from certain previous states” →
https://github.com/hammerlab/ketrew/blob/master/src/pure/target.ml#L169