aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/SubstantialRelation.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kernel/SubstantialRelation.ml')
-rw-r--r--lib/kernel/SubstantialRelation.ml31
1 files changed, 9 insertions, 22 deletions
diff --git a/lib/kernel/SubstantialRelation.ml b/lib/kernel/SubstantialRelation.ml
index e89b008..f269686 100644
--- a/lib/kernel/SubstantialRelation.ml
+++ b/lib/kernel/SubstantialRelation.ml
@@ -81,22 +81,15 @@ module Make (S : Abstract.Storage.STORAGE) = struct
let open Concepts.Encoding in
[ "schema", Value.bencode_of_hash schematics;
"tuples", Value.bencode_of_hash tuples;
- ( "indexes",
- Bencode.Dict
- (BatMap.String.bindings indexes |> List.map (fun (a, h) -> a, Value.bencode_of_hash h))
- ) ]
+ "indexes", Bencode.of_map Value.bencode_of_hash indexes ]
let of_fields fields =
let open Utilities.Result in
let open Concepts.Encoding in
let* schematics = Bencode.field "schema" fields |>> Value.hash_of_bencode in
let* tuples = Bencode.field "tuples" fields |>> Value.hash_of_bencode in
- let* indexes = Bencode.field "indexes" fields |>> Bencode.as_dict in
- let* indexes =
- List.map (fun (a, h) -> Value.hash_of_bencode h |> Result.map (fun h -> a, h)) indexes
- |> Utilities.List.sequence
- in
- Ok {schematics; tuples; indexes= BatMap.String.of_list indexes}
+ let* indexes = Bencode.field "indexes" fields |>> Bencode.to_map Value.hash_of_bencode in
+ Ok {schematics; tuples; indexes}
end
let encode = Representation.to_blob
@@ -109,23 +102,17 @@ module Make (S : Abstract.Storage.STORAGE) = struct
let store_schema tx description =
Concepts.Encoding.Bencode.(
- Dict
- ( BatMap.String.bindings description
- |> List.map (fun (name, {Protocols.Schematics.domain; _}) -> name, String domain) )
- |> to_blob )
+ of_map (fun {Protocols.Schematics.domain; _} -> String domain) description |> to_blob )
|> SI.store_blob tx
let schema_of tx schematics =
let open Utilities.Result in
+ let open Concepts.Encoding in
let* data = SI.get_req tx (S.Hash schematics) in
- let* fields = Concepts.Encoding.Bencode.of_blob data in
- let* kvs = Concepts.Encoding.Bencode.as_dict fields in
- kvs
- |> List.map (fun (name, domain) ->
- Concepts.Encoding.Bencode.as_string domain
- |> Result.map (fun domain -> name, {Protocols.Schematics.domain; provenance= []}) )
- |> Utilities.List.sequence
- |> Result.map BatMap.String.of_list
+ Bencode.of_blob data
+ |>> Bencode.to_map (fun domain ->
+ Bencode.as_string domain
+ |> Result.map (fun domain -> {Protocols.Schematics.domain; provenance= []}) )
let prefix value =
Concepts.Encoding.Bencode.to_bytes (Concepts.Tuple.bencode_of_value value)