let rec expanded_string_of_enum ename env =
  let nfields = get_nvalues_enum ename env in
    concat [ename;" : ";string_of_int nfields]

(** Gives an expanded string representation of the given struct type which includes the expanded representation of each of its fields *)

and expanded_string_of_struct sname env = 
  let struct_dts = get_second (getfields_struct sname env) in
  let helper x = x env in
  let string_list = List.map helper (List.map expanded_string_of_type struct_dts) in
    concat [sname;" : ";concat_commas string_list]
    
(** Gives a string representation of the given type with expanded represnetations of structs and enums *)

and expanded_string_of_type ty env = match ty with
    TyInt -> "int"
  | TyFloat -> "float"
  | TyString -> "string"
  | TyBool -> "bool"
  | TyVoid -> "void"
  | TyList t_list -> concat ["list(";expanded_string_of_type t_list env;")"]
  | TyEnumType s -> concat ["enumType(";expanded_string_of_enum s env;")"]
  | TyEnum s -> concat ["enum(";expanded_string_of_enum s env;")"]
  | TyStruct s -> concat ["struct(";expanded_string_of_struct s env;")"]
  | TyArray (t_arr) -> concat["array(";expanded_string_of_type t_arr env;")"]
  | TyArrow (t_args,t_ret) -> 
      let helper x = x env in
      let arg_string = List.map helper (List.map expanded_string_of_type t_args) in
      let arg_string = if arg_string = []  then ["void"else arg_string in
      String.concat " "
        (["function("]@arg_string@["->";expanded_string_of_type t_ret env;")"])
  | TyRef t_ref -> concat ["ref(";expanded_string_of_type t_ref env;")"]
  | TyTemplate s -> if s = "_unknown" then "_" else concat ["templated(";s;")"]