func (s Some) MarshalCBOR() ([]byte, error) {
	return em.Marshal([]interface{}{5, nil, s.Val})
}
MarshalCBOR implements cbor.Marshaler.
package term
import (
	"bytes"
	"fmt"
	"sort"
	"github.com/fxamacker/cbor/v2"
)
func encMode() cbor.EncMode {
	em, err := cbor.CanonicalEncOptions().EncMode()
	if err != nil {
		panic(err)
	}
	return em
}
var em = encMode()
func (u Universe) MarshalCBOR() ([]byte, error) {
	switch u {
	case Type:
		return cbor.Marshal("Type")
	case Kind:
		return cbor.Marshal("Kind")
	case Sort:
		return cbor.Marshal("Sort")
	}
	return nil, fmt.Errorf("Invalid Universe value %d", u)
}
func (v Var) MarshalCBOR() ([]byte, error) {
	if v.Name == "_" {
		return cbor.Marshal(v.Index)
	}
	return cbor.Marshal([]interface{}{v.Name, v.Index})
}
func (app App) MarshalCBOR() ([]byte, error) {
	fn := app.Fn
	args := []interface{}{app.Arg}
	for true {
		childapp, ok := fn.(App)
		if !ok {
			break
		}
		fn = childapp.Fn
		args = append([]interface{}{childapp.Arg}, args...)
	}
	return em.Marshal(append([]interface{}{0, fn}, args...))
}
func (l Lambda) MarshalCBOR() ([]byte, error) {
	if l.Label == "_" {
		return em.Marshal([]interface{}{1, l.Type, l.Body})
	}
	return em.Marshal([]interface{}{1, l.Label, l.Type, l.Body})
}
func (p Pi) MarshalCBOR() ([]byte, error) {
	if p.Label == "_" {
		return em.Marshal([]interface{}{2, p.Type, p.Body})
	}
	return em.Marshal([]interface{}{2, p.Label, p.Type, p.Body})
}
func (op Op) MarshalCBOR() ([]byte, error) {
	return em.Marshal([]interface{}{3, op.OpCode, op.L, op.R})
}
func (l EmptyList) MarshalCBOR() ([]byte, error) {
	if app, ok := l.Type.(App); ok {
		if app.Fn == List {
			return em.Marshal([]interface{}{4, app.Arg})
		}
	}
	return em.Marshal([]interface{}{28, l.Type})
}
func (l NonEmptyList) MarshalCBOR() ([]byte, error) {
	output := make([]interface{}, len(l)+2)
	output[0] = 4
	output[1] = nil
	for i, item := range l {
		output[i+2] = item
	}
	return em.Marshal(output)
}