110 fun pretty_items _ _ [] = [] |
110 fun pretty_items _ _ [] = [] |
111 | pretty_items keyword sep (x :: ys) = |
111 | pretty_items keyword sep (x :: ys) = |
112 Pretty.block [Pretty.keyword2 keyword, Pretty.brk 1, x] :: |
112 Pretty.block [Pretty.keyword2 keyword, Pretty.brk 1, x] :: |
113 map (fn y => Pretty.block [Pretty.str " ", Pretty.keyword2 sep, Pretty.brk 1, y]) ys; |
113 map (fn y => Pretty.block [Pretty.str " ", Pretty.keyword2 sep, Pretty.brk 1, y]) ys; |
114 |
114 |
115 fun pretty_name_atts ctxt (b, atts) sep = |
|
116 if Attrib.is_empty_binding (b, atts) then [] |
|
117 else |
|
118 [Pretty.block (Pretty.breaks |
|
119 (Binding.pretty b :: Attrib.pretty_attribs ctxt atts @ [Pretty.str sep]))]; |
|
120 |
|
121 |
115 |
122 (* pretty_stmt *) |
116 (* pretty_stmt *) |
123 |
117 |
124 fun pretty_stmt ctxt = |
118 fun pretty_stmt ctxt = |
125 let |
119 let |
126 val prt_typ = Pretty.quote o Syntax.pretty_typ ctxt; |
120 val prt_typ = Pretty.quote o Syntax.pretty_typ ctxt; |
127 val prt_term = Pretty.quote o Syntax.pretty_term ctxt; |
121 val prt_term = Pretty.quote o Syntax.pretty_term ctxt; |
128 val prt_terms = separate (Pretty.keyword2 "and") o map prt_term; |
122 val prt_terms = separate (Pretty.keyword2 "and") o map prt_term; |
129 val prt_name_atts = pretty_name_atts ctxt; |
123 val prt_binding = Attrib.pretty_binding ctxt; |
130 |
124 |
131 fun prt_show (a, ts) = |
125 fun prt_show (a, ts) = |
132 Pretty.block (Pretty.breaks (prt_name_atts a ":" @ prt_terms (map fst ts))); |
126 Pretty.block (Pretty.breaks (prt_binding a ":" @ prt_terms (map fst ts))); |
133 |
127 |
134 fun prt_var (x, SOME T) = Pretty.block |
128 fun prt_var (x, SOME T) = Pretty.block |
135 [Pretty.str (Binding.name_of x ^ " ::"), Pretty.brk 1, prt_typ T] |
129 [Pretty.str (Binding.name_of x ^ " ::"), Pretty.brk 1, prt_typ T] |
136 | prt_var (x, NONE) = Pretty.str (Binding.name_of x); |
130 | prt_var (x, NONE) = Pretty.str (Binding.name_of x); |
137 val prt_vars = separate (Pretty.keyword2 "and") o map prt_var; |
131 val prt_vars = separate (Pretty.keyword2 "and") o map prt_var; |
151 let |
145 let |
152 val prt_typ = Pretty.quote o Syntax.pretty_typ ctxt; |
146 val prt_typ = Pretty.quote o Syntax.pretty_typ ctxt; |
153 val prt_term = Pretty.quote o Syntax.pretty_term ctxt; |
147 val prt_term = Pretty.quote o Syntax.pretty_term ctxt; |
154 val prt_thm = Pretty.backquote o Display.pretty_thm ctxt; |
148 val prt_thm = Pretty.backquote o Display.pretty_thm ctxt; |
155 |
149 |
156 fun prt_name_atts (b, atts) sep = |
150 fun prt_binding (b, atts) = |
157 if not show_attribs orelse null atts then |
151 Attrib.pretty_binding ctxt (b, if show_attribs then atts else []); |
158 [Pretty.block [Binding.pretty b, Pretty.str sep]] |
|
159 else pretty_name_atts ctxt (b, atts) sep; |
|
160 |
152 |
161 fun prt_fact (ths, atts) = |
153 fun prt_fact (ths, atts) = |
162 if not show_attribs orelse null atts then map prt_thm ths |
154 if not show_attribs orelse null atts then map prt_thm ths |
163 else |
155 else |
164 Pretty.enclose "(" ")" (Pretty.breaks (map prt_thm ths)) :: |
156 Pretty.enclose "(" ")" (Pretty.breaks (map prt_thm ths)) :: |
172 | prt_fix (x, NONE, mx) = Pretty.block (Pretty.str (Binding.name_of x) :: |
164 | prt_fix (x, NONE, mx) = Pretty.block (Pretty.str (Binding.name_of x) :: |
173 Pretty.brk 1 :: prt_mixfix mx); |
165 Pretty.brk 1 :: prt_mixfix mx); |
174 fun prt_constrain (x, T) = prt_fix (Binding.name x, SOME T, NoSyn); |
166 fun prt_constrain (x, T) = prt_fix (Binding.name x, SOME T, NoSyn); |
175 |
167 |
176 fun prt_asm (a, ts) = |
168 fun prt_asm (a, ts) = |
177 Pretty.block (Pretty.breaks (prt_name_atts a ":" @ map (prt_term o fst) ts)); |
169 Pretty.block (Pretty.breaks (prt_binding a ":" @ map (prt_term o fst) ts)); |
178 fun prt_def (a, (t, _)) = |
170 fun prt_def (a, (t, _)) = |
179 Pretty.block (Pretty.breaks (prt_name_atts a ":" @ [prt_term t])); |
171 Pretty.block (Pretty.breaks (prt_binding a ":" @ [prt_term t])); |
180 |
172 |
181 fun prt_note (a, ths) = |
173 fun prt_note (a, ths) = |
182 Pretty.block (Pretty.breaks (flat (prt_name_atts a "=" :: map prt_fact ths))); |
174 Pretty.block (Pretty.breaks (flat (prt_binding a " =" :: map prt_fact ths))); |
183 in |
175 in |
184 fn Fixes fixes => pretty_items "fixes" "and" (map prt_fix fixes) |
176 fn Fixes fixes => pretty_items "fixes" "and" (map prt_fix fixes) |
185 | Constrains xs => pretty_items "constrains" "and" (map prt_constrain xs) |
177 | Constrains xs => pretty_items "constrains" "and" (map prt_constrain xs) |
186 | Assumes asms => pretty_items "assumes" "and" (map prt_asm asms) |
178 | Assumes asms => pretty_items "assumes" "and" (map prt_asm asms) |
187 | Defines defs => pretty_items "defines" "and" (map prt_def defs) |
179 | Defines defs => pretty_items "defines" "and" (map prt_def defs) |