lib

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 51 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package lib implements the standard library (section 11 and stdlib.md) as builtins, and builds the prelude table that binds every prelude name.

Index

Constants

This section is empty.

Variables

View Source
var (
	// HtmlElementTag is Html.Element: { name, attributes, children }.
	HtmlElementTag = value.NewTag("Html.Element", value.RecordTag, []string{"name", "attributes", "children"})
	// HtmlAttributeTag is Html.Attribute: { name, value }.
	HtmlAttributeTag = value.NewTag("Html.Attribute", value.RecordTag, []string{"name", "value"})
	// HtmlTextTag is Html.Text: { text }.
	HtmlTextTag = value.NewTag("Html.Text", value.RecordTag, []string{"text"})
	// HtmlRawTag is Html.Raw: { markup }.
	HtmlRawTag = value.NewTag("Html.Raw", value.RecordTag, []string{"markup"})
)
View Source
var (
	ReflectTypeTag       = value.NewTag("Reflect.Type", value.SyncTag, nil)
	ReflectErasedTypeTag = value.NewTag("Reflect.ErasedType", value.SyncTag, nil)
	ReflectDeclTag       = value.NewTag("Reflect.Decl", value.SyncTag, nil)
	ReflectValueTag      = value.NewTag("Reflect.Value", value.SyncTag, nil)

	ShapeNullTag   = value.NewTag("Reflect.Null", value.RecordTag, nil)
	ShapeVoidTag   = value.NewTag("Reflect.Void", value.RecordTag, nil)
	ShapeNeverTag  = value.NewTag("Reflect.Never", value.RecordTag, nil)
	ShapeBoolTag   = value.NewTag("Reflect.Bool", value.RecordTag, nil)
	ShapeIntTag    = value.NewTag("Reflect.Int", value.RecordTag, []string{"bits", "signed"})
	ShapeFloatTag  = value.NewTag("Reflect.Float", value.RecordTag, []string{"bits"})
	ShapeStringTag = value.NewTag("Reflect.String", value.RecordTag, nil)
	ShapeArrayTag  = value.NewTag("Reflect.Array", value.RecordTag, []string{"element"})
	ShapeMapTag    = value.NewTag("Reflect.Map", value.RecordTag, []string{"key", "value"})
	ShapeSetTag    = value.NewTag("Reflect.Set", value.RecordTag, []string{"member"})
	ShapeRecordTag = value.NewTag("Reflect.Record", value.RecordTag, []string{"decl", "args", "fields"})
	ShapeFieldTag  = value.NewTag("Reflect.Field", value.RecordTag, []string{"name", "type", "hasDefault"})
	ShapeTaggedTag = value.NewTag("Reflect.Tagged", value.RecordTag, []string{"decl", "args", "base"})
	ShapeUnionTag  = value.NewTag("Reflect.Union", value.RecordTag, []string{"members"})
	ShapeFuncTag   = value.NewTag("Reflect.Func", value.RecordTag, []string{"params", "result"})
	ShapeOpaqueTag = value.NewTag("Reflect.Opaque", value.RecordTag, []string{"decl", "args"})
)

The Reflect namespace (section 11, Reflect): type values, shapes, and reflected values. The opaque types are tags that `is` cannot test, as the sync types are; the shapes are record tags whose values Reflect.shape builds. A type value is the checker's own types.Type, so equality, union membership, substitution, and assignability are the checker's code.

View Source
var CmdTag = value.NewTag("Cmd", value.RecordTag, []string{"program", "args", "dir", "env"})

CmdTag is Cmd: { program: string, args: Array[string], dir: string | null, env: Map[string, string] | null }, with the defaults the prelude declares.

View Source
var CutTag = value.NewTag("String.Cut", value.RecordTag, []string{"before", "after"})

CutTag is String.Cut: { before: string, after: string }.

View Source
var FrameTag = value.NewTag("Panic.Frame", value.RecordTag, []string{"function", "path", "line", "column"})

FrameTag is Panic.Frame: { function: string, path: string, line: int, column: int }.

View Source
var InfoTag = value.NewTag("File.Info", value.RecordTag, []string{"name", "size", "isDir", "isSymlink", "modified", "mode", "uid", "gid"})

InfoTag is File.Info: { name: string, size: int, isDir: bool, isSymlink: bool, modified: Time.Instant, mode: int, uid: int | null, gid: int | null }.

