src/Pure/Isar/typedecl.ML
changeset 42360 da8817d01e7c
parent 38831 4933a3dfd745
child 42375 774df7c59508
equal deleted inserted replaced
42359:6ca5407863ed 42360:da8817d01e7c
    49 fun global_type lthy (b, raw_args) =
    49 fun global_type lthy (b, raw_args) =
    50   let
    50   let
    51     fun err msg = error (msg ^ " in type declaration " ^ quote (Binding.str_of b));
    51     fun err msg = error (msg ^ " in type declaration " ^ quote (Binding.str_of b));
    52 
    52 
    53     val _ = has_duplicates (eq_fst op =) raw_args andalso err "Duplicate parameters";
    53     val _ = has_duplicates (eq_fst op =) raw_args andalso err "Duplicate parameters";
    54     val args = map (TFree o ProofContext.check_tfree lthy) raw_args;
    54     val args = map (TFree o Proof_Context.check_tfree lthy) raw_args;
    55     val T = Type (Local_Theory.full_name lthy b, args);
    55     val T = Type (Local_Theory.full_name lthy b, args);
    56 
    56 
    57     val bad_args =
    57     val bad_args =
    58       #2 (Term.dest_Type (Logic.type_map (singleton (Variable.polymorphic lthy)) T))
    58       #2 (Term.dest_Type (Logic.type_map (singleton (Variable.polymorphic lthy)) T))
    59       |> filter_out Term.is_TVar;
    59       |> filter_out Term.is_TVar;
    96     |> pair name
    96     |> pair name
    97   end;
    97   end;
    98 
    98 
    99 fun read_abbrev b ctxt raw_rhs =
    99 fun read_abbrev b ctxt raw_rhs =
   100   let
   100   let
   101     val rhs = ProofContext.read_typ_syntax (ctxt |> ProofContext.set_defsort []) raw_rhs;
   101     val rhs = Proof_Context.read_typ_syntax (ctxt |> Proof_Context.set_defsort []) raw_rhs;
   102     val ignored = Term.fold_atyps_sorts (fn (_, []) => I | (T, _) => insert (op =) T) rhs [];
   102     val ignored = Term.fold_atyps_sorts (fn (_, []) => I | (T, _) => insert (op =) T) rhs [];
   103     val _ =
   103     val _ =
   104       if null ignored then ()
   104       if null ignored then ()
   105       else Context_Position.if_visible ctxt warning
   105       else Context_Position.if_visible ctxt warning
   106         ("Ignoring sort constraints in type variables(s): " ^
   106         ("Ignoring sort constraints in type variables(s): " ^
   108           "\nin type abbreviation " ^ quote (Binding.str_of b));
   108           "\nin type abbreviation " ^ quote (Binding.str_of b));
   109   in rhs end;
   109   in rhs end;
   110 
   110 
   111 in
   111 in
   112 
   112 
   113 val abbrev = gen_abbrev (K ProofContext.cert_typ_syntax);
   113 val abbrev = gen_abbrev (K Proof_Context.cert_typ_syntax);
   114 val abbrev_cmd = gen_abbrev read_abbrev;
   114 val abbrev_cmd = gen_abbrev read_abbrev;
   115 
   115 
   116 end;
   116 end;
   117 
   117 
   118 fun abbrev_global decl rhs =
   118 fun abbrev_global decl rhs =