diff options
| author | Marcos Magueta <maguetamarcos@gmail.com> | 2026-06-23 23:53:26 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-23 23:53:26 -0300 |
| commit | c284fcd570342c31bc21169960579a20a763e32e (patch) | |
| tree | ce7485055116d794c55090ad0978e0b3f5ff4c2a /prl_api | |
| parent | b81586ee4a0543a5f9866586c78dccdd6328934a (diff) | |
| download | Sakura-c284fcd570342c31bc21169960579a20a763e32e.tar.gz Sakura-c284fcd570342c31bc21169960579a20a763e32e.zip | |
Format
Diffstat (limited to 'prl_api')
| -rw-r--r-- | prl_api/sakura_prl_api.ml | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/prl_api/sakura_prl_api.ml b/prl_api/sakura_prl_api.ml index 84337fb..d1a6fcc 100644 --- a/prl_api/sakura_prl_api.ml +++ b/prl_api/sakura_prl_api.ml @@ -1,34 +1,26 @@ type value = Obj.t type tuple = (string * value) list -type implementation = { - membership_criteria : (tuple -> (bool, string) result) option; - produce : (tuple -> (tuple list, string) result) option; -} +type implementation = + { membership_criteria: (tuple -> (bool, string) result) option; + produce: (tuple -> (tuple list, string) result) option } (* TODO: Rethink this instead in terms of a value. We need to store the references as a normal relation on the multigroup relation catalog. *) let registry : (string, implementation) Hashtbl.t = Hashtbl.create 32 let mutex = Mutex.create () +let register symbol impl = Mutex.protect mutex (fun () -> Hashtbl.replace registry symbol impl) +let find symbol = Mutex.protect mutex (fun () -> Hashtbl.find_opt registry symbol) +let symbols () = Mutex.protect mutex (fun () -> Hashtbl.to_seq_keys registry |> List.of_seq) -let register symbol impl = - Mutex.protect mutex (fun () -> Hashtbl.replace registry symbol impl) +let implementation_of_rows ?membership_criteria (rows : tuple list) : implementation = + {membership_criteria; produce= Some (fun _bindings -> Ok rows)} -let find symbol = - Mutex.protect mutex (fun () -> Hashtbl.find_opt registry symbol) - -let symbols () = - Mutex.protect mutex (fun () -> Hashtbl.to_seq_keys registry |> List.of_seq) - -let implementation_of_rows ?membership_criteria (rows : tuple list) : - implementation = - { membership_criteria; produce = Some (fun _bindings -> Ok rows) } - -let implementation_of_producer ?membership_criteria - (produce : tuple -> (tuple list, string) result) : implementation = - { membership_criteria; produce = Some produce } +let implementation_of_producer ?membership_criteria (produce : tuple -> (tuple list, string) result) + : implementation = + {membership_criteria; produce= Some produce} let implementation_of_unit_producer ?membership_criteria (produce : unit -> (tuple list, string) result) : implementation = - { membership_criteria; produce = Some (fun _bindings -> produce ()) } + {membership_criteria; produce= Some (fun _bindings -> produce ())} |
