diff options
| author | Marcos Magueta <mmagueta@MacMini.local> | 2024-11-24 22:23:32 -0300 |
|---|---|---|
| committer | Marcos Magueta <mmagueta@MacMini.local> | 2024-11-24 22:23:32 -0300 |
| commit | 3235bcba70e0b9a5e9a8ed0fc18f96ce5c6beb57 (patch) | |
| tree | 0d7202961ebb0fc62d593c6ff403fbafdf0292db /lib/relation.ml | |
| parent | c310cdc8d684a89e24b8b5910e39c4894b60c7c0 (diff) | |
| download | Sakura-3235bcba70e0b9a5e9a8ed0fc18f96ce5c6beb57.tar.gz Sakura-3235bcba70e0b9a5e9a8ed0fc18f96ce5c6beb57.zip | |
relation building
Diffstat (limited to 'lib/relation.ml')
| -rw-r--r-- | lib/relation.ml | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/relation.ml b/lib/relation.ml new file mode 100644 index 0000000..a4e14c4 --- /dev/null +++ b/lib/relation.ml @@ -0,0 +1,39 @@ +open Sexplib0 +open Sexplib0.Sexp_conv +open Ppx_xml_conv +module Protocol = struct + type tuples = string list list + [@@deriving sexp, ] +end + +let write_and_retrieve() = + let open Disk in + let stream: Executor.history = [{state = Executor._EMPTY_SHA_HASH_; files = Executor.StringMap.empty}] in + let locations: Executor.locations = Executor.StringMap.empty in + let open Extensions.Result in + let command_write1: Command.t = + {kind = Command.WRITE; timestamp = 10.0; hash = ""; content = "Daisy"; filename = "user/first-name"; references = []} in + let+ ((stream, locations), Command.ComputedHash handle) = Command.commit_and_perform stream locations command_write1 in + let command_write2: Command.t = + {kind = Command.WRITE; timestamp = 10.0; hash = ""; content = "Blossom"; filename = "user/last-name"; references = [handle]} in + let command_write3: Command.t = + {kind = Command.WRITE; timestamp = 10.0; hash = ""; content = "Minnie"; filename = "user/first-name"; references = []} in + let+ ((stream, locations), Command.ComputedHash _handle) = Command.commit_and_perform stream locations command_write2 in + let+ ((stream, locations), Command.ComputedHash handle) = Command.commit_and_perform stream locations command_write3 in + let command_write4: Command.t = + {kind = Command.WRITE; timestamp = 10.0; hash = ""; content = "Mouse"; filename = "user/last-name"; references = [handle]} in + let+ ((stream, locations), Command.ComputedHash _handle) = Command.commit_and_perform stream locations command_write4 in + let command_write5: Command.t = + {kind = Command.WRITE; timestamp = 10.0; hash = ""; content = "Billie"; filename = "user/first-name"; references = []} in + let+ ((stream, locations), Command.ComputedHash handle) = Command.commit_and_perform stream locations command_write5 in + let command_write6: Command.t = + {kind = Command.WRITE; timestamp = 10.0; hash = ""; content = "Beans"; filename = "user/last-name"; references = [handle]} in + let+ ((stream, locations), Command.ComputedHash _handle) = Command.commit_and_perform stream locations command_write6 in + let command_read1: Command.t = {kind = Command.READ; timestamp = 0.0; hash = ""; content = ""; filename = "user/first-name"; references = []} in + let+ (_, Command.Read first_name) = Command.commit_and_perform (List.tl stream) locations command_read1 in + let command_read2: Command.t = {kind = Command.READ; timestamp = 0.0; hash = ""; content = ""; filename = "user/last-name"; references = []} in + let+ (_, Command.Read last_name) = Command.commit_and_perform (List.tl stream) locations command_read2 in + (* List.iter (fun a -> print_endline a) (List.map Bytes.to_string first_name); *) + (* List.iter (fun a -> print_endline a) (List.map Bytes.to_string last_name); *) + Ok (Sexp.to_string (Protocol.sexp_of_tuples [List.map Bytes.to_string first_name; List.map Bytes.to_string last_name])) + [@@warning "-8"] (* Suppress pattern match incomplete warnings *) |
