src/HOLCF/Tools/domain/domain_extender.ML
changeset 30345 76fd85bbf139
parent 30280 eb98b49ef835
child 30364 577edc39b501
equal deleted inserted replaced
30344:10a67c5ddddb 30345:76fd85bbf139
   101   let
   101   let
   102     val dtnvs = map ((fn (dname,vs) => 
   102     val dtnvs = map ((fn (dname,vs) => 
   103 			 (Sign.full_bname thy''' dname, map (Syntax.read_typ_global thy''') vs))
   103 			 (Sign.full_bname thy''' dname, map (Syntax.read_typ_global thy''') vs))
   104                    o fst) eqs''';
   104                    o fst) eqs''';
   105     val cons''' = map snd eqs''';
   105     val cons''' = map snd eqs''';
   106     fun thy_type  (dname,tvars)  = (NameSpace.base_name dname, length tvars, NoSyn);
   106     fun thy_type  (dname,tvars)  = (Binding.name (NameSpace.base_name dname), length tvars, NoSyn);
   107     fun thy_arity (dname,tvars)  = (dname, map (snd o dest_TFree) tvars, pcpoS);
   107     fun thy_arity (dname,tvars)  = (dname, map (snd o dest_TFree) tvars, pcpoS);
   108     val thy'' = thy''' |> Sign.add_types     (map thy_type  dtnvs)
   108     val thy'' = thy''' |> Sign.add_types     (map thy_type  dtnvs)
   109 		       |> fold (AxClass.axiomatize_arity o thy_arity) dtnvs;
   109 		       |> fold (AxClass.axiomatize_arity o thy_arity) dtnvs;
   110     val cons'' = map (map (upd_third (map (upd_third (prep_typ thy''))))) cons''';
   110     val cons'' = map (map (upd_third (map (upd_third (prep_typ thy''))))) cons''';
   111     val eqs' = check_and_sort_domain (dtnvs,cons'') thy'';
   111     val eqs' = check_and_sort_domain (dtnvs,cons'') thy'';
   117           let val c = hd (Symbol.explode (NameSpace.base_name id))
   117           let val c = hd (Symbol.explode (NameSpace.base_name id))
   118           in if Symbol.is_letter c then c else "t" end
   118           in if Symbol.is_letter c then c else "t" end
   119       | typid (TFree (id,_)   ) = hd (strip (tl (Symbol.explode id)))
   119       | typid (TFree (id,_)   ) = hd (strip (tl (Symbol.explode id)))
   120       | typid (TVar ((id,_),_)) = hd (tl (Symbol.explode id));
   120       | typid (TVar ((id,_),_)) = hd (tl (Symbol.explode id));
   121     fun one_con (con,mx,args) =
   121     fun one_con (con,mx,args) =
   122 	((Syntax.const_name con mx),
   122 	((Syntax.const_name mx con),
   123 	 ListPair.map (fn ((lazy,sel,tp),vn) => ((lazy,
   123 	 ListPair.map (fn ((lazy,sel,tp),vn) => ((lazy,
   124 					find_index_eq tp dts,
   124 					find_index_eq tp dts,
   125 					DatatypeAux.dtyp_of_typ new_dts tp),
   125 					DatatypeAux.dtyp_of_typ new_dts tp),
   126 					sel,vn))
   126 					sel,vn))
   127 	     (args,(mk_var_names(map (typid o third) args)))
   127 	     (args,(mk_var_names(map (typid o third) args)))