[{"name":"Boon","comment":" Parsing and evaulation of [Boon](https://docs.google.com/document/u/0/d/1UzsnnKjjW7T_u-OPb5dcPmc9My4YS_jHoyButolNVa4/mobilebasic#heading=h.wazvxi10wtkz) strings.\n\n\n# Terminology\n\nIn the boon expression:\n\n`this OR that`\n\n`OR` is an _operator_, and `this` and `that` are _identifiers_.\n\n\n# Parsing\n\n@docs Expression, parse, parseWith\n\n\n# Evaluation\n\n@docs eval, evalFromDict, evalFromSet, identifiers\n\n","unions":[{"name":"Expression","comment":" A parsed Boon expression with identifiers of type `i`. Can be evaluated many times\n","args":["i"],"cases":[]}],"aliases":[],"values":[{"name":"eval","comment":" Evaluate an expression based on a user-provided lookup function that maps\nidentifiers to boolean values.\n\n    trueOrFalse str =\n        if (str == \"true\") then\n            True\n        else\n            False\n\n    -- Evaluates to False\n    parse \"true AND false\"\n        |> eval trueOrFalse\n\n","type":"(i -> Basics.Bool) -> Boon.Expression i -> Basics.Bool"},{"name":"evalFromDict","comment":" Evaluate an expression by looking up identifiers in a `Dict`. If a\nkey is absent, it will evaluate to `False`\n\n    values =\n        Dict.fromList\n            [ ( \"foo\", True )\n            , ( \"bar\", False )\n            ]\n\n    -- Evaluates to True\n    parse \"foo OR bar\"\n        |> evalFromDict values\n\n    -- Evaluates to False\n    parse \"baz OR bar\"\n        |> evalFromDict values\n\n","type":"Dict.Dict comparable Basics.Bool -> Boon.Expression comparable -> Basics.Bool"},{"name":"evalFromSet","comment":" Evalute an expression by looking up identifiers in a `Set`. Identifiers\npresent in the set are `True`, any others are `False`.\n\n    values = Set.fromList [\"foo\", \"bar\"]\n\n    -- Evaluates to True\n    parse \"foo AND bar\"\n        |> evalFromSet values\n\n    -- Evaluates to False\n    parse \"bar AND baz\"\n        |> evalFromSet values\n\n","type":"Set.Set comparable -> Boon.Expression comparable -> Basics.Bool"},{"name":"identifiers","comment":" Get a list of identifiers used in an expression. This can be useful if\nyou need to fetch these identifiers from some external source with a Cmd prior\nto evaluation, or otherwise keep a list of them for reference.\n\nIdentifiers may be included more than once and ordering is not guaranteed. It is\nrecommended to collect them in a `Set` if the identifiers are `comparable`.\n\n","type":"Boon.Expression i -> List.List i"},{"name":"parse","comment":" Try to parse a string as a Boon expression, failing on invalid input.\n","type":"String.String -> Result.Result String.String (Boon.Expression String.String)"},{"name":"parseWith","comment":" Try to parse a string as a Boon expression, using the provided function to transform\nidentifiers. This can be useful if your Boon expressions have more than one type of identifier\nin them and you want to map them to custom types.\n\n    type Ingredient\n        = Meat String\n        | Cheese String\n\n    parseIngredient : String -> Result String Ingredient\n    parseIngredient str =\n        if String.startsWith \"meat:\" str then\n            Ok (Meat (String.dropLeft 5 str))\n\n        else if String.startsWith \"cheese:\" str then\n            Ok (Cheese (String.dropLeft 7 str))\n\n        else\n            Err (str ++ \" is not a valid ingredient\")\n\n    sandwichCheck : Ingredient -> Bool\n    sandwichCheck ingredient =\n        case ingredient of\n            Meat \"ham\" ->\n                True\n            Cheese \"swiss\" ->\n                True\n\n    -- returns True\n    parseWith parseIngredient \"meat:ham AND cheese:swiss\"\n        |> eval sandwichCheck\n\n","type":"(String.String -> Result.Result String.String i) -> String.String -> Result.Result String.String (Boon.Expression i)"}],"binops":[]}]