6316
|
1 |
(* Title: Pure/General/buffer.ML
|
|
2 |
ID: $Id$
|
|
3 |
Author: Markus Wenzel, TU Muenchen
|
8806
|
4 |
License: GPL (GNU GENERAL PUBLIC LICENSE)
|
6316
|
5 |
|
|
6 |
Simple string buffers.
|
|
7 |
*)
|
|
8 |
|
|
9 |
signature BUFFER =
|
|
10 |
sig
|
|
11 |
type T
|
|
12 |
val empty: T
|
|
13 |
val add: string -> T -> T
|
|
14 |
val content: T -> string
|
|
15 |
val write: Path.T -> T -> unit
|
|
16 |
end;
|
|
17 |
|
|
18 |
structure Buffer: BUFFER =
|
|
19 |
struct
|
|
20 |
|
|
21 |
datatype T = Buffer of string list;
|
|
22 |
|
|
23 |
val empty = Buffer [];
|
|
24 |
fun add x (Buffer xs) = Buffer (x :: xs);
|
|
25 |
fun content (Buffer xs) = implode (rev xs);
|
|
26 |
fun write path buffer = File.write path (content buffer);
|
|
27 |
|
|
28 |
end;
|