equal
deleted
inserted
replaced
431 (case find_first (equal s o fst o fst) cases' of |
431 (case find_first (equal s o fst o fst) cases' of |
432 NONE => (list_abs (map (rpair dummyT) |
432 NONE => (list_abs (map (rpair dummyT) |
433 (DatatypeProp.make_tnames (map (typ_of_dtyp descr sorts) dt)), |
433 (DatatypeProp.make_tnames (map (typ_of_dtyp descr sorts) dt)), |
434 case default of |
434 case default of |
435 NONE => (warning ("No clause for constructor " ^ s ^ |
435 NONE => (warning ("No clause for constructor " ^ s ^ |
436 " in case expression"); Const ("undefined", dummyT)) |
436 " in case expression"); Const ("HOL.undefined", dummyT)) |
437 | SOME t => t), cases) |
437 | SOME t => t), cases) |
438 | SOME (c as ((_, vs), t)) => |
438 | SOME (c as ((_, vs), t)) => |
439 if length dt <> length vs then |
439 if length dt <> length vs then |
440 case_error ("Wrong number of arguments for constructor " ^ s) |
440 case_error ("Wrong number of arguments for constructor " ^ s) |
441 (SOME tname) vs |
441 (SOME tname) vs |
484 (body, []) (cons cname) |
484 (body, []) (cons cname) |
485 val cases' = sort (int_ord o swap o pairself (length o snd)) |
485 val cases' = sort (int_ord o swap o pairself (length o snd)) |
486 (fold_rev count_cases cases []); |
486 (fold_rev count_cases cases []); |
487 fun mk_case1 (cname, (vs, body), _) = Syntax.const "_case1" $ |
487 fun mk_case1 (cname, (vs, body), _) = Syntax.const "_case1" $ |
488 list_comb (Syntax.const cname, vs) $ body; |
488 list_comb (Syntax.const cname, vs) $ body; |
489 fun is_undefined (Const ("undefined", _)) = true |
489 fun is_undefined (Const ("HOL.undefined", _)) = true |
490 | is_undefined _ = false; |
490 | is_undefined _ = false; |
491 in |
491 in |
492 Syntax.const "_case_syntax" $ x $ |
492 Syntax.const "_case_syntax" $ x $ |
493 foldr1 (fn (t, u) => Syntax.const "_case2" $ t $ u) (map mk_case1 |
493 foldr1 (fn (t, u) => Syntax.const "_case2" $ t $ u) (map mk_case1 |
494 (case find_first (is_undefined o fst) cases' of |
494 (case find_first (is_undefined o fst) cases' of |