package rep import ( "git.sr.ht/~cco/go-scopes/common/funky" "git.sr.ht/~cco/go-scopes/forge" ) // maybe: code, defs, string, int, float type citem interface{} // code, represented by a slice type code []citem func Code(items ...citem) code { return code(items) } func (ci code) Compile(f forge.FE) forge.FPtr { c := f.Code() for _, item := range ci { switch i := item.(type) { case int: c.Append(i) case string: m := compStr(f, i) if !m.IsNothing() { c.Append(m.Value()) } } } return c.Reset() } func compStr(f forge.FE, s string) funky.Maybe[forge.FItem] { mxt := f.Voc().Lookup(s) if mxt.IsNothing() { return funky.Nothing[forge.FItem]() } return funky.Just(forge.FItem(mxt.Value())) } // defs - definitions, represented by a map type defs map[string]citem