$ stack build
$ cat example.txt | stack exec rules-engine-exe
You can find an example of how use this in app/Main.hs
.
The flow is:
- Use
parseRule
to receive anEither ParseError Rule
. - If you have a
Right rule
, pass that tovalidateRule
, along with a list of all the valid actions, and a list of all the valid variables.- This is a separate function call, so that you can surface a failure to the user.
- If
validateRule
returnsTrue
, pass the rule, along withMap
from variable names to their value, aMap
from actions, to their callback functions, and a context value to pass to the callback if it is triggered.- This context value is useful if you are running the rule against multiple sets of data, so that you can distinguish which data set triggered the rule.