2 ms·
I've been experimenting with a similar project. We encode the language in a data-structure which allows us to serialize/parse the rules. Paired with an interpre
by agentultra 5y ago
I've been experimenting with a similar project. We encode the language in a data-structure which allows us to serialize/parse the rules. Paired with an interpreter that takes an environment context along with its input the rule language can be written and maintained by analysts and domain experts.
The usual caching strategies work as well. We can keep rules cached in-memory. Caching the contextual environment comprising all of the relevant data from the system is a bit trickier but we haven't gotten to that part and query for it at run time. It should be feasible. And if the language gets complex enough we may experiment with writing lightweight analysis tools [0]. For now though we're limiting it to internal use by engineers (working with analysts) until we learn more about the approach in production.
The surprising thing is just how little code it takes to get something like this going in Haskell. GHC can derive and write a lot of parsing/serialization code for you automatically and you get a lot of great type-classes out of the box which makes composing big parts out of little pieces nice and easy.
[0]: https://luctielen.com/posts/static_analysis_using_haskell_and_datalog/ https://luctielen.com/posts/static_analysis_using_haskell_an...