--- /dev/null
+(*
+ ||M|| This file is part of HELM, an Hypertextual, Electronic
+ ||A|| Library of Mathematics, developed at the Computer Science
+ ||T|| Department, University of Bologna, Italy.
+ ||I||
+ ||T|| HELM is free software; you can redistribute it and/or
+ ||A|| modify it under the terms of the GNU General Public License
+ \ / version 2 or (at your option) any later version.
+ \ / This software is distributed as is, NO WARRANTY.
+ V_______________________________________________________________ *)
+
+module F = Format
+module O = MetaOutput
+
+type out_channel = Pervasives.out_channel * F.formatter
+
+(* internal functions *******************************************************)
+
+let hal_dir = "hal"
+
+let hal_ext = ".hal"
+
+(* interface functions ******************************************************)
+
+let open_out f name =
+ let _ = Sys.command (Printf.sprintf "mkdir -p %s" hal_dir) in
+ let och = open_out (Filename.concat hal_dir (name ^ hal_ext)) in
+ let frm = F.formatter_of_out_channel och in
+ F.pp_set_margin frm max_int;
+ f (och, frm)
+
+let write_item f (_, frm) item =
+ O.pp_item f frm item
+
+let close_out f (och, _) =
+ close_out och; f ()