aboutsummaryrefslogtreecommitdiff
path: root/lib/configuration/syntax.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/configuration/syntax.ml')
-rw-r--r--lib/configuration/syntax.ml69
1 files changed, 36 insertions, 33 deletions
diff --git a/lib/configuration/syntax.ml b/lib/configuration/syntax.ml
index 8efdc59..1eb3c70 100644
--- a/lib/configuration/syntax.ml
+++ b/lib/configuration/syntax.ml
@@ -13,46 +13,49 @@ let toml_of_table Table.{ file; tab; name } =
Otoml.table values
-type extern = {
- intern_key : Path.t E.t;
- target : Table.t;
- extern_key : Path.column E.t;
- allow_missing : bool;
- match_rule : string option;
-}
+module Extern = struct
+ type t = {
+ intern_key : Path.t E.t;
+ target : Table.t;
+ extern_key : Path.column E.t;
+ allow_missing : bool;
+ match_rule : string option;
+ }
+ (** Describe a relation beteween two tables *)
-let toml_of_extern extern =
- let values =
- [
- ( "intern_key",
- Otoml.string
- @@ ImportExpression.Repr.repr ~top:true Path.repr extern.intern_key );
- ( "extern_key",
- Otoml.string
- @@ ImportExpression.Repr.repr ~top:true
- (fun v -> ":" ^ ImportCSV.Csv.column_to_string v)
- extern.extern_key );
- ("file", Otoml.string extern.target.file);
- ("allow_missing", Otoml.boolean extern.allow_missing);
- ]
- in
+ let toml_of_extern extern =
+ let values =
+ [
+ ( "intern_key",
+ Otoml.string
+ @@ ImportExpression.Repr.repr ~top:true Path.repr extern.intern_key );
+ ( "extern_key",
+ Otoml.string
+ @@ ImportExpression.Repr.repr ~top:true
+ (fun v -> ":" ^ ImportCSV.Csv.column_to_string v)
+ extern.extern_key );
+ ("file", Otoml.string extern.target.file);
+ ("allow_missing", Otoml.boolean extern.allow_missing);
+ ]
+ in
- let values =
- match extern.target.tab with
- | 1 -> values
- | tab -> ("tab", Otoml.integer tab) :: values
- in
+ let values =
+ match extern.target.tab with
+ | 1 -> values
+ | tab -> ("tab", Otoml.integer tab) :: values
+ in
- Otoml.table values
+ Otoml.table values
-let toml_of_externs externs =
- List.map externs ~f:(fun e -> (e.target.name, toml_of_extern e))
- |> Otoml.table
+ let toml externs =
+ List.map externs ~f:(fun e -> (e.target.name, toml_of_extern e))
+ |> Otoml.table
+end
type t = {
version : int;
source : Table.t;
- externals : extern list;
+ externals : Extern.t list;
columns : Path.t E.t list;
filters : Path.t E.t list;
sort : Path.t E.t list;
@@ -80,7 +83,7 @@ let repr t =
[
("version", Otoml.integer t.version);
("source", toml_of_table t.source);
- ("externals", toml_of_externs t.externals);
+ ("externals", Extern.toml t.externals);
("sheet", sheet);
]
in