aboutsummaryrefslogtreecommitdiffstats
path: root/lib/concepts/Condition.ml
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-07-11 00:51:11 -0300
committerGitHub <noreply@github.com>2026-07-11 00:51:11 -0300
commitbb3156b8ab78b035ce886bbe3021ec7cbe269d03 (patch)
tree82dd52655d25e49519a035f1245c703e910a2152 /lib/concepts/Condition.ml
parent85bff2fc22a131cce5ec2b4eb4b3dd8269c247cd (diff)
downloadRNT-bb3156b8ab78b035ce886bbe3021ec7cbe269d03.tar.gz
RNT-bb3156b8ab78b035ce886bbe3021ec7cbe269d03.zip
FOL: First Order Logic Execution Engine
Co-authored-by: Estevan Castilho <tevo@riajuu.net>
Diffstat (limited to 'lib/concepts/Condition.ml')
-rw-r--r--lib/concepts/Condition.ml29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/concepts/Condition.ml b/lib/concepts/Condition.ml
new file mode 100644
index 0000000..cc0f7a7
--- /dev/null
+++ b/lib/concepts/Condition.ml
@@ -0,0 +1,29 @@
+type properties = (string, Value.value) BatMap.t
+type ps = properties -> properties
+
+type condition =
+ {name: string; message: string; backtrace: Printexc.raw_backtrace; properties: properties}
+
+let ( |=| ) name value = fun p -> BatMap.add name value p
+let ( & ) l r = fun p -> r (l p)
+let empty = fun p -> p
+
+let condition name message ?parent props =
+ { name;
+ message;
+ backtrace= Printexc.get_callstack 256;
+ properties=
+ parent
+ |> Option.map (fun {properties; _} -> properties)
+ |> Option.value ~default:BatMap.empty
+ |> props }
+
+let to_string_hum {name; message; properties; backtrace} =
+ let properties' =
+ properties
+ |> BatMap.to_seq
+ |> BatSeq.to_string ~first:"" ~last:"" ~sep:"\n" (fun (k, v) ->
+ "\t" ^ k ^ ": " ^ Value.to_string v )
+ in
+ let backtrace' = Printexc.raw_backtrace_to_string backtrace in
+ name ^ ": " ^ message ^ "\n" ^ properties' ^ "\n\nBacktrace:\n" ^ backtrace'