package vals

Import Path
	src.elv.sh/pkg/eval/vals (on go.dev)

Dependency Relation
	imports 19 packages, and imported by 10 packages


Package-Level Type Names (total 38, in which 29 are exported)
/* sort exporteds by: | */
Assocer wraps the Assoc method. Assoc returns a slightly modified version of the receiver with key k associated with value v.
Booler wraps the Bool method. Bool computes the truth value of the receiver. reflect.Value
Concatter wraps the Concat method. See Concat for how it is used. Concat concatenates the receiver with another value, the receiver being the left operand. If concatenation is not supported for the given value, the method can return the special error type ErrCatNotImplemented. *src.elv.sh/pkg/ui.Segment src.elv.sh/pkg/ui.Text
Dissocer wraps the Dissoc method. Dissoc returns a slightly modified version of the receiver with key k dissociated with any value.
Equaler wraps the Equal method. Equal compares the receiver to another value. Two equal values must have the same hash code. Pipe *src.elv.sh/pkg/eval.Ns src.elv.sh/pkg/ui.Key
ErrIndexer wraps the Index method. Index retrieves one value from the receiver at the specified index. src.elv.sh/pkg/ui.Text
File is an alias for *os.File. var src.elv.sh/pkg/eval.DevNull var os.Stderr var os.Stdin var os.Stdout
Hasher wraps the Hash method. Hash computes the hash code of the receiver. Pipe *src.elv.sh/pkg/eval.Ns src.elv.sh/pkg/ui.Key
HasKeyer wraps the HasKey method. HasKey returns whether the receiver has the given argument as a valid key.
Indexer wraps the Index method. Index retrieves the value corresponding to the specified key in the container. It returns the value (if any), and whether it actually exists. *src.elv.sh/pkg/eval.Ns src.elv.sh/pkg/persistent/hashmap.Map (interface) *src.elv.sh/pkg/ui.Segment
Iterator wraps the Iterate method. Iterate calls the passed function with each value within the receiver. The iteration is aborted if the function returns false.
KeysIterator wraps the IterateKeys method. IterateKeys calls the passed function with each key within the receiver. The iteration is aborted if the function returns false. *src.elv.sh/pkg/eval.Ns *src.elv.sh/pkg/ui.Segment src.elv.sh/pkg/ui.Text
Kinder wraps the Kind method. ( T) Kind() string Pipe *src.elv.sh/pkg/eval.Ns src.elv.sh/pkg/ui.Key *src.elv.sh/pkg/ui.Segment src.elv.sh/pkg/ui.Text
Lener wraps the Len method. Len computes the length of the receiver. src.elv.sh/pkg/cli/tk.Items (interface) src.elv.sh/pkg/cli/tk.TestItems src.elv.sh/pkg/persistent/hashmap.Map (interface) src.elv.sh/pkg/persistent/list.List (interface) src.elv.sh/pkg/persistent/vector.Vector (interface) src.elv.sh/pkg/ui.Keys *bytes.Buffer *bytes.Reader *container/list.List *internal/fmtsort.SortedMap internal/reflectlite.Value reflect.Type (interface) reflect.Value sort.Float64Slice sort.Interface (interface) sort.IntSlice sort.StringSlice *strings.Builder *strings.Reader
List is an alias for the underlying type used for lists in Elvish.
ListIndex represents a (converted) list index. Lower int Slice bool Upper int func ConvertListIndex(rawIndex interface{}, n int) (*ListIndex, error)
ListReprBuilder helps to build Repr of list-like Values. String returns the representation that has been built. After it is called, the ListReprBuilder may no longer be used. WriteElem writes a new element. *T : Stringer *T : fmt.Stringer func NewListReprBuilder(indent int) *ListReprBuilder
Map is an alias for the underlying type used for maps in Elvish.
MapReprBuilder helps building the Repr of a Map. It is also useful for implementing other Map-like values. The zero value of a MapReprBuilder is ready to use. String returns the representation that has been built. After it is called, the MapReprBuilder should no longer be used. WritePair writes a new pair. *T : Stringer *T : fmt.Stringer func NewMapReprBuilder(indent int) *MapReprBuilder
Num is a stand-in type for int, *big.Int, *big.Rat or float64. This type doesn't offer type safety, but is useful as a marker; for example, it is respected when parsing function arguments. func NormalizeBigInt(z *big.Int) Num func NormalizeBigRat(z *big.Rat) Num func ParseNum(s string) Num func UnifyNums(nums []Num, typ NumType) NumSlice
NumSlice is a stand-in type for []int, []*big.Int, []*big.Rat or []float64. This type doesn't offer type safety, but is useful as a marker. func UnifyNums(nums []Num, typ NumType) NumSlice
NumType represents a number type. func UnifyNums(nums []Num, typ NumType) NumSlice const BigInt const BigRat const Float64 const Int
Pipe wraps a pair of pointers to os.File that are the two ends of the same pipe. ReadEnd *os.File WriteEnd *os.File Equal compares based on the equality of the two consistuent files. Hash calculates the hash based on the two consituent files. Kind returns "pipe". Repr writes an opaque representation containing the FDs of the two constituent files. T : Equaler T : Hasher T : Kinder T : Reprer func NewPipe(r, w *os.File) Pipe
PseudoStructMap may be implemented by a type to derive the Repr, Index, HasKey and IterateKeys operations from the struct map returned by the Fields method. ( T) Fields() StructMap src.elv.sh/pkg/eval.ExternalCmdExit src.elv.sh/pkg/eval.FailError src.elv.sh/pkg/eval.Flow src.elv.sh/pkg/eval.PipelineError
RConcatter wraps the RConcat method. See Concat for how it is used. ( T) RConcat(v interface{}) (interface{}, error) *src.elv.sh/pkg/ui.Segment src.elv.sh/pkg/ui.Text
Reprer wraps the Repr method. Repr returns a string that represents a Value. The string either be a literal of that Value that is preferably deep-equal to it (like `[a b c]` for a list), or a string enclosed in "<>" containing the kind and identity of the Value(like `<fn 0xdeadcafe>`). If indent is at least 0, it should be pretty-printed with the current indentation level of indent; the indent of the first line has already been written and shall not be written in Repr. The returned string should never contain a trailing newline. Pipe *src.elv.sh/pkg/eval.Ns src.elv.sh/pkg/parse.Source src.elv.sh/pkg/ui.Key *src.elv.sh/pkg/ui.Segment src.elv.sh/pkg/ui.Text
Stringer wraps the String method. ( T) String() string *ListReprBuilder *MapReprBuilder src.elv.sh/pkg/edit/complete.ComplexItem src.elv.sh/pkg/edit/complete.PlainItem src.elv.sh/pkg/edit/complete.RawItem (interface) src.elv.sh/pkg/getopt.Config src.elv.sh/pkg/getopt.ContextType src.elv.sh/pkg/getopt.HasArg src.elv.sh/pkg/parse.ExprCtx src.elv.sh/pkg/parse.PrimaryType src.elv.sh/pkg/parse.RedirMode src.elv.sh/pkg/ui.Color (interface) src.elv.sh/pkg/ui.Key *src.elv.sh/pkg/ui.Segment src.elv.sh/pkg/ui.Text *bytes.Buffer crypto.Hash crypto/tls.ClientAuthType crypto/tls.CurveID crypto/tls.SignatureScheme crypto/x509.PublicKeyAlgorithm crypto/x509.SignatureAlgorithm crypto/x509/pkix.Name crypto/x509/pkix.RDNSequence encoding/asn1.ObjectIdentifier encoding/binary.ByteOrder (interface) encoding/json.Delim encoding/json.Number flag.Getter (interface) flag.Value (interface) fmt.Stringer (interface) *go.etcd.io/bbolt.DB go/token.Position go/token.Token internal/reflectlite.Kind internal/reflectlite.Type (interface) io/fs.FileMode math/big.Accuracy *math/big.Float *math/big.Int *math/big.Rat math/big.RoundingMode net.Addr (interface) net.Flags net.HardwareAddr net.IP *net.IPAddr net.IPMask *net.IPNet *net.TCPAddr *net.UDPAddr *net.UnixAddr net/http.ConnState *net/http.Cookie *net/url.URL *net/url.Userinfo *os.ProcessState os.Signal (interface) *os/exec.Cmd os/exec.ExitError reflect.ChanDir reflect.Kind reflect.Type (interface) reflect.Value *regexp.Regexp regexp/syntax.ErrorCode *regexp/syntax.Inst regexp/syntax.InstOp regexp/syntax.Op *regexp/syntax.Prog *regexp/syntax.Regexp *strings.Builder syscall.Signal testing.BenchmarkResult time.Duration *time.Location time.Month time.Time time.Weekday vendor/golang.org/x/net/dns/dnsmessage.Class vendor/golang.org/x/net/dns/dnsmessage.Name vendor/golang.org/x/net/dns/dnsmessage.RCode vendor/golang.org/x/net/dns/dnsmessage.Type vendor/golang.org/x/net/http2/hpack.HeaderField *vendor/golang.org/x/net/idna.Profile *vendor/golang.org/x/text/unicode/bidi.Run T : fmt.Stringer
StructMap may be implemented by a struct to mark the struct as a "struct map", which causes Elvish to treat it like a read-only map. Each exported, named field and getter method (a method taking no argument and returning one value) becomes a field of the map, with the name mapped to dash-case. The following operations are derived for structmaps: Kind, Repr, Hash, Len, Index, HasKey and IterateKeys. Example: type someStruct struct { FooBar int lorem string } func (someStruct) IsStructMap() { } func (s SomeStruct) Ipsum() string { return s.lorem } func (s SomeStruct) OtherMethod(int) { } An instance of someStruct behaves like a read-only map with 3 fields: foo-bar, lorem and ipsum. ( T) IsStructMap() src.elv.sh/pkg/parse.Source func PseudoStructMap.Fields() StructMap func src.elv.sh/pkg/eval.ExternalCmdExit.Fields() StructMap func src.elv.sh/pkg/eval.FailError.Fields() StructMap func src.elv.sh/pkg/eval.Flow.Fields() StructMap func src.elv.sh/pkg/eval.PipelineError.Fields() StructMap
ValueTester is a helper for testing properties of a value. AllKeys tests that the given keys match what the result of IterateKeys on the value. NOTE: This now checks equality using reflect.DeepEqual, since all the builtin types have string keys. This can be changed in future to use Equal is the need arises. Assoc tests that Assoc'ing the value with the given key-value pair returns the wanted new value and no error. AssocError tests that Assoc'ing the value with the given key-value pair returns the given error. Bool tests the Boool of the value. Equal tests that the value is Equal to every of the given values. HasKey tests that the value has each of the given keys. HasNoKey tests that the value does not have any of the given keys. Hash tests the Hash of the value. Index tests that Index'ing the value with the given key returns the wanted value and no error. IndexError tests that Index'ing the value with the given key returns the given error. Kind tests the Kind of the value. Len tests the Len of the value. NotEqual tests that the value is not Equal to any of the given values. Repr tests the Repr of the value. func TestValue(t *testing.T, v interface{}) ValueTester func ValueTester.AllKeys(wantKeys ...interface{}) ValueTester func ValueTester.Assoc(key, val, wantNew interface{}) ValueTester func ValueTester.AssocError(key, val interface{}, wantErr error) ValueTester func ValueTester.Bool(wantBool bool) ValueTester func ValueTester.Equal(others ...interface{}) ValueTester func ValueTester.Hash(wantHash uint32) ValueTester func ValueTester.HasKey(keys ...interface{}) ValueTester func ValueTester.HasNoKey(keys ...interface{}) ValueTester func ValueTester.Index(key, wantVal interface{}) ValueTester func ValueTester.IndexError(key interface{}, wantErr error) ValueTester func ValueTester.Kind(wantKind string) ValueTester func ValueTester.Len(wantLen int) ValueTester func ValueTester.NotEqual(others ...interface{}) ValueTester func ValueTester.Repr(wantRepr string) ValueTester
Package-Level Functions (total 67, in which 34 are exported)
Assoc takes a container, a key and value, and returns a modified version of the container, in which the key associated with the value. It is implemented for the builtin type string, List and Map types, StructMap types, and types satisfying the Assocer interface. For other types, it returns an error.
Bool converts a value to bool. It is implemented for nil, the builtin bool type, and types implementing the Booler interface. For all other values, it returns true.
CanIterate returns whether the value can be iterated. If CanIterate(v) is true, calling Iterate(v, f) will not result in an error.
Collect collects all elements of an iterable value into a slice.
Concat concatenates two values. If both operands are strings, it returns lhs + rhs, nil. If the left operand implements Concatter, it calls lhs.Concat(rhs). If lhs doesn't implement the interface or returned ErrConcatNotImplemented, it then calls rhs.RConcat(lhs). If all attempts fail, it returns nil and an error.
ConvertListIndex parses a list index, check whether it is valid, and returns the converted structure.
Dissoc takes a container and a key, and returns a modified version of the container, with the given key dissociated with any value. It is implemented for the Map type and types satisfying the Dissocer interface. For other types, it returns nil.
Eq returns a tt.Matcher that matches using the Equal function.
Equal returns whether two values are equal. It is implemented for the builtin types bool and string, the File, List, Map types, StructMap types, and types satisfying the Equaler interface. For other types, it uses reflect.DeepEqual to compare the two values.
Feed calls the function with given values, breaking earlier if the function returns false.
FromGo converts a Go value to an Elvish value. Most types are returned as is, but exact numerical types are normalized to one of int, *big.Int and *big.Rat, using the small representation that can hold the value, and runes are converted to strings.
Hash returns the 32-bit hash of a value. It is implemented for the builtin types bool and string, the File, List, Map types, StructMap types, and types satisfying the Hasher interface. For other values, it returns 0 (which is OK in terms of correctness).
HasKey returns whether a container has a key. It is implemented for the Map type, StructMap types, and types satisfying the HasKeyer interface. It falls back to iterating keys using IterateKeys, and if that fails, it falls back to calling Len and checking if key is a valid numeric or slice index. Otherwise it returns false.
Index indexes a value with the given key. It is implemented for the builtin type string, *os.File, List, StructMap and PseudoStructMap types, and types satisfying the ErrIndexer or Indexer interface (the Map type satisfies Indexer). For other types, it returns a nil value and a non-nil error.
Iterate iterates the supplied value, and calls the supplied function in each of its elements. The function can return false to break the iteration. It is implemented for the builtin type string, the List type, and types satisfying the Iterator interface. For these types, it always returns a nil error. For other types, it doesn't do anything and returns an error.
IterateKeys iterates the keys of the supplied value, calling the supplied function for each key. The function can return false to break the iteration. It is implemented for the Map type, StructMap types, and types satisfying the IterateKeyser interface. For these types, it always returns a nil error. For other types, it doesn't do anything and returns an error.
Kind returns the "kind" of the value, a concept similar to type but not yet very well defined. It is implemented for the builtin nil, bool and string, the File, List, Map types, StructMap types, and types satisfying the Kinder interface. For other types, it returns the Go type name of the argument preceded by "!!". TODO: Decide what `kind-of` should report for an external command object and document the rationale for the choice in the doc string for `func (ExternalCmd) Kind()` as well as user facing documentation. It's not obvious why this returns "fn" rather than "external" for that case.
Len returns the length of the value, or -1 if the value does not have a well-defined length. It is implemented for the builtin type string, StructMap types, and types satisfying the Lener interface. For other types, it returns -1.
MakeList creates a new List from values.
MakeMap creates a map from arguments that are alternately keys and values. It panics if the number of arguments is odd.
NewListReprBuilder makes a new ListReprBuilder.
NewMapReprBuilder makes a new MapReprBuilder.
NewPipe creates a new Pipe value.
NormalizeBigInt converts a big.Int to an int if it is within the range of int. Otherwise it returns n as is.
NormalizeBigRat converts a big.Rat to a big.Int (or an int if within the range) if its denominator is 1.
NoSuchKey returns an error indicating that a key is not found in a map-like value.
ParseNum parses a string into a suitable number type. If the string does not represent a valid number, it returns nil.
Repr returns the representation for a value, a string that is preferably (but not necessarily) an Elvish expression that evaluates to the argument. If indent >= 0, the representation is pretty-printed. It is implemented for the builtin types nil, bool and string, the File, List and Map types, StructMap types, and types satisfying the Reprer interface. For other types, it uses fmt.Sprint with the format "<unknown %v>".
ScanToGo converts an Elvish value to a Go value. the pointer points to. It uses the type of the pointer to determine the destination type, and puts the converted value in the location the pointer points to. Conversion only happens when the destination type is int, float64 or rune; in other cases, this function just checks that the source value is already assignable to the destination.
TestValue returns a ValueTester.
ToString converts a Value to string. It is implemented for the builtin float64 and string types, and type satisfying the Stringer interface. It falls back to Repr(v, NoPretty).
TypeOf is like reflect.TypeOf, except that when given an argument of nil, it does not return nil, but the Type for the empty interface.
UnifyNums unifies the given slice of numbers into the same type, converting those with lower NumType to the higest NumType present in the slice. The typ argument can be used to force the minimum NumType.
ValueOf is like reflect.ValueOf, except that when given an argument of nil, it does not return a zero Value, but the Value for the zero value of the empty interface.
Package-Level Variables (total 18, in which 3 are exported)
EmptyList is an empty list.
EmptyMap is an empty map.
ErrConcatNotImplemented is a special error value used to signal that concatenation is not implemented. See Concat for how it is used.
Package-Level Constants (total 5, all are exported)
Possible values for NumType, sorted in the order of implicit conversion (lower types can be implicitly converted to higher types).
Possible values for NumType, sorted in the order of implicit conversion (lower types can be implicitly converted to higher types).
Possible values for NumType, sorted in the order of implicit conversion (lower types can be implicitly converted to higher types).
Possible values for NumType, sorted in the order of implicit conversion (lower types can be implicitly converted to higher types).
NoPretty can be passed to Repr to suppress pretty-printing.