From ffd190890d4c07c24616325a9d26724306429b22 Mon Sep 17 00:00:00 2001
From: Michael Sippel <micha@fragmental.art>
Date: Sat, 15 Mar 2025 18:22:46 +0100
Subject: [PATCH] improve encode_type_to_symbol to handle complex types

---
 src/main.rs | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index e1262e1..5ddb94e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -96,9 +96,31 @@ struct LdmcPrimCMorphism {
 fn encode_type_to_symbol(dict: &mut impl TypeDict, t: &laddertypes::TypeTerm)-> String {
     match t {
         laddertypes::TypeTerm::Char(c) => {
-            format!("{}", (*c as u64))
+            match c {
+                '.' => format!("_dot_"),
+                _ =>
+                format!("{}", (*c as u64))
+            }
         },
-        t => dict.unparse(t)
+        laddertypes::TypeTerm::Num(n) => {
+            format!("{}", n)
+        }
+        laddertypes::TypeTerm::TypeID(ty_id) => {
+            if let Some(name) = dict.get_typename(ty_id) {
+                format!("{}", name.replace(".", "_dot_"))
+            } else {
+                format!("")
+            }
+        }
+        laddertypes::TypeTerm::Ladder(rs) |
+        laddertypes::TypeTerm::App(rs) => {
+            let mut s = String::new();
+            for r in rs {
+                s.push('_');
+                s.push_str(&encode_type_to_symbol(dict, r));
+            }
+            s
+        }
     }
 }