Documentation ¶
Index ¶
- Constants
- Variables
- func BindConst(a, b Value) error
- func CacheThunkPath(ctx context.Context, tp ThunkPath) (string, error)
- func DecodeProto(ctx context.Context, name Symbol, sink PipeSink, r io.Reader) error
- func Details(val Value) string
- func Dump(dst io.Writer, val interface{})
- func Each(list List, cb func(Value) error) error
- func EachBindingList(binding List, cb func(Symbol, Range) error) error
- func IsApplicative(val Value) bool
- func IsList(val Value) bool
- func IsOperative(val Value) bool
- func Logger() *zap.Logger
- func LoggerTo(w io.Writer) *zap.Logger
- func MarshalJSON(val interface{}) ([]byte, error)
- func NewDecoder(r io.Reader) *json.Decoder
- func NewEncoder(w io.Writer) *json.Encoder
- func PrintBindingDocs(ctx context.Context, scope *Scope, form, val Value)
- func RunMain(ctx context.Context, scope *Scope, args ...Value) error
- func UnmarshalJSON(payload []byte, dest interface{}) error
- func WithRuntimePool(ctx context.Context, pool RuntimePool) context.Context
- func WithTrace(ctx context.Context, trace *Trace) context.Context
- func WriteError(ctx context.Context, err error)
- type Annotate
- type AnnotateBinding
- type Annotated
- type Applicative
- type ArityError
- type Bind
- type BindMismatchError
- type Bindable
- type Bindings
- type Bool
- func (binding Bool) Bind(_ context.Context, _ *Scope, cont Cont, val Value, _ ...Annotated) ReadyCont
- func (value Bool) Decode(dest interface{}) error
- func (Bool) EachBinding(func(Symbol, Range) error) error
- func (value Bool) Equal(other Value) bool
- func (value Bool) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (value Bool) String() string
- type Builtin
- func (builtin Builtin) Call(ctx context.Context, val Value, scope *Scope, cont Cont) ReadyCont
- func (value *Builtin) Decode(dest interface{}) error
- func (value *Builtin) Equal(other Value) bool
- func (value *Builtin) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (value *Builtin) MarshalJSON() ([]byte, error)
- func (value *Builtin) String() string
- type CannotBindError
- type Combiner
- type CommandPath
- func (binding CommandPath) Bind(_ context.Context, _ *Scope, cont Cont, val Value, _ ...Annotated) ReadyCont
- func (combiner CommandPath) Call(ctx context.Context, val Value, scope *Scope, cont Cont) ReadyCont
- func (value CommandPath) Decode(dest interface{}) error
- func (CommandPath) EachBinding(func(Symbol, Range) error) error
- func (value CommandPath) Equal(other Value) bool
- func (value CommandPath) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (path CommandPath) Extend(ext Path) (Path, error)
- func (value *CommandPath) FromValue(val Value) error
- func (value CommandPath) Name() string
- func (value CommandPath) String() string
- func (app CommandPath) Unwrap() Combiner
- type CompleteOpt
- type CompleteOpts
- type Config
- type Cons
- func (binding Cons) Bind(ctx context.Context, scope *Scope, cont Cont, value Value, _ ...Annotated) ReadyCont
- func (value Cons) Decode(dest interface{}) error
- func (binding Cons) EachBinding(cb func(Symbol, Range) error) error
- func (value Cons) Equal(other Value) bool
- func (value Cons) Eval(ctx context.Context, scope *Scope, cont Cont) ReadyCont
- func (value Cons) First() Value
- func (value Cons) MarshalJSON() ([]byte, error)
- func (value Cons) Rest() Value
- func (value Cons) String() string
- type Cont
- type Continuation
- func (cont *Continuation) Call(res Value, err error) ReadyCont
- func (value *Continuation) Decode(dest interface{}) error
- func (value *Continuation) Equal(other Value) bool
- func (value *Continuation) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (value *Continuation) MarshalJSON() ([]byte, error)
- func (value *Continuation) String() string
- func (value *Continuation) Traced(trace *Trace) Cont
- type Data
- type Decodable
- type DecodeError
- type DirPath
- func (binding DirPath) Bind(_ context.Context, _ *Scope, cont Cont, val Value, _ ...Annotated) ReadyCont
- func (combiner DirPath) Call(ctx context.Context, val Value, scope *Scope, cont Cont) ReadyCont
- func (value DirPath) Decode(dest interface{}) error
- func (value DirPath) Dir() DirPath
- func (DirPath) EachBinding(func(Symbol, Range) error) error
- func (value DirPath) Equal(other Value) bool
- func (value DirPath) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (dir DirPath) Extend(ext Path) (Path, error)
- func (value DirPath) FromSlash() string
- func (value *DirPath) FromValue(val Value) error
- func (value DirPath) IsDir() bool
- func (value DirPath) Name() string
- func (value DirPath) String() string
- func (combiner DirPath) Unwrap() Combiner
- type Empty
- func (binding Empty) Bind(_ context.Context, _ *Scope, cont Cont, val Value, _ ...Annotated) ReadyCont
- func (value Empty) Decode(dest interface{}) error
- func (Empty) EachBinding(func(Symbol, Range) error) error
- func (Empty) Equal(other Value) bool
- func (value Empty) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (Empty) First() Value
- func (Empty) MarshalJSON() ([]byte, error)
- func (Empty) Rest() Value
- func (Empty) String() string
- func (*Empty) UnmarshalJSON(payload []byte) error
- type Encodable
- type EncodeError
- type ExtendError
- type ExtendOperative
- func (op ExtendOperative) Call(_ context.Context, val Value, _ *Scope, cont Cont) ReadyCont
- func (value ExtendOperative) Decode(dest interface{}) error
- func (value ExtendOperative) Equal(other Value) bool
- func (value ExtendOperative) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (value ExtendOperative) String() string
- type ExtendPath
- func (binding ExtendPath) Bind(ctx context.Context, scope *Scope, cont Cont, val Value, _ ...Annotated) ReadyCont
- func (value ExtendPath) Decode(dest interface{}) error
- func (ExtendPath) EachBinding(func(Symbol, Range) error) error
- func (value ExtendPath) Equal(other Value) bool
- func (value ExtendPath) Eval(ctx context.Context, scope *Scope, cont Cont) ReadyCont
- func (value ExtendPath) String() string
- type FSPath
- func (combiner FSPath) Call(ctx context.Context, val Value, scope *Scope, cont Cont) ReadyCont
- func (value FSPath) Decode(dest interface{}) error
- func (value FSPath) Equal(other Value) bool
- func (value FSPath) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (path FSPath) Extend(ext Path) (Path, error)
- func (path FSPath) Name() string
- func (value FSPath) String() string
- func (app FSPath) Unwrap() Combiner
- type FileOrDirPath
- func (path FileOrDirPath) Extend(ext Path) (FileOrDirPath, error)
- func (path FileOrDirPath) FilesystemPath() FilesystemPath
- func (path *FileOrDirPath) FromValue(val Value) error
- func (path FileOrDirPath) MarshalJSON() ([]byte, error)
- func (path FileOrDirPath) String() string
- func (path FileOrDirPath) ToValue() Value
- func (path *FileOrDirPath) UnmarshalJSON(payload []byte) error
- type FilePath
- func (binding FilePath) Bind(_ context.Context, _ *Scope, cont Cont, val Value, _ ...Annotated) ReadyCont
- func (combiner FilePath) Call(ctx context.Context, val Value, scope *Scope, cont Cont) ReadyCont
- func (value FilePath) Decode(dest interface{}) error
- func (value FilePath) Dir() DirPath
- func (FilePath) EachBinding(func(Symbol, Range) error) error
- func (value FilePath) Equal(other Value) bool
- func (value FilePath) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (path_ FilePath) Extend(ext Path) (Path, error)
- func (app FilePath) FileOrDir() FileOrDirPath
- func (value FilePath) FromSlash() string
- func (value *FilePath) FromValue(val Value) error
- func (value FilePath) IsDir() bool
- func (value FilePath) Name() string
- func (value FilePath) String() string
- func (app FilePath) Unwrap() Combiner
- type FilesystemPath
- type FormAnalyzer
- type HostPath
- func (combiner HostPath) Call(ctx context.Context, val Value, scope *Scope, cont Cont) ReadyCont
- func (value HostPath) Decode(dest interface{}) error
- func (value HostPath) Equal(other Value) bool
- func (value HostPath) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (path HostPath) Extend(ext Path) (Path, error)
- func (hp HostPath) FromSlash() string
- func (value *HostPath) FromValue(val Value) error
- func (path HostPath) Name() string
- func (value HostPath) String() string
- func (app HostPath) Unwrap() Combiner
- type Ignore
- func (Ignore) Bind(_ context.Context, _ *Scope, cont Cont, _ Value, _ ...Annotated) ReadyCont
- func (value Ignore) Decode(dest interface{}) error
- func (Ignore) EachBinding(func(Symbol, Range) error) error
- func (Ignore) Equal(other Value) bool
- func (value Ignore) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (Ignore) String() string
- type InMemoryFS
- type InMemorySink
- type InMemorySource
- type Int
- func (binding Int) Bind(_ context.Context, _ *Scope, cont Cont, val Value, _ ...Annotated) ReadyCont
- func (value Int) Decode(dest interface{}) error
- func (Int) EachBinding(func(Symbol, Range) error) error
- func (value Int) Equal(other Value) bool
- func (value Int) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (value Int) String() string
- type JSONProtocol
- type JSONSink
- type JSONSource
- type Keyword
- func (binding Keyword) Bind(_ context.Context, _ *Scope, cont Cont, val Value, _ ...Annotated) ReadyCont
- func (value Keyword) Decode(dest interface{}) error
- func (Keyword) EachBinding(func(Symbol, Range) error) error
- func (value Keyword) Equal(other Value) bool
- func (value Keyword) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (value Keyword) String() string
- func (value Keyword) Symbol() Symbol
- type List
- type Lockfile
- type LockfileContent
- type Memory
- type Memos
- type NiceError
- type NoopMemos
- type Null
- func (binding Null) Bind(_ context.Context, _ *Scope, cont Cont, val Value, _ ...Annotated) ReadyCont
- func (value Null) Decode(dest interface{}) error
- func (Null) EachBinding(func(Symbol, Range) error) error
- func (Null) Equal(other Value) bool
- func (value Null) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (Null) MarshalJSON() ([]byte, error)
- func (Null) String() string
- type Operative
- func (combiner *Operative) Call(ctx context.Context, val Value, scope *Scope, cont Cont) ReadyCont
- func (value *Operative) Decode(dest interface{}) error
- func (value *Operative) Equal(other Value) bool
- func (value *Operative) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (value *Operative) MarshalJSON() ([]byte, error)
- func (value *Operative) String() string
- type Pair
- func (binding Pair) Bind(ctx context.Context, scope *Scope, cont Cont, value Value, _ ...Annotated) ReadyCont
- func (value Pair) Decode(dest interface{}) error
- func (binding Pair) EachBinding(cb func(Symbol, Range) error) error
- func (value Pair) Equal(other Value) bool
- func (value Pair) Eval(ctx context.Context, scope *Scope, cont Cont) ReadyCont
- func (value Pair) First() Value
- func (value Pair) MarshalJSON() ([]byte, error)
- func (value Pair) Rest() Value
- func (value Pair) String() string
- func (value *Pair) UnmarshalJSON(payload []byte) error
- type Path
- type PipeSink
- type PipeSource
- type Platform
- type Protocol
- type PruneOpts
- type Range
- type RawProtocol
- type ReadError
- type Readable
- type Reader
- type ReadonlyMemos
- type ReadyCont
- type ReadyContinuation
- func (value *ReadyContinuation) Decode(dest interface{}) error
- func (value *ReadyContinuation) Equal(other Value) bool
- func (value *ReadyContinuation) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (cont *ReadyContinuation) Go() (Value, error)
- func (value *ReadyContinuation) MarshalJSON() ([]byte, error)
- func (cont *ReadyContinuation) String() string
- type Runtime
- type RuntimeConfig
- type RuntimePool
- type Scope
- func (scope *Scope) Complete(prefix string) []CompleteOpt
- func (value *Scope) Copy() *Scope
- func (value *Scope) Decode(dest interface{}) error
- func (value *Scope) Each(f func(Symbol, Value) error) error
- func (value *Scope) Equal(o Value) bool
- func (value *Scope) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (scope *Scope) Get(binding Symbol) (Value, bool)
- func (scope *Scope) GetDecode(binding Symbol, dest interface{}) error
- func (value *Scope) IsEmpty() bool
- func (value *Scope) IsSubsetOf(other *Scope) bool
- func (value *Scope) MarshalJSON() ([]byte, error)
- func (scope *Scope) Set(binding Symbol, value Value, docs ...string)
- func (value *Scope) String() string
- func (value *Scope) UnmarshalJSON(payload []byte) error
- type Secret
- type Sink
- type Source
- type String
- func (binding String) Bind(_ context.Context, _ *Scope, cont Cont, val Value, _ ...Annotated) ReadyCont
- func (value String) Decode(dest interface{}) error
- func (String) EachBinding(func(Symbol, Range) error) error
- func (value String) Equal(other Value) bool
- func (value String) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (value String) String() string
- type Symbol
- func (binding Symbol) Bind(ctx context.Context, scope *Scope, cont Cont, val Value, doc ...Annotated) ReadyCont
- func (combiner Symbol) Call(ctx context.Context, val Value, scope *Scope, cont Cont) ReadyCont
- func (value Symbol) Decode(dest interface{}) error
- func (binding Symbol) EachBinding(cb func(Symbol, Range) error) error
- func (value Symbol) Equal(other Value) bool
- func (value Symbol) Eval(_ context.Context, scope *Scope, cont Cont) ReadyCont
- func (value Symbol) JSONKey() string
- func (value Symbol) Keyword() Keyword
- func (value Symbol) String() string
- func (app Symbol) Unwrap() Combiner
- type SymbolOperative
- func (op SymbolOperative) Call(_ context.Context, val Value, _ *Scope, cont Cont) ReadyCont
- func (value SymbolOperative) Decode(dest interface{}) error
- func (value SymbolOperative) Equal(other Value) bool
- func (value SymbolOperative) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (value SymbolOperative) String() string
- type Thunk
- func (wl Thunk) Avatar() (*invaders.Invader, error)
- func (combiner Thunk) Call(ctx context.Context, val Value, scope *Scope, cont Cont) ReadyCont
- func (thunk Thunk) Cmdline() string
- func (thunk Thunk) Decode(dest interface{}) error
- func (thunk Thunk) Equal(other Value) bool
- func (value Thunk) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (thunk Thunk) Extend(sub Path) (Path, error)
- func (value *Thunk) FromValue(val Value) error
- func (thunk Thunk) Name() string
- func (thunk Thunk) Open(ctx context.Context) (io.ReadCloser, error)
- func (thunk *Thunk) Platform() *Platform
- func (wl Thunk) SHA1() (string, error)
- func (wl Thunk) SHA256() (string, error)
- func (thunk Thunk) String() string
- func (thunk *Thunk) UnmarshalJSON(b []byte) error
- func (combiner Thunk) Unwrap() Combiner
- func (thunk Thunk) WithArgs(args []Value) Thunk
- func (thunk Thunk) WithDir(dir ThunkDir) Thunk
- func (thunk Thunk) WithEnv(env *Scope) Thunk
- func (thunk Thunk) WithImage(image ThunkImage) Thunk
- func (thunk Thunk) WithInsecure(insecure bool) Thunk
- func (thunk Thunk) WithLabel(key Symbol, val Value) Thunk
- func (thunk Thunk) WithMount(src ThunkMountSource, tgt FileOrDirPath) Thunk
- func (thunk Thunk) WithStdin(stdin []Value) Thunk
- func (thunk Thunk) Wrap(cmd ThunkCmd, prependArgs ...Value) Thunk
- type ThunkCmd
- type ThunkDir
- type ThunkImage
- type ThunkImageRef
- type ThunkMount
- type ThunkMountSource
- type ThunkOperative
- func (op ThunkOperative) Call(_ context.Context, args Value, _ *Scope, cont Cont) ReadyCont
- func (value ThunkOperative) Decode(dest interface{}) error
- func (value ThunkOperative) Equal(other Value) bool
- func (value ThunkOperative) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (value ThunkOperative) String() string
- type ThunkPath
- func (combiner ThunkPath) Call(ctx context.Context, val Value, scope *Scope, cont Cont) ReadyCont
- func (value ThunkPath) Decode(dest interface{}) error
- func (path ThunkPath) Dir() ThunkPath
- func (value ThunkPath) Equal(other Value) bool
- func (value ThunkPath) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (path ThunkPath) Extend(ext Path) (Path, error)
- func (value *ThunkPath) FromValue(val Value) error
- func (path ThunkPath) Name() string
- func (path ThunkPath) Open(ctx context.Context) (io.ReadCloser, error)
- func (wl ThunkPath) SHA256() (string, error)
- func (value ThunkPath) String() string
- func (value *ThunkPath) UnmarshalJSON(payload []byte) error
- func (app ThunkPath) Unwrap() Combiner
- type Trace
- type UnboundError
- type UnixTableProtocol
- type UnknownProtocolError
- type Value
- func Descope(val Value) Value
- func EvalFSFile(ctx context.Context, scope *Scope, fs fs.FS, filePath string) (Value, error)
- func EvalFile(ctx context.Context, scope *Scope, filePath string) (Value, error)
- func EvalReader(ctx context.Context, e *Scope, r io.Reader, name ...string) (Value, error)
- func EvalString(ctx context.Context, e *Scope, str string, name ...string) (Value, error)
- func Resolve(val Value, r func(Value) (Value, error)) (Value, error)
- func ToSlice(list List) ([]Value, error)
- func Trampoline(ctx context.Context, val Value) (Value, error)
- func ValueOf(src interface{}) (Value, error)
- func WithMeta(val Value, metaVal Value) (Value, error)
- type ValueJSON
- type Wrapped
- func (combiner Wrapped) Call(ctx context.Context, val Value, scope *Scope, cont Cont) ReadyCont
- func (value Wrapped) Decode(dest interface{}) error
- func (value Wrapped) Equal(other Value) bool
- func (value Wrapped) Eval(_ context.Context, _ *Scope, cont Cont) ReadyCont
- func (value Wrapped) MarshalJSON() ([]byte, error)
- func (value Wrapped) String() string
- func (app Wrapped) Unwrap() Combiner
- type WriteFlusher
- type WriteonlyMemos
Constants ¶
const ExprLen = 40
const LockfileName = "bass.lock"
const TraceSize = 1000
const Version = "0.0.1-alpha"
Variables ¶
var Clock = clockwork.NewRealClock()
Clock is used to determine the current time.
var ErrBadSyntax = errors.New("bad syntax")
var ErrEndOfSource = errors.New("end of source")
var ErrInterrupted = errors.New("interrupted")
var ErrNoRuntimePool = errors.New("runtime not initialized")
ErrNoRuntimePool is returned when the context.Context does not have a runtime pool set.
var Ground = NewEmptyScope()
Ground is the scope providing the standard library.
var Identity = Continue(func(v Value) Value {
return v
})
var LinuxPlatform = Platform{
OS: "linux",
}
LinuxPlatform is the minimum configuration to select a Linux runtime.
var Protocols = map[Symbol]Protocol{ "raw": RawProtocol{}, "json": JSONProtocol{}, "unix-table": UnixTableProtocol{}, }
Protocols defines the set of supported protocols for reading responses.
var Secrets = NewEmptyScope()
var Stdin = &Source{ NewJSONSource("stdin", os.Stdin), }
var Stdout = &Sink{ NewJSONSink("stdout", os.Stdout), }
Functions ¶
func CacheThunkPath ¶
CacheThunkPath exports a thunk path to a local cache under $XDG_CACHE_HOME.
If the path is a file, a path to the cached file will be returned.
If the path is a directory, a path to a cached directory containing its immediate files will be returned. Note that sub-directories are not recursively exported.
A cached directory will be marked as cached by placing a .cached file in it to distinguish from a directory created in order to export a child path.
It does not preserve things like file permissions and timestamps. It is only for accessing the content of files.
func DecodeProto ¶
DecodeProto uses the named protocol to decode values from r into the sink.
func IsApplicative ¶
IsApplicative returns true iff the value is an Applicative.
func IsOperative ¶
IsOperative returns true iff the value is an Operative or a Builtin operative.
func MarshalJSON ¶
func UnmarshalJSON ¶
func WithRuntimePool ¶
func WithRuntimePool(ctx context.Context, pool RuntimePool) context.Context
func WriteError ¶
Types ¶
type Annotate ¶
type Annotate struct { // Value the inner form whose value will be annotated. Value // Range is the source code location of the inner form. Range Range // Comment is a literal comment ahead of or following the inner form. Comment string // Meta is an optional binding form that will be evaluated to attach metadata // to the inner form's value. Meta *Bind }
func (Annotate) MarshalJSON ¶
type AnnotateBinding ¶
func (AnnotateBinding) Decode ¶
func (value AnnotateBinding) Decode(dest interface{}) error
func (AnnotateBinding) EachBinding ¶
func (binding AnnotateBinding) EachBinding(cb func(Symbol, Range) error) error
type Annotated ¶
type Annotated struct { // Value is the inner value. Value // Meta contains metadata about the inner value. Meta *Scope }
func (Annotated) MarshalJSON ¶
type Applicative ¶
func Wrap ¶
func Wrap(comb Combiner) Applicative
type ArityError ¶
func (ArityError) Error ¶
func (err ArityError) Error() string
type BindMismatchError ¶
func (BindMismatchError) Error ¶
func (err BindMismatchError) Error() string
type Bindable ¶
type Bindable interface { Value // Bind assigns values to symbols in the given scope. Bind(context.Context, *Scope, Cont, Value, ...Annotated) ReadyCont // EachBinding calls the fn for each symbol that will be bound. EachBinding(func(Symbol, Range) error) error }
Bindable is any value which may be used to destructure a value into bindings in a scope.
type CannotBindError ¶
type CannotBindError struct {
Have Value
}
func (CannotBindError) Error ¶
func (err CannotBindError) Error() string
type CommandPath ¶
type CommandPath struct {
Command string `json:"command"`
}
CommandPath represents a command path in an abstract runtime environment, typically resolved by consulting $PATH.
func (CommandPath) Decode ¶
func (value CommandPath) Decode(dest interface{}) error
func (CommandPath) EachBinding ¶
func (CommandPath) EachBinding(func(Symbol, Range) error) error
func (CommandPath) Equal ¶
func (value CommandPath) Equal(other Value) bool
func (*CommandPath) FromValue ¶
func (value *CommandPath) FromValue(val Value) error
func (CommandPath) Name ¶
func (value CommandPath) Name() string
func (CommandPath) String ¶
func (value CommandPath) String() string
func (CommandPath) Unwrap ¶
func (app CommandPath) Unwrap() Combiner
type CompleteOpt ¶
type CompleteOpts ¶
type CompleteOpts []CompleteOpt
func (CompleteOpts) Len ¶
func (opts CompleteOpts) Len() int
func (CompleteOpts) Less ¶
func (opts CompleteOpts) Less(i, j int) bool
func (CompleteOpts) Swap ¶
func (opts CompleteOpts) Swap(i, j int)
type Config ¶
type Config struct {
Runtimes []RuntimeConfig `json:"runtimes"`
}
Config is set by the user and read by the Bass language and runtimes which run on the same machine.
func LoadConfig ¶
LoadConfig loads a Config from the JSON file at the given path.
type Cons ¶
type Cons Pair
func (Cons) MarshalJSON ¶
type Continuation ¶
func (*Continuation) Decode ¶
func (value *Continuation) Decode(dest interface{}) error
func (*Continuation) Equal ¶
func (value *Continuation) Equal(other Value) bool
func (*Continuation) MarshalJSON ¶
func (value *Continuation) MarshalJSON() ([]byte, error)
func (*Continuation) String ¶
func (value *Continuation) String() string
func (*Continuation) Traced ¶
func (value *Continuation) Traced(trace *Trace) Cont
type DecodeError ¶
type DecodeError struct { Source interface{} Destination interface{} }
func (DecodeError) Error ¶
func (err DecodeError) Error() string
type DirPath ¶
type DirPath struct {
Path string `json:"dir"`
}
DirPath represents a directory path in an abstract filesystem.
Its interpretation is context-dependent; it may refer to a path in a runtime environment, or a path on the local machine.
type Empty ¶
type Empty struct{}
func (Empty) MarshalJSON ¶
func (*Empty) UnmarshalJSON ¶
type Encodable ¶
type Encodable interface {
ToValue() Value
}
Encodable types typically implement json.Marshaler as well.
type EncodeError ¶
type EncodeError struct {
Value Value
}
func (EncodeError) Error ¶
func (err EncodeError) Error() string
type ExtendError ¶
func (ExtendError) Error ¶
func (err ExtendError) Error() string
type ExtendOperative ¶
type ExtendOperative struct {
Path Path
}
ExtendOperative is an operative which constructs a Extend.
func (ExtendOperative) Decode ¶
func (value ExtendOperative) Decode(dest interface{}) error
func (ExtendOperative) Equal ¶
func (value ExtendOperative) Equal(other Value) bool
func (ExtendOperative) String ¶
func (value ExtendOperative) String() string
type ExtendPath ¶
type ExtendPath struct { Parent Value Child FilesystemPath }
ExtendPath extends a parent path expression with a child path.
func (ExtendPath) Decode ¶
func (value ExtendPath) Decode(dest interface{}) error
func (ExtendPath) EachBinding ¶
func (ExtendPath) EachBinding(func(Symbol, Range) error) error
func (ExtendPath) Equal ¶
func (value ExtendPath) Equal(other Value) bool
func (ExtendPath) String ¶
func (value ExtendPath) String() string
type FSPath ¶
type FSPath struct { ID string `json:"fs"` FS fs.FS `json:"-"` Path FileOrDirPath `json:"path"` }
FSPath is a Path representing a file or directory relative to a filesystem.
This type will typically never occur in production code. It is only used for embedded filesystems, i.e. in Bass's stdlib and test suites.
JSON tags are specified just for keeping up appearances - this type needs to be marshalable just to support .SHA1, .SHA256, .Avatar, etc. on a Thunk that embeds it.
func NewInMemoryFSDir ¶
NewInMemoryFSDir is exposed as (mkfs) - it takes alternating file paths and content and constructs an in-memory filesystem path.
type FileOrDirPath ¶
FileOrDirPath is an enum type that accepts a FilePath or a DirPath.
func NewFileOrDirPath ¶
func NewFileOrDirPath(path FilesystemPath) FileOrDirPath
func ParseFileOrDirPath ¶
func ParseFileOrDirPath(arg string) FileOrDirPath
ParseFileOrDirPath parses arg as a path using the host machine's separator convention.
If the path is '.' or has a trailing slash, a DirPath is returned.
Otherwise, a FilePath is returned.
func (FileOrDirPath) Extend ¶
func (path FileOrDirPath) Extend(ext Path) (FileOrDirPath, error)
Extend extends the value with the given path and returns it wrapped in another FileOrDirPath.
func (FileOrDirPath) FilesystemPath ¶
func (path FileOrDirPath) FilesystemPath() FilesystemPath
FilesystemPath returns the value present.
func (*FileOrDirPath) FromValue ¶
func (path *FileOrDirPath) FromValue(val Value) error
FromValue decodes val into a FilePath or a DirPath, setting whichever worked as the internal value.
func (FileOrDirPath) MarshalJSON ¶
func (path FileOrDirPath) MarshalJSON() ([]byte, error)
func (FileOrDirPath) String ¶
func (path FileOrDirPath) String() string
String calls String on whichever value is present.
func (FileOrDirPath) ToValue ¶
func (path FileOrDirPath) ToValue() Value
ToValue returns the value present.
func (*FileOrDirPath) UnmarshalJSON ¶
func (path *FileOrDirPath) UnmarshalJSON(payload []byte) error
UnmarshalJSON unmarshals a FilePath or DirPath from JSON.
type FilePath ¶
type FilePath struct {
Path string `json:"file"`
}
FilePath represents a file path in an abstract filesystem.
Its interpretation is context-dependent; it may refer to a path in a runtime environment, or a path on the local machine.
func (FilePath) FileOrDir ¶
func (app FilePath) FileOrDir() FileOrDirPath
type FilesystemPath ¶
type FilesystemPath interface { Path // FromSlash uses filepath.FromSlash to convert the path to host machine's // path separators. FromSlash() string // IsDir returns true if the path refers to a directory. IsDir() bool // Dir returns the parent directory of the path, or the same directory if // there is no parent. Dir() DirPath }
FilesystemPath is a Path representing a file or directory in a filesystem.
type FormAnalyzer ¶
type HostPath ¶
type HostPath struct { ContextDir string `json:"context"` Path FileOrDirPath `json:"path"` }
HostPath is a Path representing an absolute path on the host machine's filesystem.
func NewHostDir ¶
func NewHostPath ¶
func NewHostPath(contextDir string, path FileOrDirPath) HostPath
type InMemoryFS ¶
InMemoryFS is a stupid simple filesystem representation, not even concerning itself with pesky permissions and timestamps.
It maps cleaned file paths to their content. It does not contain empty directories, but its file paths may be nested.
func (InMemoryFS) Open ¶
func (inmem InMemoryFS) Open(name string) (fs.File, error)
Opens returns a file for reading the given file's content or errors if the file does not exist.
The returned file always has 0644 permissions and a zero (Unix epoch) mtime.
func (InMemoryFS) SHA256 ¶
func (inmem InMemoryFS) SHA256() (string, error)
SHA256 returns a checksum of the filesystem.
type InMemorySink ¶
type InMemorySink struct {
Values []Value
}
func NewInMemorySink ¶
func NewInMemorySink() *InMemorySink
func (*InMemorySink) Emit ¶
func (src *InMemorySink) Emit(val Value) error
func (*InMemorySink) Reset ¶
func (sink *InMemorySink) Reset()
func (*InMemorySink) Source ¶
func (sink *InMemorySink) Source() PipeSource
func (*InMemorySink) String ¶
func (src *InMemorySink) String() string
type InMemorySource ¶
type InMemorySource struct {
// contains filtered or unexported fields
}
func NewInMemorySource ¶
func NewInMemorySource(vals ...Value) *InMemorySource
func (*InMemorySource) String ¶
func (src *InMemorySource) String() string
type JSONProtocol ¶
type JSONProtocol struct{}
JSON protocol decodes a values from JSON stream.
func (JSONProtocol) DecodeInto ¶
DecodeInto decodes a JSON stream from r and emits values to the sink.
type JSONSource ¶
type JSONSource struct { Name string // contains filtered or unexported fields }
func NewJSONSource ¶
func NewJSONSource(name string, in io.Reader) *JSONSource
func (*JSONSource) String ¶
func (source *JSONSource) String() string
type Keyword ¶
type Keyword string
type List ¶
func NewConsList ¶
type Lockfile ¶
type Lockfile struct {
// contains filtered or unexported fields
}
func NewLockfileMemo ¶
type LockfileContent ¶
type Memos ¶
type Memos interface { Store(Thunk, Symbol, Value, Value) error Retrieve(Thunk, Symbol, Value) (Value, bool, error) Remove(Thunk, Symbol, Value) error }
Memos is where memoized calls are cached.
func OpenFSPathMemos ¶
func OpenHostPathMemos ¶
type NiceError ¶
NiceError is an error that is able to provide some extra guidance to the user.
Strive for all errors returned by Bass to become a NiceError.
type Null ¶
type Null struct{}
type Pair ¶
func (Pair) Eval ¶
Pair combines the first operand with the second operand.
If the first value is not a Combiner, an error is returned.
func (Pair) MarshalJSON ¶
func (*Pair) UnmarshalJSON ¶
type Path ¶
type Path interface { // All Paths are Values. Value // Name returns the unqualified name for the path, i.e. the base name of a // file or directory, or the name of a command. Name() string // Extend returns a path referring to the given path relative to the parent // Path. Extend(Path) (Path, error) }
Path is an abstract location identifier for files, directories, or executable commands.
type PipeSource ¶
type Platform ¶
Platform configures an OCI image platform.
type Protocol ¶
type Protocol interface { // DecodeInto decodes values from the reader and emits them to the sink. DecodeInto(context.Context, PipeSink, io.Reader) error }
Protocol determines how response data is parsed from a thunk's response.
type PruneOpts ¶
type PruneOpts struct { // Prune everything. All bool // Keep data last used within the duration. KeepDuration time.Duration // Keep KeepBytes int64 }
PruneOpts contains parameters to fine-tune the pruning behavior. These parameters are best-effort; not all runtimes are expected to support every option.
type RawProtocol ¶
type RawProtocol struct{}
Raw protocol buffers the entire stream and writes it as a single JSON string on flush.
func (RawProtocol) DecodeInto ¶
DecodeInto reads the full content from r and emits it to the sink as a one big string.
type Reader ¶
type Reader struct { Analyzer FormAnalyzer Context context.Context // contains filtered or unexported fields }
type ReadonlyMemos ¶
type ReadonlyMemos struct {
Content LockfileContent
}
func (ReadonlyMemos) Remove ¶
func (file ReadonlyMemos) Remove(thunk Thunk, binding Symbol, input Value) error
type ReadyContinuation ¶
type ReadyContinuation struct { Cont *Continuation Result Value Err error }
func (*ReadyContinuation) Decode ¶
func (value *ReadyContinuation) Decode(dest interface{}) error
func (*ReadyContinuation) Equal ¶
func (value *ReadyContinuation) Equal(other Value) bool
func (*ReadyContinuation) Go ¶
func (cont *ReadyContinuation) Go() (Value, error)
func (*ReadyContinuation) MarshalJSON ¶
func (value *ReadyContinuation) MarshalJSON() ([]byte, error)
func (*ReadyContinuation) String ¶
func (cont *ReadyContinuation) String() string
type Runtime ¶
type Runtime interface { Resolve(context.Context, ThunkImageRef) (ThunkImageRef, error) Run(context.Context, io.Writer, Thunk) error Load(context.Context, Thunk) (*Scope, error) Export(context.Context, io.Writer, Thunk) error ExportPath(context.Context, io.Writer, ThunkPath) error Prune(context.Context, PruneOpts) error }
type RuntimeConfig ¶
type RuntimeConfig struct { Platform Platform `json:"platform"` Runtime string `json:"runtime"` Config *Scope `json:"config,omitempty"` }
RuntimeConfig associates a platform object to a runtime command to run.
Additional configuration may be specified; it will be read from the runtime by finding the config associated to the platform on the thunk it receives.
type RuntimePool ¶
func RuntimePoolFromContext ¶
func RuntimePoolFromContext(ctx context.Context) (RuntimePool, error)
type Scope ¶
type Scope struct { // an optional name for the scope, used to prettify .String on 'standard' // environments Name string Parents []*Scope Bindings Bindings Order []Symbol // contains filtered or unexported fields }
Scope contains bindings from symbols to values, and parent scopes to delegate to during symbol lookup.
func ImportSystemEnv ¶
func ImportSystemEnv() *Scope
ImportSystemEnv converts the system env into a scope, clearing the system env in the process. This is a destructive operation.
func NewEmptyScope ¶
NewEmptyScope constructs a new scope with no bindings and optional parents.
func NewStandardScope ¶
func NewStandardScope() *Scope
NewStandardScope returns a new empty scope with Ground as its sole parent.
func (*Scope) Complete ¶
func (scope *Scope) Complete(prefix string) []CompleteOpt
Complete queries the scope for bindings beginning with the given prefix.
Local bindings are listed before parent bindings, with shorter binding names listed first.
func (*Scope) Each ¶
Reduce calls f for each binding-value pair mapped by the scope.
Note that shadowed bindings will be skipped.
func (*Scope) Get ¶
Get fetches the given binding.
If a value is set in the local bindings, it is returned.
If not, the parent scopes are queried in order.
If no value is found, false is returned.
func (*Scope) IsSubsetOf ¶
func (*Scope) MarshalJSON ¶
func (*Scope) UnmarshalJSON ¶
type Secret ¶
type Secret struct { Name Symbol `json:"secret"` // contains filtered or unexported fields }
func (Secret) Decode ¶
Decode only supports decoding into a Secret or Value; it will not reveal the inner secret.
type Source ¶
type Source struct {
PipeSource PipeSource
}
func NewSource ¶
func NewSource(ps PipeSource) *Source
func (*Source) MarshalJSON ¶
type Symbol ¶
type Symbol string
var ( DocMetaBinding Symbol = "doc" FileMetaBinding Symbol = "file" LineMetaBinding Symbol = "line" ColumnMetaBinding Symbol = "column" )
DocMetaBinding is the binding in meta that stores the value's doc string.
func Predicates ¶
Predicates returns a list of all builtin predicates which return true for the given value.
func SymbolFromJSONKey ¶
type SymbolOperative ¶
type SymbolOperative struct {
Symbol Symbol
}
func (SymbolOperative) Decode ¶
func (value SymbolOperative) Decode(dest interface{}) error
func (SymbolOperative) Equal ¶
func (value SymbolOperative) Equal(other Value) bool
func (SymbolOperative) String ¶
func (value SymbolOperative) String() string
type Thunk ¶
type Thunk struct { // Image specifies the OCI image in which to run the thunk. Image *ThunkImage `json:"image,omitempty"` // Insecure may be set to true to enable running the thunk with elevated // privileges. Its meaning is determined by the runtime. Insecure bool `json:"insecure,omitempty"` // Cmd identifies the file or command to run. Cmd ThunkCmd `json:"cmd"` // Args is a list of string or path arguments to pass to the command. Args []Value `json:"args,omitempty"` // Stdin is a list of arbitrary values, which may contain paths, to pass to // the command. Stdin []Value `json:"stdin,omitempty"` // Env is a mapping from environment variables to their string or path // values. Env *Scope `json:"env,omitempty"` // Dir configures a working directory in which to run the command. // // Note that a working directory is automatically provided to thunks by // the runtime. A relative Dir value will be relative to this working // directory, not the OCI image's initial working directory. The OCI image's // working directory is ignored. // // A relative directory path will be relative to the initial working // directory. An absolute path will be relative to the OCI image root. // // A thunk directory path may also be provided. It will be mounted to the // container and used as the working directory of the command. Dir *ThunkDir `json:"dir,omitempty"` // Mounts configures explicit mount points for the thunk, in addition to // any provided in Path, Args, Stdin, Env, or Dir. Mounts []ThunkMount `json:"mounts,omitempty"` // Labels specify arbitrary fields for identifying the thunk, typically // used to influence caching behavior. // // For example, thunks which may return different results over time should // embed the current timestamp truncated to a certain amount of granularity, // e.g. one minute. Doing so prevents the first call from being cached // forever while still allowing some level of caching to take place. Labels *Scope `json:"labels,omitempty"` }
func (Thunk) Extend ¶
Extend returns a path referring to the given path relative to the parent Path.
func (Thunk) Name ¶
Name returns the unqualified name for the path, i.e. the base name of a file or directory, or the name of a command.
func (*Thunk) UnmarshalJSON ¶
func (Thunk) WithImage ¶
func (thunk Thunk) WithImage(image ThunkImage) Thunk
WithImage sets the base image of the thunk, recursing into parent thunks until it reaches the bottom, like a rebase.
func (Thunk) WithInsecure ¶
WithInsecure sets whether the thunk should be run insecurely.
func (Thunk) WithMount ¶
func (thunk Thunk) WithMount(src ThunkMountSource, tgt FileOrDirPath) Thunk
WithMount adds a mount.
type ThunkCmd ¶
type ThunkCmd struct { Cmd *CommandPath File *FilePath ThunkFile *ThunkPath Host *HostPath FS *FSPath }
func (ThunkCmd) MarshalJSON ¶
func (*ThunkCmd) UnmarshalJSON ¶
type ThunkImage ¶
type ThunkImage struct { Ref *ThunkImageRef Thunk *Thunk }
ThunkImage specifies an OCI image, either by referencing a location or by referencing a path to an OCI image archive.
func (*ThunkImage) FromValue ¶
func (image *ThunkImage) FromValue(val Value) error
func (ThunkImage) MarshalJSON ¶
func (image ThunkImage) MarshalJSON() ([]byte, error)
func (ThunkImage) Platform ¶
func (img ThunkImage) Platform() *Platform
func (ThunkImage) ToValue ¶
func (image ThunkImage) ToValue() Value
func (*ThunkImage) UnmarshalJSON ¶
func (image *ThunkImage) UnmarshalJSON(payload []byte) error
type ThunkImageRef ¶
type ThunkImageRef struct { Platform Platform `json:"platform"` Repository string `json:"repository"` Tag string `json:"tag,omitempty"` Digest string `json:"digest,omitempty"` }
ThunkImageRef specifies an OCI image uploaded to a registry.
func (ThunkImageRef) Ref ¶
func (ref ThunkImageRef) Ref() string
type ThunkMount ¶
type ThunkMount struct { Source ThunkMountSource `json:"source"` Target FileOrDirPath `json:"target"` }
ThunkMount configures a mount for the thunk.
type ThunkMountSource ¶
type ThunkMountSource struct { ThunkPath *ThunkPath HostPath *HostPath FSPath *FSPath Cache *FileOrDirPath Secret *Secret }
func (*ThunkMountSource) FromValue ¶
func (enum *ThunkMountSource) FromValue(val Value) error
func (ThunkMountSource) MarshalJSON ¶
func (enum ThunkMountSource) MarshalJSON() ([]byte, error)
func (ThunkMountSource) ToValue ¶
func (enum ThunkMountSource) ToValue() Value
func (*ThunkMountSource) UnmarshalJSON ¶
func (enum *ThunkMountSource) UnmarshalJSON(payload []byte) error
type ThunkOperative ¶
type ThunkOperative struct {
Cmd ThunkCmd
}
ThunkOperative is an operative which constructs a Thunk.
func (ThunkOperative) Decode ¶
func (value ThunkOperative) Decode(dest interface{}) error
func (ThunkOperative) Equal ¶
func (value ThunkOperative) Equal(other Value) bool
func (ThunkOperative) String ¶
func (value ThunkOperative) String() string
type ThunkPath ¶
type ThunkPath struct { Thunk Thunk `json:"thunk"` Path FileOrDirPath `json:"path"` }
A path created by a thunk.
func (*ThunkPath) UnmarshalJSON ¶
type UnboundError ¶
type UnboundError struct {
Symbol Symbol
}
func (UnboundError) Error ¶
func (err UnboundError) Error() string
type UnixTableProtocol ¶
type UnixTableProtocol struct{}
UnixTableProtocol parses lines of tabular output with columns separated by whitespace.
Each row is not guaranteed to have the same number of columns. Empty lines correspond to empty arrays.
func (UnixTableProtocol) DecodeInto ¶
DecodeInto decodes from r and emits lists of strings to the sink.
type UnknownProtocolError ¶
type UnknownProtocolError struct {
Protocol Symbol
}
UnknownProtocolError is returned when a thunk specifies an unknown response protocol.
func (UnknownProtocolError) Error ¶
func (err UnknownProtocolError) Error() string
type Value ¶
type Value interface { fmt.Stringer // Eval continues execution with a new value (or the same value, for consts). Eval(context.Context, *Scope, Cont) ReadyCont // Equal checks whether two values are equal, i.e. same type and equivalent // value. Equal(Value) bool // Decode coerces and assigns the Value into the given type, analogous to // unmarshaling. // // If the given type is a direct implementor of Value, it must only // successfully decode from another instance of that type. // // If the given type is a Go primitive, it must do its best to coerce into // that type. For example, null can Decode into bool, but not Bool. // // TODO: move this to Encodable/Decodable or something (or rename all this if // it's so confusing) Decode(interface{}) error }
Value represents any value used by Bass programs.
func Descope ¶
Descope is a funky little function that decodes from the scope form of a first-class value type, like a thunk path or file path. This typically happens when encoding to and from JSON.
func EvalFSFile ¶
func EvalReader ¶
func EvalString ¶
type ValueJSON ¶
type ValueJSON struct {
Value
}
ValueJSON is just an envelope for an arbitrary Value.
func (ValueJSON) MarshalJSON ¶
func (*ValueJSON) UnmarshalJSON ¶
type Wrapped ¶
type Wrapped struct {
Underlying Combiner
}
func (Wrapped) Call ¶
Call evaluates the value in the scope and calls the underlying combiner with the result.
func (Wrapped) MarshalJSON ¶
type WriteFlusher ¶
WriteFlusher is a flushable io.Writer, to support protocols which have to maintain an internal buffer.
Source Files ¶
- annotated.go
- applicative.go
- bind.go
- bool.go
- builtin.go
- combiners.go
- config.go
- cons.go
- continuation.go
- doc.go
- empty.go
- env.go
- errors.go
- eval.go
- exportcache.go
- fspath.go
- ground.go
- host_path.go
- ignore.go
- int.go
- json.go
- keyword.go
- list.go
- log.go
- memfs.go
- memo.go
- null.go
- operative.go
- pair.go
- path.go
- pipes.go
- predicates.go
- protocol.go
- range.go
- readable.go
- reader.go
- runtime.go
- scope.go
- script.go
- secret.go
- stdlib.go
- string.go
- symbol.go
- thunk.go
- thunk_path.go
- thunk_types.go
- trace.go
- value.go
- version.go