New function name_of_typ.
authorberghofe
Wed, 30 Aug 2000 13:55:26 +0200
changeset 9740 1c5b0f27de56
parent 9739 8470c4662685
child 9741 0502f06c2d29
New function name_of_typ.
src/HOL/Tools/datatype_aux.ML
--- a/src/HOL/Tools/datatype_aux.ML	Wed Aug 30 13:54:57 2000 +0200
+++ b/src/HOL/Tools/datatype_aux.ML	Wed Aug 30 13:55:26 2000 +0200
@@ -40,6 +40,7 @@
   type datatype_info
 
   exception Datatype
+  val name_of_typ : typ -> string
   val dtyp_of_typ : (string * string list) list -> typ -> dtyp
   val mk_Free : string -> typ -> int -> term
   val is_rec_type : dtyp -> bool
@@ -198,6 +199,10 @@
 
 fun dest_TFree (TFree (n, _)) = n;
 
+fun name_of_typ (Type (s, Ts)) = space_implode "_"
+      (filter (not o equal "") (map name_of_typ Ts) @ [Sign.base_name s])
+  | name_of_typ _ = "";
+
 fun dtyp_of_typ _ (TFree (n, _)) = DtTFree n
   | dtyp_of_typ _ (TVar _) = error "Illegal schematic type variable(s)"
   | dtyp_of_typ new_dts (Type (tname, Ts)) =