Import Upstream version 20180207
[hcoop/debian/mlton.git] / lib / mlton / basic / format.sig
1 (* Copyright (C) 2009 Matthew Fluet.
2 * Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
3 * Jagannathan, and Stephen Weeks.
4 *
5 * MLton is released under a BSD-style license.
6 * See the file MLton-LICENSE for details.
7 *)
8
9 signature FORMAT =
10 sig
11 type ('a, 'b) t
12
13 val eol: ('a, 'a) t
14 val format: (string, 'a) t -> 'a
15 val int: ('a, int -> 'a) t
16 val list: ('a, 'b -> 'a) t -> ('a, 'b list -> 'a) t
17 val lit: string -> ('a, 'a) t
18 val new: ('b -> string) -> ('a, 'b -> 'a) t
19 val o: ('a, 'b) t * ('c, 'a) t -> ('c, 'b) t
20 val string: ('a, string -> 'a) t
21 end
22
23 functor TestFormat (S: FORMAT): sig end =
24 struct
25
26 open S
27
28 val _ =
29 Assert.assert
30 ("TestFormat", fn () =>
31 "abc" = format (lit "abc")
32 andalso "abc" = format string "abc"
33 andalso "abc" = format (lit "a" o lit "b" o lit "c")
34 andalso "abc" = format (string o string o string) "a" "b" "c"
35 andalso "[a, b, c]" = format (list string) ["a", "b", "c"]
36 andalso "[1, 2, 3]" = format (list int) [1, 2, 3])
37
38 end