This is an idea for how to case on a byte sequence without any special support from the compiler.
The basic idea is explored in https://github.com/layer-3-communications/fortios-syslog, but there
code generation is used rather than
TemplateHaskell. The idea is that, at compile time, generating
a perfect hash function for all strings of the same length is a good way to pattern match on a sequence of
bytes. Roughly, we have:
foo :: Bytes -> Bar foo b = case B.length b of 3 -> case hash3 b of
Car | b == "car" -> ...