From 72b2ec224bda76ef937333635033838408e2a43d Mon Sep 17 00:00:00 2001 From: Neemek Date: Thu, 20 Aug 2026 13:50:09 +0200 Subject: [PATCH] add composite simplifaction --- core/types.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/core/types.go b/core/types.go index 6fe7c99..81dafd8 100644 --- a/core/types.go +++ b/core/types.go @@ -487,6 +487,27 @@ func quickComposite(a ...TypeSignature) TypeSignature { return s } +func simplifyComposite(a TypeSignature) TypeSignature { + var atoms []TypeSignature + + s := NewStack[TypeSignature](16) + s.Push(a) + + for s.Current > 0 { + i := s.Pop() + + c, ok := i.(*CompositeSignature) + if !ok { + + atoms = append(atoms, i) + } else { + s.Push(c.A, c.B) + } + } + + return quickComposite(atoms...) +} + type InnerSignature struct{} func (*InnerSignature) Type() Type {