src/HOL/Tools/TFL/thry.ML
changeset 31784 bd3486c57ba3
parent 31723 f5cafe803b55
child 32035 8e77b6a250d5
equal deleted inserted replaced
31783:cfbe9609ceb1 31784:bd3486c57ba3
    58 (*---------------------------------------------------------------------------
    58 (*---------------------------------------------------------------------------
    59  * Get information about datatypes
    59  * Get information about datatypes
    60  *---------------------------------------------------------------------------*)
    60  *---------------------------------------------------------------------------*)
    61 
    61 
    62 fun match_info thy dtco =
    62 fun match_info thy dtco =
    63   case (Datatype.get_datatype thy dtco,
    63   case (Datatype.get_info thy dtco,
    64          Datatype.get_datatype_constrs thy dtco) of
    64          Datatype.get_constrs thy dtco) of
    65       (SOME { case_name, ... }, SOME constructors) =>
    65       (SOME { case_name, ... }, SOME constructors) =>
    66         SOME {case_const = Const (case_name, Sign.the_const_type thy case_name), constructors = map Const constructors}
    66         SOME {case_const = Const (case_name, Sign.the_const_type thy case_name), constructors = map Const constructors}
    67     | _ => NONE;
    67     | _ => NONE;
    68 
    68 
    69 fun induct_info thy dtco = case Datatype.get_datatype thy dtco of
    69 fun induct_info thy dtco = case Datatype.get_info thy dtco of
    70         NONE => NONE
    70         NONE => NONE
    71       | SOME {nchotomy, ...} =>
    71       | SOME {nchotomy, ...} =>
    72           SOME {nchotomy = nchotomy,
    72           SOME {nchotomy = nchotomy,
    73                 constructors = (map Const o the o Datatype.get_datatype_constrs thy) dtco};
    73                 constructors = (map Const o the o Datatype.get_constrs thy) dtco};
    74 
    74 
    75 fun extract_info thy =
    75 fun extract_info thy =
    76  let val infos = (map snd o Symtab.dest o Datatype.get_datatypes) thy
    76  let val infos = (map snd o Symtab.dest o Datatype.get_all) thy
    77  in {case_congs = map (mk_meta_eq o #case_cong) infos,
    77  in {case_congs = map (mk_meta_eq o #case_cong) infos,
    78      case_rewrites = List.concat (map (map mk_meta_eq o #case_rewrites) infos)}
    78      case_rewrites = List.concat (map (map mk_meta_eq o #case_rewrites) infos)}
    79  end;
    79  end;
    80 
    80 
    81 
    81