comparison src/flat_util.sig @ 26:4ab19c19665f

Closure conversion
author Adam Chlipala <adamc@hcoop.net>
date Tue, 10 Jun 2008 15:56:33 -0400
parents
children 104d43266b33
comparison
equal deleted inserted replaced
25:0a762c73824d 26:4ab19c19665f
1 (* Copyright (c) 2008, Adam Chlipala
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * - Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 * - Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12 * - The names of contributors may not be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 *)
27
28 signature FLAT_UTIL = sig
29
30 structure Typ : sig
31 val mapfold : (Flat.typ', 'state, 'abort) Search.mapfolder
32 -> (Flat.typ, 'state, 'abort) Search.mapfolder
33
34 val map : (Flat.typ' -> Flat.typ')
35 -> Flat.typ -> Flat.typ
36
37 val fold : (Flat.typ' * 'state -> 'state)
38 -> 'state -> Flat.typ -> 'state
39
40 val exists : (Flat.typ' -> bool) -> Flat.typ -> bool
41 end
42
43 structure Exp : sig
44 datatype binder =
45 NamedT of string * int * Flat.typ option
46 | RelE of string * Flat.typ
47 | NamedE of string * int * Flat.typ * Flat.exp option
48
49 val mapfoldB : {typ : (Flat.typ', 'state, 'abort) Search.mapfolder,
50 exp : ('typtext, Flat.exp', 'state, 'abort) Search.mapfolderB,
51 bind : 'typtext * binder -> 'typtext}
52 -> ('typtext, Flat.exp, 'state, 'abort) Search.mapfolderB
53 val mapfold : {typ : (Flat.typ', 'state, 'abort) Search.mapfolder,
54 exp : (Flat.exp', 'state, 'abort) Search.mapfolder}
55 -> (Flat.exp, 'state, 'abort) Search.mapfolder
56
57 val map : {typ : Flat.typ' -> Flat.typ',
58 exp : Flat.exp' -> Flat.exp'}
59 -> Flat.exp -> Flat.exp
60 val mapB : {typ : Flat.typ' -> Flat.typ',
61 exp : 'typtext -> Flat.exp' -> Flat.exp',
62 bind : 'typtext * binder -> 'typtext}
63 -> 'typtext -> (Flat.exp -> Flat.exp)
64
65 val fold : {typ : Flat.typ' * 'state -> 'state,
66 exp : Flat.exp' * 'state -> 'state}
67 -> 'state -> Flat.exp -> 'state
68
69 val exists : {typ : Flat.typ' -> bool,
70 exp : Flat.exp' -> bool} -> Flat.exp -> bool
71 end
72
73 structure Decl : sig
74 datatype binder = datatype Exp.binder
75
76 val mapfoldB : {typ : (Flat.typ', 'state, 'abort) Search.mapfolder,
77 exp : ('typtext, Flat.exp', 'state, 'abort) Search.mapfolderB,
78 decl : ('typtext, Flat.decl', 'state, 'abort) Search.mapfolderB,
79 bind : 'typtext * binder -> 'typtext}
80 -> ('typtext, Flat.decl, 'state, 'abort) Search.mapfolderB
81 val mapfold : {typ : (Flat.typ', 'state, 'abort) Search.mapfolder,
82 exp : (Flat.exp', 'state, 'abort) Search.mapfolder,
83 decl : (Flat.decl', 'state, 'abort) Search.mapfolder}
84 -> (Flat.decl, 'state, 'abort) Search.mapfolder
85
86 val fold : {typ : Flat.typ' * 'state -> 'state,
87 exp : Flat.exp' * 'state -> 'state,
88 decl : Flat.decl' * 'state -> 'state}
89 -> 'state -> Flat.decl -> 'state
90 end
91
92 structure File : sig
93 datatype binder =
94 NamedT of string * int * Flat.typ option
95 | RelE of string * Flat.typ
96 | NamedE of string * int * Flat.typ * Flat.exp option
97 | F of int * string * Flat.typ * Flat.typ * Flat.exp
98
99 val mapfoldB : {typ : (Flat.typ', 'state, 'abort) Search.mapfolder,
100 exp : ('typtext, Flat.exp', 'state, 'abort) Search.mapfolderB,
101 decl : ('typtext, Flat.decl', 'state, 'abort) Search.mapfolderB,
102 bind : 'typtext * binder -> 'typtext}
103 -> ('typtext, Flat.file, 'state, 'abort) Search.mapfolderB
104
105 val mapfold : {typ : (Flat.typ', 'state, 'abort) Search.mapfolder,
106 exp : (Flat.exp', 'state, 'abort) Search.mapfolder,
107 decl : (Flat.decl', 'state, 'abort) Search.mapfolder}
108 -> (Flat.file, 'state, 'abort) Search.mapfolder
109
110 val mapB : {typ : Flat.typ' -> Flat.typ',
111 exp : 'typtext -> Flat.exp' -> Flat.exp',
112 decl : 'typtext -> Flat.decl' -> Flat.decl',
113 bind : 'typtext * binder -> 'typtext}
114 -> 'typtext -> Flat.file -> Flat.file
115
116 val fold : {typ : Flat.typ' * 'state -> 'state,
117 exp : Flat.exp' * 'state -> 'state,
118 decl : Flat.decl' * 'state -> 'state}
119 -> 'state -> Flat.file -> 'state
120 end
121
122 end