src/Pure/General/buffer.ML
author wenzelm
Fri, 05 May 2000 22:02:46 +0200
changeset 8806 a202293db3f6
parent 7767 659648e14c3e
child 14981 e73f8140af78
permissions -rw-r--r--
GPLed;

(*  Title:      Pure/General/buffer.ML
    ID:         $Id$
    Author:     Markus Wenzel, TU Muenchen
    License:    GPL (GNU GENERAL PUBLIC LICENSE)

Simple string buffers.
*)

signature BUFFER =
sig
  type T
  val empty: T
  val add: string -> T -> T
  val content: T -> string
  val write: Path.T -> T -> unit
end;

structure Buffer: BUFFER =
struct

datatype T = Buffer of string list;

val empty = Buffer [];
fun add x (Buffer xs) = Buffer (x :: xs);
fun content (Buffer xs) = implode (rev xs);
fun write path buffer = File.write path (content buffer);

end;