Mercurial > urweb
comparison src/core_print.sml @ 192:9bbf4d383381
Parametrized datatypes through corify
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Fri, 08 Aug 2008 10:59:06 -0400 |
parents | 8e9f97508f0d |
children | 8a70e2919e86 |
comparison
equal
deleted
inserted
replaced
191:aa54250f58ac | 192:9bbf4d383381 |
---|---|
171 fun p_pat' par env (p, _) = | 171 fun p_pat' par env (p, _) = |
172 case p of | 172 case p of |
173 PWild => string "_" | 173 PWild => string "_" |
174 | PVar (s, _) => string s | 174 | PVar (s, _) => string s |
175 | PPrim p => Prim.p_t p | 175 | PPrim p => Prim.p_t p |
176 | PCon (_, n, NONE) => p_patCon env n | 176 | PCon (_, n, _, NONE) => p_patCon env n |
177 | PCon (_,n, SOME p) => parenIf par (box [p_patCon env n, | 177 | PCon (_, n, _, SOME p) => parenIf par (box [p_patCon env n, |
178 space, | 178 space, |
179 p_pat' true env p]) | 179 p_pat' true env p]) |
180 | PRecord xps => | 180 | PRecord xps => |
181 box [string "{", | 181 box [string "{", |
182 p_list_sep (box [string ",", space]) (fn (x, p, _) => | 182 p_list_sep (box [string ",", space]) (fn (x, p, _) => |
183 box [string x, | 183 box [string x, |
184 space, | 184 space, |
197 string (#1 (E.lookupERel env n) ^ "_" ^ Int.toString n) | 197 string (#1 (E.lookupERel env n) ^ "_" ^ Int.toString n) |
198 else | 198 else |
199 string (#1 (E.lookupERel env n))) | 199 string (#1 (E.lookupERel env n))) |
200 handle E.UnboundRel _ => string ("UNBOUND_" ^ Int.toString n)) | 200 handle E.UnboundRel _ => string ("UNBOUND_" ^ Int.toString n)) |
201 | ENamed n => p_enamed env n | 201 | ENamed n => p_enamed env n |
202 | ECon (_, pc, NONE) => p_patCon env pc | 202 | ECon (_, pc, _, NONE) => p_patCon env pc |
203 | ECon (_, pc, SOME e) => parenIf par (box [p_patCon env pc, | 203 | ECon (_, pc, _, SOME e) => parenIf par (box [p_patCon env pc, |
204 space, | 204 space, |
205 p_exp' true env e]) | 205 p_exp' true env e]) |
206 | EFfi (m, x) => box [string "FFI(", string m, string ".", string x, string ")"] | 206 | EFfi (m, x) => box [string "FFI(", string m, string ".", string x, string ")"] |
207 | EFfiApp (m, x, es) => box [string "FFI(", | 207 | EFfiApp (m, x, es) => box [string "FFI(", |
208 string m, | 208 string m, |
209 string ".", | 209 string ".", |
210 string x, | 210 string x, |
342 fun p_export_kind ck = | 342 fun p_export_kind ck = |
343 case ck of | 343 case ck of |
344 Link => string "link" | 344 Link => string "link" |
345 | Action => string "action" | 345 | Action => string "action" |
346 | 346 |
347 fun p_datatype env (x, n, cons) = | 347 fun p_datatype env (x, n, xs, cons) = |
348 let | 348 let |
349 val k = (KType, ErrorMsg.dummySpan) | |
349 val env = E.pushCNamed env x n (KType, ErrorMsg.dummySpan) NONE | 350 val env = E.pushCNamed env x n (KType, ErrorMsg.dummySpan) NONE |
351 val env = foldl (fn (x, env) => E.pushCRel env x k) env xs | |
350 in | 352 in |
351 box [string "datatype", | 353 box [string "datatype", |
352 space, | 354 space, |
353 string x, | 355 string x, |
356 p_list_sep (box []) (fn x => box [space, string x]) xs, | |
354 space, | 357 space, |
355 string "=", | 358 string "=", |
356 space, | 359 space, |
357 p_list_sep (box [space, string "|", space]) | 360 p_list_sep (box [space, string "|", space]) |
358 (fn (x, n, NONE) => if !debug then (string (x ^ "__" ^ Int.toString n)) | 361 (fn (x, n, NONE) => if !debug then (string (x ^ "__" ^ Int.toString n)) |