diff options
Diffstat (limited to '')
| -rw-r--r-- | lib/concepts/Relation.ml | 18 | ||||
| -rw-r--r-- | lib/concepts/Relation.mli | 2 |
2 files changed, 5 insertions, 15 deletions
diff --git a/lib/concepts/Relation.ml b/lib/concepts/Relation.ml index a4fb341..1194804 100644 --- a/lib/concepts/Relation.ml +++ b/lib/concepts/Relation.ml @@ -1,10 +1,6 @@ type address = Hash.hash type schema = string BatMap.String.t - -type t = - { name: string; - tuples: address; - schema: schema } +type t = {name: string; tuples: address; schema: schema} module Field = struct let name = "name" @@ -25,31 +21,27 @@ module Error = struct end let make ~name ~tuples ~schema = {name; tuples; schema} - let name relation = relation.name let tuples relation = relation.tuples let schema relation = relation.schema - let schema_empty = BatMap.String.empty let schema_of_list fields = - List.fold_left (fun acc (name, domain) -> BatMap.String.add name domain acc) schema_empty - fields + List.fold_left (fun acc (name, domain) -> BatMap.String.add name domain acc) schema_empty fields let schema_to_list schema = BatMap.String.bindings schema let schema_to_bencode schema = Codec.Bencode.Dict - (schema_to_list schema - |> List.map (fun (name, domain) -> name, Codec.Bencode.String domain) ) + (schema_to_list schema |> List.map (fun (name, domain) -> name, Codec.Bencode.String domain)) let schema_of_bencode value = let open Utilities.Result in let* fields = Codec.Bencode.as_dict value in fields |> List.map (fun (name, domain) -> - let* domain = Codec.Bencode.as_string domain in - Ok (name, domain) ) + let* domain = Codec.Bencode.as_string domain in + Ok (name, domain) ) |> sequence |> Result.map schema_of_list diff --git a/lib/concepts/Relation.mli b/lib/concepts/Relation.mli index 5319a3d..d370578 100644 --- a/lib/concepts/Relation.mli +++ b/lib/concepts/Relation.mli @@ -5,11 +5,9 @@ type schema include Object.S with type t := t val make : name:string -> tuples:address -> schema:schema -> t - val name : t -> string val tuples : t -> address val schema : t -> schema - val schema_empty : schema val schema_of_list : (string * string) list -> schema val schema_to_list : schema -> (string * string) list |
