aboutsummaryrefslogtreecommitdiffstats
path: root/lib/prl
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-04-27 23:29:57 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2026-04-27 23:29:57 -0300
commit4fdf3392868c72ff4c33b70d165a177e97f2fece (patch)
tree4eebfc260c890ea56d59f874cdfa0c9b1f55cd98 /lib/prl
parent97960adb8426e5270fe16b027e82a2c61674f821 (diff)
downloadSakura-4fdf3392868c72ff4c33b70d165a177e97f2fece.tar.gz
Sakura-4fdf3392868c72ff4c33b70d165a177e97f2fece.zip
Format
Diffstat (limited to '')
-rw-r--r--lib/prl/executor.ml18
-rw-r--r--lib/prl/runtime.ml25
2 files changed, 23 insertions, 20 deletions
diff --git a/lib/prl/executor.ml b/lib/prl/executor.ml
index d4ceca5..6a53656 100644
--- a/lib/prl/executor.ml
+++ b/lib/prl/executor.ml
@@ -28,15 +28,18 @@ module Make (Storage : Management.Physical.S) = struct
let execute_load_library storage db path =
match Runtime.load_library path with
| Error e -> Error (RuntimeError e)
- | Ok () ->
- let* ll_rel = require_relation db Prelude.Catalog.loaded_library_rel_name in
+ | Ok () -> (
+ let* ll_rel =
+ require_relation db Prelude.Catalog.loaded_library_rel_name
+ in
let tuple = Prelude.Catalog.build_loaded_library_tuple path in
- (match Ops.create_tuple storage db ll_rel tuple with
+ match Ops.create_tuple storage db ll_rel tuple with
| Ok (new_db, _, _) -> Ok (Sublanguage_types.Transition new_db)
| Error (Error.DuplicateTuple _) -> Ok (Sublanguage_types.Transition db)
| Error e -> Error (RelationError e))
- let execute_define_function_predicate storage db (spec : Ast.function_predicate) =
+ let execute_define_function_predicate storage db
+ (spec : Ast.function_predicate) =
match Sakura_prl_api.find spec.symbol with
| None -> Error (UnknownPluginSymbol spec.symbol)
| Some impl ->
@@ -48,7 +51,9 @@ module Make (Storage : Management.Physical.S) = struct
let name = Qualified_name.(parse spec.name |> to_key) in
let generator = Runtime.make_generator name schema impl [] in
let producer = Runtime.make_producer name schema impl in
- let membership_criteria = Runtime.make_membership_criteria schema impl in
+ let membership_criteria =
+ Runtime.make_membership_criteria schema impl
+ in
let* new_db, _ =
Ops.create_immutable_relation storage db ~name ~schema ~generator
~membership_criteria ~cardinality:spec.cardinality
@@ -60,7 +65,8 @@ module Make (Storage : Management.Physical.S) = struct
in
let fp_tuple =
Prelude.Catalog.build_function_predicate_tuple ~name
- ~symbol:spec.symbol ~cardinality:spec.cardinality ~purity:spec.purity
+ ~symbol:spec.symbol ~cardinality:spec.cardinality
+ ~purity:spec.purity
in
let* final_db =
Ops.create_tuple storage new_db fp_rel fp_tuple
diff --git a/lib/prl/runtime.ml b/lib/prl/runtime.ml
index d5e28ec..4b746d4 100644
--- a/lib/prl/runtime.ml
+++ b/lib/prl/runtime.ml
@@ -1,7 +1,4 @@
-type t = {
- loaded_libraries : (string, unit) Hashtbl.t;
- mutex : Mutex.t;
-}
+type t = { loaded_libraries : (string, unit) Hashtbl.t; mutex : Mutex.t }
let state : t =
{ loaded_libraries = Hashtbl.create 16; mutex = Mutex.create () }
@@ -29,16 +26,15 @@ let to_plugin_row (schema : Schema.t) (tuple : Tuple.materialized) :
go [] schema
(* Convert a plugin row back to an engine materialized tuple. *)
-let of_plugin_row relation_name (schema : Schema.t)
- (row : Sakura_prl_api.tuple) : Tuple.materialized option =
+let of_plugin_row relation_name (schema : Schema.t) (row : Sakura_prl_api.tuple)
+ : Tuple.materialized option =
let rec go acc = function
| [] -> Some { Tuple.relation = relation_name; attributes = acc }
| (attr_name, _) :: rest -> (
match List.assoc_opt attr_name row with
| None -> None
| Some value ->
- go (Tuple.AttributeMap.add attr_name { Attribute.value = value } acc)
- rest)
+ go (Tuple.AttributeMap.add attr_name { Attribute.value } acc) rest)
in
go Tuple.AttributeMap.empty schema
@@ -51,7 +47,8 @@ let rows_to_generator relation_name schema (rows : Sakura_prl_api.tuple list) :
if i >= n then Generator.Done
else
match of_plugin_row relation_name schema arr.(i) with
- | None -> Generator.Error "Plugin row does not conform to predicate schema."
+ | None ->
+ Generator.Error "Plugin row does not conform to predicate schema."
| Some tuple -> Generator.Value (Tuple.Materialized tuple, gen (i + 1))
in
gen 0
@@ -60,25 +57,25 @@ let make_generator relation_name schema (impl : Sakura_prl_api.implementation)
(bindings : Sakura_prl_api.tuple) : Generator.t =
match impl.produce with
| None -> fun _ -> Generator.Done
- | Some produce ->
+ | Some produce -> (
let rows_result = lazy (produce bindings) in
fun _pos ->
match Lazy.force rows_result with
| Error e -> Generator.Error e
- | Ok rows -> rows_to_generator relation_name schema rows _pos
+ | Ok rows -> rows_to_generator relation_name schema rows _pos)
let make_producer relation_name schema (impl : Sakura_prl_api.implementation) :
Relation.producer =
- fun bindings -> make_generator relation_name schema impl bindings
+ fun bindings -> make_generator relation_name schema impl bindings
let make_membership_criteria schema (impl : Sakura_prl_api.implementation) :
(string -> Merkle.t option) -> Tuple.t -> bool =
match impl.membership_criteria with
| None -> fun _ _ -> false
- | Some check ->
+ | Some check -> (
fun _tree_of -> function
| Tuple.NonMaterialized _ -> false
| Tuple.Materialized m -> (
match to_plugin_row schema m with
| None -> false
- | Some row -> (match check row with Ok b -> b | Error _ -> false))
+ | Some row -> ( match check row with Ok b -> b | Error _ -> false)))