From fe73c47504c63bd7db9dc3a50f3595600a00e6bb Mon Sep 17 00:00:00 2001
From: Michael Sippel <micha@fragmental.art>
Date: Fri, 14 Mar 2025 17:44:27 +0100
Subject: [PATCH] find_morphism_path(): param-normalize halo

---
 src/morphism.rs      | 10 ++++----
 src/test/morphism.rs | 59 ++++++++------------------------------------
 2 files changed, 15 insertions(+), 54 deletions(-)

diff --git a/src/morphism.rs b/src/morphism.rs
index 7b2ac5e..9f29ba8 100644
--- a/src/morphism.rs
+++ b/src/morphism.rs
@@ -21,8 +21,8 @@ pub struct MorphismType {
 impl MorphismType {
     pub fn normalize(self) -> Self {
         MorphismType {
-            src_type: self.src_type.normalize().param_normalize(),
-            dst_type: self.dst_type.normalize().param_normalize(),
+            src_type: self.src_type.strip().param_normalize(),
+            dst_type: self.dst_type.strip().param_normalize(),
 /*
             subtype_bounds: Vec::new(),
             trait_bounds: Vec::new()
@@ -149,7 +149,7 @@ impl<M: Morphism + Clone> MorphismBase<M> {
                     if let Some( map_morph ) = item_morph_inst.m.map_morphism( seq_type.clone() ) {
                         dst_types.push(
                             MorphismInstance {
-                                halo: TypeTerm::Ladder(dst_halo_ladder).normalize(),
+                                halo: TypeTerm::Ladder(dst_halo_ladder).strip().param_normalize(),
                                 m: map_morph,
                                 σ: item_morph_inst.σ
                             }
@@ -221,7 +221,7 @@ impl<M: Morphism + Clone> MorphismBase<M> {
 
                         n.halo = n.halo.clone().apply_substitution(
                             &|k| σ.get(k).cloned()
-                        ).clone().strip();
+                        ).clone().strip().param_normalize();
 
                         n.σ = new_σ;
                     }
@@ -256,7 +256,7 @@ impl<M: Morphism + Clone> MorphismBase<M> {
 
                         n.halo = n.halo.clone().apply_substitution(
                             &|k| next_morph_inst.σ.get(k).cloned()
-                        ).clone().strip();
+                        ).clone().strip().param_normalize();
 
                         n.σ = new_σ;
                     }
diff --git a/src/test/morphism.rs b/src/test/morphism.rs
index fc0419a..e6db4a3 100644
--- a/src/test/morphism.rs
+++ b/src/test/morphism.rs
@@ -330,51 +330,6 @@ fn test_morphism_path_posint() {
             ]
         )
     );
-
-
-
-/*
-    assert_eq!(
-        base.find_morphism_path(MorphismType {
-            src_type: dict.parse("Symbol ~ ℕ ~ <PosInt 10 BigEndian> ~ <Seq <Digit 10> ~ Char>").unwrap(),
-            dst_type: dict.parse("Symbol ~ ℕ ~ <PosInt 16 BigEndian> ~ <Seq <Digit 16> ~ Char>").unwrap()
-        }),
-        Some(
-            vec![
-                dict.parse("Symbol ~ ℕ ~ <PosInt 10 BigEndian> ~ <Seq <Digit 10> ~ Char>").unwrap().normalize(),
-                dict.parse("Symbol ~ ℕ ~ <PosInt 10 BigEndian> ~ <Seq <Digit 10> ~ ℤ_2^64 ~ machine.UInt64>").unwrap().normalize(),
-                dict.parse("Symbol ~ ℕ ~ <PosInt 10 LittleEndian> ~ <Seq <Digit 10> ~ ℤ_2^64 ~ machine.UInt64>").unwrap().normalize(),
-                dict.parse("Symbol ~ ℕ ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16> ~ ℤ_2^64 ~ machine.UInt64>").unwrap().normalize(),
-                dict.parse("Symbol ~ ℕ ~ <PosInt 16 BigEndian> ~ <Seq <Digit 16> ~ ℤ_2^64 ~ machine.UInt64>").unwrap().normalize(),
-                dict.parse("Symbol ~ ℕ ~ <PosInt 16 BigEndian> ~ <Seq <Digit 16> ~ Char>").unwrap().normalize(),
-            ]
-        )
-    );
-    */
-/*
-    assert_eq!(
-        base.find_morphism_with_subtyping(
-            &MorphismType {
-                src_type: dict.parse("Symbol ~ ℕ ~ <PosInt 10 BigEndian> ~ <Seq <Digit 10> ~ Char>").unwrap(),
-                dst_type: dict.parse("Symbol ~ ℕ ~ <PosInt 10 BigEndian> ~ <Seq <Digit 10> ~ ℤ_2^64 ~ machine.UInt64>").unwrap()
-            }
-        ),
-
-        Some((
-                DummyMorphism(MorphismType{
-                    src_type: dict.parse("<Seq <Digit Radix> ~ Char>").unwrap(),
-                    dst_type: dict.parse("<Seq <Digit Radix> ~ ℤ_2^64 ~ machine.UInt64>").unwrap()
-                }),
-
-                dict.parse("Symbol ~ ℕ ~ <PosInt 10 BigEndian> ~ <Seq <Digit 10>>").unwrap(),
-
-                vec![
-                    (dict.get_typeid(&"Radix".into()).unwrap(),
-                    dict.parse("10").unwrap())
-                ].into_iter().collect::<std::collections::HashMap<TypeID, TypeTerm>>()
-        ))
-    );
-*/
 }
 
 #[test]
@@ -421,14 +376,20 @@ fn test_morphism_path_listedit()
     );
     base.add_morphism(
         DummyMorphism(MorphismType{
-            src_type: dict.parse("<List~Vec Char>").unwrap(),
-            dst_type: dict.parse("<List Char>").unwrap()
+            src_type: dict.parse("Char").unwrap(),
+            dst_type: dict.parse("Char ~ ReprTree").unwrap()
         })
     );
     base.add_morphism(
         DummyMorphism(MorphismType{
-            src_type: dict.parse("<List Char>").unwrap(),
-            dst_type: dict.parse("<List Char~ReprTree>").unwrap()
+            src_type: dict.parse("Char ~ ReprTree").unwrap(),
+            dst_type: dict.parse("Char").unwrap()
+        })
+    );
+    base.add_morphism(
+        DummyMorphism(MorphismType{
+            src_type: dict.parse("<List~Vec Char>").unwrap(),
+            dst_type: dict.parse("<List Char>").unwrap()
         })
     );
     base.add_morphism(