25 lines
621 B
Go
25 lines
621 B
Go
package registry
|
|
|
|
// A Repr is a lambda calculus expression. It can have any type of
|
|
// representation, so long as that class is known to the registry it is handled
|
|
// by.
|
|
type Repr interface {
|
|
// ID returns the name of the underlying representation. It is assumed that
|
|
// if two expressions have the same Id(), they have the same representation.
|
|
ID() string
|
|
|
|
// The base expression data.
|
|
Data() any
|
|
}
|
|
|
|
type baseRepr struct {
|
|
id string
|
|
data any
|
|
}
|
|
|
|
func (r baseRepr) ID() string { return r.id }
|
|
|
|
func (r baseRepr) Data() any { return r.data }
|
|
|
|
func NewRepr(id string, data any) Repr { return baseRepr{id, data} }
|