comparison src/expl_print.sml @ 45:3c1ce1b4eb3d

Explifying functors
author Adam Chlipala <adamc@hcoop.net>
date Thu, 19 Jun 2008 17:11:24 -0400
parents d16ef24de78b
children 0a5c312de09a
comparison
equal deleted inserted replaced
44:a9f3ce2d1b9b 45:3c1ce1b4eb3d
291 p_list_sep newline (fn x => x) psgis 291 p_list_sep newline (fn x => x) psgis
292 end, 292 end,
293 newline, 293 newline,
294 string "end"] 294 string "end"]
295 | SgnVar n => string (#1 (E.lookupSgnNamed env n)) 295 | SgnVar n => string (#1 (E.lookupSgnNamed env n))
296 | SgnFun (x, n, sgn, sgn') => box [string "functor",
297 space,
298 string "(",
299 string x,
300 space,
301 string ":",
302 space,
303 p_sgn env sgn,
304 string ")",
305 space,
306 string ":",
307 space,
308 p_sgn (E.pushStrNamed env x n sgn) sgn']
309 | SgnWhere (sgn, x, c) => box [p_sgn env sgn,
310 space,
311 string "where",
312 space,
313 string "con",
314 space,
315 string x,
316 space,
317 string "=",
318 space,
319 p_con env c]
296 320
297 fun p_decl env ((d, _) : decl) = 321 fun p_decl env ((d, _) : decl) =
298 case d of 322 case d of
299 DCon (x, n, k, c) => box [string "con", 323 DCon (x, n, k, c) => box [string "con",
300 space, 324 space,
347 string "end"] 371 string "end"]
348 | StrVar n => string (#1 (E.lookupStrNamed env n)) 372 | StrVar n => string (#1 (E.lookupStrNamed env n))
349 | StrProj (str, s) => box [p_str env str, 373 | StrProj (str, s) => box [p_str env str,
350 string ".", 374 string ".",
351 string s] 375 string s]
376 | StrFun (x, n, sgn, sgn', str) =>
377 let
378 val env' = E.pushStrNamed env x n sgn
379 in
380 box [string "functor",
381 space,
382 string "(",
383 string x,
384 space,
385 string ":",
386 space,
387 p_sgn env sgn,
388 string ")",
389 space,
390 string ":",
391 space,
392 p_sgn env' sgn',
393 space,
394 string "=>",
395 space,
396 p_str env' str]
397 end
398 | StrApp (str1, str2) => box [p_str env str1,
399 string "(",
400 p_str env str2,
401 string ")"]
352 402
353 and p_file env file = 403 and p_file env file =
354 let 404 let
355 val (pds, _) = ListUtil.foldlMap (fn (d, env) => 405 val (pds, _) = ListUtil.foldlMap (fn (d, env) =>
356 (p_decl env d, 406 (p_decl env d,