View Source
var MatchTag = value.NewTag("Regex.Match", value.RecordTag, []string{"text", "start", "end", "groups", "named"})

MatchTag is Regex.Match: { text, start, end, groups, named }.

View Source
var OutputBytesTag = value.NewTag("Cmd.OutputBytes", value.RecordTag, []string{"status", "statuses", "stdout", "stderr"})

OutputBytesTag is Cmd.OutputBytes: { status: int, statuses: Array[int], stdout: Bytes, stderr: string }, standard output as the last stage wrote it and standard error as text.

View Source
var OutputTag = value.NewTag("Cmd.Output", value.RecordTag, []string{"status", "statuses", "stdout", "stderr"})

OutputTag is Cmd.Output: { status: int, statuses: Array[int], stdout: string, stderr: string }, both outputs as text.

View Source
var PanicTag = value.NewTag("Panic", value.RecordTag, []string{"message", "trace"})

PanicTag is Panic: { message: string, trace: Array[Panic.Frame] }.

View Source
var PartsTag = value.NewTag("Url.Parts", value.RecordTag, []string{"scheme", "opaque", "user", "host", "port", "path", "query", "fragment"})

PartsTag is Url.Parts: a reference as RFC 3986 divides it.

View Source
var PipeTag = value.NewTag("Os.Pipe", value.RecordTag, []string{"read", "write"})

PipeTag is Os.Pipe: { read: File.Handle, write: File.Handle }.

View Source
var PipelineTag = value.NewTag("Cmd.Pipeline", value.RecordTag, []string{"cmds"})

PipelineTag is Cmd.Pipeline: { cmds: Array[Cmd] }.

View Source
var ReplyTag = value.NewTag("Http.Reply", value.RecordTag, []string{"status", "headers", "body"})

ReplyTag is Http.Reply: what a handler of Http.serve returns, with a body that is a string or Bytes.

View Source
var RequestTag = value.NewTag("Http.Request", value.RecordTag, []string{"method", "path", "query", "headers", "bytes", "remote"})

RequestTag is Http.Request: what a handler of Http.serve receives, the body held once, as received; Http.text decodes it.

View Source
var ResponseTag = value.NewTag("Http.Response", value.RecordTag, []string{"status", "headers", "bytes"})

ResponseTag is Http.Response: { status: int, headers: Map[string, string], bytes: Bytes }, the body held once, as received; Http.text decodes it.

Functions

func Prelude

func Prelude() map[string]value.Value

Prelude returns the table that binds every prelude name. It is built once and shared by every run; nothing in it changes after construction.

Types

type Handle

type Handle struct {
	// contains filtered or unexported fields
}

Handle is an open file, a standard stream, a connection, or a buffer over one: File.Handle. A reader holds the read slot, a writer the write mutex, and close takes the state mutex alone, so one goroutine may read a connection while another writes it, and a close from a third ends both. A write goes to the OS before it returns, except into the buffer of a buffered handle.

func (*Handle) SyncName

func (h *Handle) SyncName() string

SyncName names the handle for rendering.

type Listener

type Listener struct {
	// contains filtered or unexported fields
}

Listener is a listening TCP socket: Net.Listener. Connections are accepted by a pump, one goroutine started at the first Net.accept, which hands each over conns to the next caller, so a caller selects on its own context and disturbs no other; a connection accepted while no caller waits is held for the next one.

func (*Listener) SyncName

func (l *Listener) SyncName() string

SyncName names the listener for rendering.

type Process

type Process struct {
	// contains filtered or unexported fields
}

Process is a started command, one child per stage: Cmd.Process. A goroutine waits for them from the start, so they are reaped whether or not the program waits, and records the outcome every Cmd.wait returns.

func (*Process) SyncName

func (p *Process) SyncName() string

SyncName names the process for rendering.

type Random

type Random struct {
	// contains filtered or unexported fields
}

Random is the seeded generator of section 11: xoshiro256** over four words, seeded by SplitMix64. Every value it gives is fixed by the spec, so no step here may change. Goroutines that share one race (section 9), so mu keeps the state whole: each operation, a whole shuffle included, is one step that a racing one comes before or after.

func (*Random) SyncName

func (r *Random) SyncName() string

SyncName names the generator for rendering.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL