add composite simplifaction

This commit is contained in:
Neemek 2026-08-20 13:50:09 +02:00
parent 7a5203cc26
commit 86760689f1
Signed by: neemek
GPG key ID: 84FFE4D7D40AB25E

View file

@ -487,6 +487,27 @@ func quickComposite(a ...TypeSignature) TypeSignature {
return s 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{} type InnerSignature struct{}
func (*InnerSignature) Type() Type { func (*InnerSignature) Type() Type {