260 Type (s, map (typ_of_dtyp descr sorts) ds)) descr; |
260 Type (s, map (typ_of_dtyp descr sorts) ds)) descr; |
261 |
261 |
262 (* get all branching types *) |
262 (* get all branching types *) |
263 |
263 |
264 fun get_branching_types descr sorts = |
264 fun get_branching_types descr sorts = |
265 map (typ_of_dtyp descr sorts) (Library.foldl (fn (Ts, (_, (_, _, constrs))) => |
265 map (typ_of_dtyp descr sorts) (fold (fn (_, (_, _, constrs)) => |
266 Library.foldl (fn (Ts', (_, cargs)) => foldr op union Ts' (map (fst o strip_dtyp) |
266 fold (fn (_, cargs) => fold (strip_dtyp #> fst #> fold (insert op =)) cargs) |
267 cargs)) (Ts, constrs)) ([], descr)); |
267 constrs) descr []); |
268 |
268 |
269 fun get_arities descr = Library.foldl (fn (is, (_, (_, _, constrs))) => |
269 fun get_arities descr = fold (fn (_, (_, _, constrs)) => |
270 Library.foldl (fn (is', (_, cargs)) => map (length o fst o strip_dtyp) |
270 fold (fn (_, cargs) => fold (insert op =) (map (length o fst o strip_dtyp) |
271 (List.filter is_rec_type cargs) union is') (is, constrs)) ([], descr); |
271 (List.filter is_rec_type cargs))) constrs) descr []; |
272 |
272 |
273 (* nonemptiness check for datatypes *) |
273 (* nonemptiness check for datatypes *) |
274 |
274 |
275 fun check_nonempty descr = |
275 fun check_nonempty descr = |
276 let |
276 let |