comparison src/elab_print.sml @ 1720:30c0ca20bf59

Pretty-print tuple types using tuple syntax
author Adam Chlipala <adam@chlipala.net>
date Sat, 21 Apr 2012 15:09:02 -0400
parents 05ae68e019b6
children 5df85275c0d4
comparison
equal deleted inserted replaced
1719:0bafdfae2ac7 1720:30c0ca20bf59
110 string "]", 110 string "]",
111 space, 111 space,
112 string "=>", 112 string "=>",
113 space, 113 space,
114 p_con env c3]) 114 p_con env c3])
115 | TRecord (CRecord (_, xcs), _) => box [string "{", 115 | TRecord (CRecord (_, xcs), _) =>
116 p_list (fn (x, c) => 116 let
117 box [p_name env x, 117 fun isTuple (n, xcs) =
118 space, 118 case xcs of
119 string ":", 119 [] => n > 2
120 space, 120 | ((CName s, _), _) :: xcs' =>
121 p_con env c]) xcs, 121 s = Int.toString n andalso isTuple (n+1, xcs')
122 string "}"] 122 | _ => false
123 in
124 if isTuple (1, xcs) then
125 case xcs of
126 (_, c) :: xcs =>
127 parenIf par (box [p_con' true env c,
128 p_list_sep (box []) (fn (_, c) => box [space,
129 string "*",
130 space,
131 p_con' true env c]) xcs])
132 | _ => raise Fail "ElabPrint: surprise empty tuple"
133 else
134 box [string "{",
135 p_list (fn (x, c) =>
136 box [p_name env x,
137 space,
138 string ":",
139 space,
140 p_con env c]) xcs,
141 string "}"]
142 end
123 | TRecord c => box [string "$", 143 | TRecord c => box [string "$",
124 p_con' true env c] 144 p_con' true env c]
125 145
126 | CRel n => 146 | CRel n =>
127 ((if !debug then 147 ((if !debug then