comparison src/core_print.sml @ 193:8a70e2919e86

Specialization of single-parameter datatypes
author Adam Chlipala <adamc@hcoop.net>
date Fri, 08 Aug 2008 17:55:51 -0400
parents 9bbf4d383381
children df5fd8f6913a
comparison
equal deleted inserted replaced
192:9bbf4d383381 193:8a70e2919e86
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) => box [string "[",
203 | ECon (_, pc, _, SOME e) => parenIf par (box [p_patCon env pc, 203 p_patCon env pc,
204 space, 204 string "]"]
205 p_exp' true env e]) 205 | ECon (_, pc, _, SOME e) => box [string "[",
206 p_patCon env pc,
207 space,
208 p_exp' true env e,
209 string "]"]
206 | EFfi (m, x) => box [string "FFI(", string m, string ".", string x, string ")"] 210 | EFfi (m, x) => box [string "FFI(", string m, string ".", string x, string ")"]
207 | EFfiApp (m, x, es) => box [string "FFI(", 211 | EFfiApp (m, x, es) => box [string "FFI(",
208 string m, 212 string m,
209 string ".", 213 string ".",
210 string x, 214 string x,
299 p_list_sep (box [space, string "|", space]) 303 p_list_sep (box [space, string "|", space])
300 (fn (p, e) => box [p_pat env p, 304 (fn (p, e) => box [p_pat env p,
301 space, 305 space,
302 string "=>", 306 string "=>",
303 space, 307 space,
304 p_exp env e]) pes]) 308 p_exp (E.patBinds env p) e]) pes])
305 309
306 | EWrite e => box [string "write(", 310 | EWrite e => box [string "write(",
307 p_exp env e, 311 p_exp env e,
308 string ")"] 312 string ")"]
309 313
347 fun p_datatype env (x, n, xs, cons) = 351 fun p_datatype env (x, n, xs, cons) =
348 let 352 let
349 val k = (KType, ErrorMsg.dummySpan) 353 val k = (KType, ErrorMsg.dummySpan)
350 val env = E.pushCNamed env x n (KType, ErrorMsg.dummySpan) NONE 354 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 355 val env = foldl (fn (x, env) => E.pushCRel env x k) env xs
356
357 val xp = if !debug then
358 string (x ^ "__" ^ Int.toString n)
359 else
360 string x
352 in 361 in
353 box [string "datatype", 362 box [string "datatype",
354 space, 363 space,
355 string x, 364 xp,
356 p_list_sep (box []) (fn x => box [space, string x]) xs, 365 p_list_sep (box []) (fn x => box [space, string x]) xs,
357 space, 366 space,
358 string "=", 367 string "=",
359 space, 368 space,
360 p_list_sep (box [space, string "|", space]) 369 p_list_sep (box [space, string "|", space])
361 (fn (x, n, NONE) => if !debug then (string (x ^ "__" ^ Int.toString n)) 370 (fn (x, n, NONE) => if !debug then (string (x ^ "__" ^ Int.toString n))
362 else string x 371 else string x
363 | (x, _, SOME t) => box [if !debug then (string (x ^ "__" ^ Int.toString n)) 372 | (x, n, SOME t) => box [if !debug then (string (x ^ "__" ^ Int.toString n))
364 else string x, space, string "of", space, p_con env t]) 373 else string x, space, string "of", space, p_con env t])
365 cons] 374 cons]
366 end 375 end
367 376
368 fun p_decl env (dAll as (d, _) : decl) = 377 fun p_decl env (dAll as (d, _) : decl) =