Documentation ¶
Overview ¶
Package values defines data structures for representing (runtime) values in Reflow. Any valid reflow type has representable values (see grail.com/reflow/types) and the structures in this package mirror those in the type system.
Values are represented by values.T, defined as
type T = interface{}
which is done to clarify code that uses reflow values.
Index ¶
- Variables
- func Digest(v T, t *types.T) digest.Digest
- func Equal(v, w T) bool
- func Less(v, w T) bool
- func Sprint(v T, t *types.T) string
- func WriteDigest(w io.Writer, v T, t *types.T)
- type Dir
- type DirScanner
- type Env
- func (e *Env) Bind(id string, v T)
- func (e *Env) Concat(f *Env) *Env
- func (e *Env) Contains(id string) bool
- func (e *Env) Debug()
- func (e *Env) Digest(id string, t *types.T) (d digest.Digest)
- func (e *Env) IsDebug() bool
- func (e *Env) Level(id string) int
- func (e *Env) Push() *Env
- func (e *Env) String() string
- func (e *Env) Value(id string) T
- type Func
- type List
- type Location
- type Map
- type Module
- type MutableDir
- type Struct
- type Symtab
- type T
- type Tuple
- type Variant
Constants ¶
This section is empty.
Variables ¶
var Digester = digest.Digester(crypto.SHA256)
Digester is the digester used to compute value digests.
var Unit = struct{}{}
Unit is the unit value.
Functions ¶
Types ¶
type Dir ¶
type Dir struct {
// contains filtered or unexported fields
}
Dir is an immutable type of directory values. Directory values are opaque and may only be accessed through its methods. This is to ensure proper usage, and that the directory is always accessed in the same order to provide determinism. The zero dir is a valid, empty directory. Dir is immutable.
func ReduceUsingSumDir ¶
ReduceUsingSumDir reduces the given list of dirs into a Dir by successively calling SumDir.
func SumDir ¶
SumDir returns a dir which behaves as the sum of the given dirs. ie, SumDir behaves like a map containing all the key-value mappings that exist in Dirs d and e. If there is a duplicate key in d and e, the value of e will be effective - just as what would happen if we created a new map and added all the mappings from d first and then from e.
func SumDirs ¶
SumDirs returns a dir which behaves as the sum of the given dirs. SumDirs is a generalized version of SumDir.
func (*Dir) DebugString ¶
func (*Dir) Lookup ¶
Lookup returns the entry associated with the provided path and a boolean indicating whether the entry was found.
func (*Dir) Scan ¶
func (d *Dir) Scan() DirScanner
Scan returns a new scanner that traverses the directory in path-sorted order.
for scan := dir.Scan(); scan.Scan(); { fmt.Println(scan.Path(), scan.File()) }
func (*Dir) SortedKeys ¶
SortedKeys returns a list of keys from this dir in sorted order.
type DirScanner ¶
type DirScanner struct {
// contains filtered or unexported fields
}
A DirScanner is a stateful scan of a directory. DirScanners should be instantiated by Dir.Scan.
func (*DirScanner) File ¶
func (s *DirScanner) File() reflow.File
File returns the file of the currently scanned entry.
func (*DirScanner) Path ¶
func (s *DirScanner) Path() string
Path returns the path of the currently scanned entry.
func (*DirScanner) Scan ¶
func (s *DirScanner) Scan() bool
Scan advances the scanner to the next entry (the first entry for a fresh scanner). It returns false when the scan stops with no more entries.
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env binds identifiers to evaluation.
func (*Env) Debug ¶
func (e *Env) Debug()
Debug sets the debug flag on this environment. This causes IsDebug to return true.
func (*Env) Digest ¶
Digest returns the digest for the value with identifier id. The supplied type is used to compute the digest. If the value is a digest.Digest, it is returned directly; if implements the interface
interface{ Digest() digest.Digest }
it returns the result of calling the Digest Method.
Digest also caches the computed digests for an id, and will return the cached value upon subsequent calls.
func (*Env) Level ¶
Level returns the level of identifier id. Level can thus be used as a de-Bruijn index (in conjunction with the identifier).
type Func ¶
type Func interface { // Apply invokes this function with an argument list. // The supplied location may be used by system functions // for debugging and decorating flows. Apply(loc Location, args []T) (T, error) // Digest returns the digest of this function. Digest() digest.Digest }
Func is the type of function value.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map is the type of map values. It uses a Go map as a hash table based on the key's digest, which in turn stores a list of entries that share the same hash bucket.
func (Map) Each ¶
Each enumerates all key-value pairs in map m in deterministic order.
TODO(marius): we really ought to use a representation that's more amenable to such (common) operations.
type MutableDir ¶
type MutableDir struct {
// contains filtered or unexported fields
}
func (*MutableDir) Dir ¶
func (d *MutableDir) Dir() Dir
Dir returns an immutable version of this dir.