src/Pure/Isar/class.ML
changeset 24701 f8bfd592a6dc
parent 24657 185502d54c3d
child 24707 dfeb98f84e93
equal deleted inserted replaced
24700:291665d063e4 24701:f8bfd592a6dc
   214 
   214 
   215 fun add_def ((class, tyco), ((name, prop), atts)) thy =
   215 fun add_def ((class, tyco), ((name, prop), atts)) thy =
   216   let
   216   let
   217     val ((lhs as Const (c, ty), args), rhs) =
   217     val ((lhs as Const (c, ty), args), rhs) =
   218       (apfst Term.strip_comb o Logic.dest_equals) prop;
   218       (apfst Term.strip_comb o Logic.dest_equals) prop;
   219     fun add_inst' def ([], (Const (c_inst, ty))) =
   219     fun (*add_inst' def ([], (Const (c_inst, ty))) =
   220           if forall (fn TFree _ => true | _ => false) (Sign.const_typargs thy (c_inst, ty))
   220           if forall (fn TFree _ => true | _ => false) (Sign.const_typargs thy (c_inst, ty))
   221           then add_inst (c, tyco) (c_inst, def)
   221           then add_inst (c, tyco) (c_inst, def)
   222           else add_inst_def (class, tyco) (c, ty)
   222           else add_inst_def (class, tyco) (c, ty)
   223       | add_inst' _ t = add_inst_def (class, tyco) (c, ty);
   223       |*) add_inst' _ t = add_inst_def (class, tyco) (c, ty);
   224   in
   224   in
   225     thy
   225     thy
   226     |> PureThy.add_defs_i true [((name, prop), map (Attrib.attribute thy) atts)]
   226     |> PureThy.add_defs_i true [((name, prop), map (Attrib.attribute thy) atts)]
   227     |-> (fn [def] => add_inst' def (args, rhs) #> pair def)
   227     |-> (fn [def] => add_inst' def (args, rhs) #> pair def)
   228   end;
   228   end;