Import Upstream version 20180207
[hcoop/debian/mlton.git] / mlton / atoms / record.sig
1 (* Copyright (C) 2017 Matthew Fluet.
2 * Copyright (C) 1999-2007 Henry Cejtin, Matthew Fluet, Suresh
3 * Jagannathan, and Stephen Weeks.
4 * Copyright (C) 1997-2000 NEC Research Institute.
5 *
6 * MLton is released under a BSD-style license.
7 * See the file MLton-LICENSE for details.
8 *)
9
10 signature RECORD_STRUCTS =
11 sig
12 val isSorted: bool
13 structure Field: FIELD
14 end
15
16 signature RECORD =
17 sig
18 include RECORD_STRUCTS
19
20 type 'a t
21
22 (* Create a record with the same fields but a new range.
23 * Also return some additional info.
24 *)
25 val change: 'a t * ('a vector -> 'b vector * 'c) -> 'b t * 'c
26 (* detuple r returns the components, if r is a tuple *)
27 val detupleOpt: 'a t -> 'a vector option
28 val domain: 'a t -> Field.t vector
29 val exists: 'a t * ('a -> bool) -> bool
30 val fold: 'a t * 'b * ('a * 'b -> 'b) -> 'b
31 val forall: 'a t * ('a -> bool) -> bool
32 val foreach: 'a t * ('a -> unit) -> unit
33 val fromVector: (Field.t * 'a) vector -> 'a t
34 val layout: {record: 'a t,
35 separator: string,
36 extra: string,
37 layoutTuple: 'a vector -> Layout.t,
38 layoutElt: 'a -> Layout.t} -> Layout.t
39 val map: 'a t * ('a -> 'b) -> 'b t
40 val peek: 'a t * Field.t -> 'a option
41 (* range {1 = a, 2 = b, 3 = c} returns [a, b, c] *)
42 val range: 'a t -> 'a vector
43 val toVector: 'a t -> (Field.t * 'a) vector
44 (* tuple [a, b, c] creates {1 = a, 2 = b, 3 = c} *)
45 val tuple: 'a vector -> 'a t
46 val unzip: 'a t -> Field.t vector * 'a vector
47 val zip: Field.t vector * 'a vector -> 'a t
48 end