Commits

ccorrodi committed efe30d9

replace some fold_right calls with String.concat

  • Participants
  • Parent commits baa1d1a
  • Branches develop

Comments (0)

Files changed (1)

 module L = List
 module S = Str
 
-(* {2 Types} *)
+(** {2 Types} *)
 (** The command type represents a command that make runs. *)
 type command = string
 
 
 (** Return a string that represents the given variable definition. *)
 let s_of_var (var : variable) : string =
-  Printf.sprintf "name: '%s', value: '%s', origin: '%s', flavor: '%s'"
+  Printf.sprintf "%s %s %s\n"
     var.v_name
-    var.v_value
-    (s_of_var_origin var.v_origin)
     (s_of_var_flavor var.v_flavor)
+    var.v_value
 
 (** Write the given variables in human-readable form to a string. *)
 let s_of_vars (vars : variable list) : string =
 (** Pretty print the variable section. This is a valid make database section.
     *)
 let pp_vars (d : database) : string =
-  L.fold_right
-    (fun var s ->
-      Printf.sprintf "%s %s %s\n%s"
-      var.v_name
-      (s_of_var_flavor var.v_flavor)
-      var.v_value
-      s)
-    d.d_variables ""
+  let var_strings = L.map s_of_var d.d_variables in
+  String.concat "\n" var_strings
 
 (** Pretty print the directory section. This is a valid make database section.
     *)
 
 (** Pretty print the rule section. This is a valid make database section. *)
 let pp_rules (d : database) : string =
-  L.fold_right
-    (fun rule s ->
-      Printf.sprintf "%s\n%s"
-      (s_of_rule rule)
-      s)
-  d.d_implicit_rules ""
+  let rule_strings = L.map s_of_rule d.d_implicit_rules in
+  String.concat "\n" rule_strings
 
 (** Pretty print the files section. This is a valid make database section. *)
 let pp_files (d : database) : string =
-  L.fold_right
-    (fun rule s ->
-      Printf.sprintf "%s\n%s"
-      (s_of_rule rule)
-      s)
-  d.d_files ""
+  let file_strings = L.map s_of_rule d.d_files in
+  String.concat "\n" file_strings