Skip to documentation
SLOP

tiny.pluck.help_topics

Reference tiny.pluck help_topics

Defined in tiny.pluck.

API (3)

Actions

Public operations.

Types and contracts

Public types and contracts.

No direct callersNo direct callstiny.pluckhelp topics
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Called byCallstest sourcelib.pluck.src.topicstest: getHelpTopic returns null for u...test sourcelib.pluck.src.topicstest: help topics lists match getHelp...tiny.pythonsyntax.astListhelp_topicsgetHelpTopic
Static calls · unresolved targets: 4 · external targets: 6.

Source: lib/pluck/src/root.zig:14

zig
pub const help_topics = @import("topics.zig");

Source: lib/pluck/src/topics.zig

zig
const std = @import("std");pub const HelpTopic = struct {    title: []const u8,    lines: []const []const u8,};pub const help_topics = struct {    pub const primitives = [_][]const u8{ "flip", "factor", "discrete", "uniform", "bgeom", "geom" };    pub const queries = [_][]const u8{ "Marginal", "Posterior", "PosteriorSamples", "AdaptiveRejection" };    pub const syntax = [_][]const u8{ "syntax-overview", "if", "case", "let", "lambda", "operators" };    pub const types = [_][]const u8{ "Bool", "Nat", "List", "Pair", "SuspendibleBool", "Unit" };    pub const stdlib = [_][]const u8{ "fst", "snd", "and", "or", "not", "iff", "given", "geom", "bgeom", "randnat", "randnatlist", "inc", "dec", "add", "+", "mul", "*", "sub", "-", "mod", "eq_nat", "nat=?", "lt_nat", "<", "gt_nat", ">", "le_nat", "<=", "ge_nat", ">=", "iseven", "car", "cdr", "cdr_safe", "isempty", "fold", "length", "append", "append_one", "map", "mapi", "filter", "filteri", "range", "zip_with", "take", "index", "list_eq", "list=?", "any", "all", "constructors_equal", "constructor=?", "adt_eq", "=?", "==", "susp_list_eq", "suspendible-list=?", "int1=?", "int2=?", "int3=?", "int4=?", "head-or", "float-of-nat", "make-uniform", "normalize-seq", "sample-seq" };    pub const commands = [_][]const u8{ ":help", ":quit", ":reset", ":defs", ":type" };};pub fn getHelpTopic(name: []const u8) ?HelpTopic {    const topics = std.StaticStringMap(HelpTopic).initComptime(.{        .{ "flip", HelpTopic{            .title = "flip : Prob -> Bool",            .lines = &.{                "  Bernoulli random variable.",                "  (flip p) returns True with probability p, else False.",                "",                "  Example:",                "    (Marginal (flip 0.5))",            },        } },        .{ "factor", HelpTopic{            .title = "factor : Weight -> Unit",            .lines = &.{                "  Soft conditioning by multiplying path weights.",                "  (factor 0) prunes a path.",            },        } },        .{ "discrete", HelpTopic{            .title = "discrete : (value, prob)... -> value",            .lines = &.{                "  Finite categorical distribution.",                "",                "  Example:",                "    (Marginal (discrete (True 0.3) (False 0.7)))",            },        } },        .{ "uniform", HelpTopic{            .title = "uniform : value... -> value",            .lines = &.{                "  Uniform choice among provided values.",                "",                "  Example:",                "    (Marginal (uniform Red Green Blue))",            },        } },        .{ "bgeom", HelpTopic{            .title = "bgeom : Prob -> Nat -> Nat",            .lines = &.{                "  Bounded geometric distribution.",                "  Exact-inference friendly alternative to unbounded geom.",            },        } },        .{ "geom", HelpTopic{            .title = "geom : Prob -> Nat",            .lines = &.{                "  Unbounded geometric distribution.",            },        } },        .{ "Marginal", HelpTopic{            .title = "Marginal : a -> Dist a",            .lines = &.{                "  Compute the full distribution of an expression.",                "",                "  Example:",                "    (Marginal (flip 0.5))",            },        } },        .{ "Posterior", HelpTopic{            .title = "Posterior : a -> Bool -> Dist a",            .lines = &.{                "  Condition expression on evidence.",                "",                "  Example:",                "    (Posterior burglar called)",            },        } },        .{ "PosteriorSamples", HelpTopic{            .title = "PosteriorSamples : a -> Bool -> Nat -> Dist a",            .lines = &.{                "  Draw N samples from the posterior.",                "",                "  Example:",                "    (PosteriorSamples x True 100)",            },        } },        .{ "AdaptiveRejection", HelpTopic{            .title = "AdaptiveRejection : a -> Bool -> a",            .lines = &.{                "  Draw one sample from the posterior.",            },        } },        .{ "syntax-overview", HelpTopic{            .title = "Pluck Language Syntax Overview",            .lines = &.{                "  Pluck uses S-expression syntax.",                "",                "  Top-level forms:",                "    (define name expr)",                "    (define (name args...) body)",                "    (define-type TypeName (Ctor ...))",                "    (query expr)",                "    (query name expr)",                "",                "  Core expression forms:",                "    (if cond then else)",                "    (lam x -> body)",                "    (let ((x e1) (y e2)) body)",                "    (case expr of Ctor arg => result | Other => fallback)",            },        } },        .{ "if", HelpTopic{            .title = "if : conditional expression",            .lines = &.{                "  Form:",                "    (if condition then-expr else-expr)",            },        } },        .{ "case", HelpTopic{            .title = "case : pattern matching",            .lines = &.{                "  Form:",                "    (case expr of Ctor arg1 arg2 => result | Other => fallback)",            },        } },        .{ "let", HelpTopic{            .title = "let : local bindings",            .lines = &.{                "  Form:",                "    (let ((x e1) (y e2)) body)",            },        } },        .{ "lambda", HelpTopic{            .title = "lambda : anonymous functions",            .lines = &.{                "  Form:",                "    (lam x -> body)",            },        } },        .{ "operators", HelpTopic{            .title = "operators",            .lines = &.{                "  Prefer stdlib/operator forms in S-expression syntax:",                "    (and a b)",                "    (or a b)",                "    (not a)",                "    (add x y)",                "    (+ x y)",                "    (mul x y)",                "    (* x y)",            },        } },        .{ "Bool", HelpTopic{ .title = "type Bool : True | False", .lines = &.{"  Boolean type."} } },        .{ "Nat", HelpTopic{ .title = "type Nat : O | S(Nat)", .lines = &.{"  Natural numbers."} } },        .{ "List", HelpTopic{ .title = "type List a : Nil | Cons(a, List a)", .lines = &.{"  Linked list type."} } },        .{ "Pair", HelpTopic{ .title = "type Pair a b : Pair(a, b)", .lines = &.{"  Pair/product type."} } },        .{ "SuspendibleBool", HelpTopic{ .title = "type SuspendibleBool : FinallyTrue | FinallyFalse | Suspend(SuspendibleBool)", .lines = &.{"  Suspendible Boolean computations for LPSMC workflows."} } },        .{ "Unit", HelpTopic{ .title = "type Unit : Unit", .lines = &.{"  Unit value type."} } },        .{ "fst", HelpTopic{ .title = "fst : Pair a b -> a", .lines = &.{"  First projection."} } },        .{ "snd", HelpTopic{ .title = "snd : Pair a b -> b", .lines = &.{"  Second projection."} } },        .{ "and", HelpTopic{ .title = "and : Bool -> Bool -> Bool", .lines = &.{"  Boolean conjunction."} } },        .{ "or", HelpTopic{ .title = "or : Bool -> Bool -> Bool", .lines = &.{"  Boolean disjunction."} } },        .{ "not", HelpTopic{ .title = "not : Bool -> Bool", .lines = &.{"  Boolean negation."} } },        .{ "iff", HelpTopic{ .title = "iff : Bool -> Bool -> Bool", .lines = &.{"  Boolean equivalence."} } },        .{ "given", HelpTopic{ .title = "given : Bool -> a -> a", .lines = &.{"  Hard conditioning helper."} } },        .{ "randnat", HelpTopic{ .title = "randnat : Unit -> Nat", .lines = &.{"  Geometric random natural number."} } },        .{ "randnatlist", HelpTopic{ .title = "randnatlist : Unit -> List Nat", .lines = &.{"  Random list of geometric random natural numbers."} } },        .{ "inc", HelpTopic{ .title = "inc : Nat -> Nat", .lines = &.{"  Successor."} } },        .{ "dec", HelpTopic{ .title = "dec : Nat -> Nat", .lines = &.{"  Saturating predecessor."} } },        .{ "add", HelpTopic{ .title = "add : Nat -> Nat -> Nat", .lines = &.{"  Nat addition."} } },        .{ "+", HelpTopic{ .title = "+ : Nat -> Nat -> Nat", .lines = &.{"  Operator form for add."} } },        .{ "mul", HelpTopic{ .title = "mul : Nat -> Nat -> Nat", .lines = &.{"  Nat multiplication."} } },        .{ "*", HelpTopic{ .title = "* : Nat -> Nat -> Nat", .lines = &.{"  Operator form for mul."} } },        .{ "sub", HelpTopic{ .title = "sub : Nat -> Nat -> Nat", .lines = &.{"  Saturating Nat subtraction."} } },        .{ "-", HelpTopic{ .title = "- : Nat -> Nat -> Nat", .lines = &.{"  Operator form for sub."} } },        .{ "mod", HelpTopic{ .title = "mod : Nat -> Nat -> Nat", .lines = &.{"  Nat remainder."} } },        .{ "eq_nat", HelpTopic{ .title = "eq_nat : Nat -> Nat -> Bool", .lines = &.{"  Nat equality."} } },        .{ "nat=?", HelpTopic{ .title = "nat=? : Nat -> Nat -> Bool", .lines = &.{"  Operator-style name for eq_nat."} } },        .{ "lt_nat", HelpTopic{ .title = "lt_nat : Nat -> Nat -> Bool", .lines = &.{"  Strict Nat less-than."} } },        .{ "<", HelpTopic{ .title = "< : Nat -> Nat -> Bool", .lines = &.{"  Operator form for lt_nat."} } },        .{ "gt_nat", HelpTopic{ .title = "gt_nat : Nat -> Nat -> Bool", .lines = &.{"  Strict Nat greater-than."} } },        .{ ">", HelpTopic{ .title = "> : Nat -> Nat -> Bool", .lines = &.{"  Operator form for gt_nat."} } },        .{ "le_nat", HelpTopic{ .title = "le_nat : Nat -> Nat -> Bool", .lines = &.{"  Nat less-than-or-equal."} } },        .{ "<=", HelpTopic{ .title = "<= : Nat -> Nat -> Bool", .lines = &.{"  Operator form for le_nat."} } },        .{ "ge_nat", HelpTopic{ .title = "ge_nat : Nat -> Nat -> Bool", .lines = &.{"  Nat greater-than-or-equal."} } },        .{ ">=", HelpTopic{ .title = ">= : Nat -> Nat -> Bool", .lines = &.{"  Operator form for ge_nat."} } },        .{ "iseven", HelpTopic{ .title = "iseven : Nat -> Bool", .lines = &.{"  True for even natural numbers."} } },        .{ "car", HelpTopic{ .title = "car : List a -> a", .lines = &.{"  List head."} } },        .{ "cdr", HelpTopic{ .title = "cdr : List a -> List a", .lines = &.{"  List tail, or Nil for Nil."} } },        .{ "cdr_safe", HelpTopic{ .title = "cdr_safe : List a -> List a", .lines = &.{"  Safe list tail."} } },        .{ "isempty", HelpTopic{ .title = "isempty : List a -> Bool", .lines = &.{"  True for Nil."} } },        .{ "fold", HelpTopic{ .title = "fold : (b -> a -> b) -> b -> List a -> b", .lines = &.{"  Fold a list from tail to head."} } },        .{ "length", HelpTopic{ .title = "length : List a -> Nat", .lines = &.{"  List length."} } },        .{ "append", HelpTopic{ .title = "append : List a -> List a -> List a", .lines = &.{"  List concatenation."} } },        .{ "append_one", HelpTopic{ .title = "append_one : List a -> a -> List a", .lines = &.{"  Append a single element."} } },        .{ "map", HelpTopic{ .title = "map : (a -> b) -> List a -> List b", .lines = &.{"  Map a function over a list."} } },        .{ "mapi", HelpTopic{ .title = "mapi : (a -> Nat -> b) -> List a -> List b", .lines = &.{"  Map with zero-based element indexes."} } },        .{ "filter", HelpTopic{ .title = "filter : (a -> Bool) -> List a -> List a", .lines = &.{"  Keep matching elements."} } },        .{ "filteri", HelpTopic{ .title = "filteri : (a -> Nat -> Bool) -> List a -> List a", .lines = &.{"  Keep matching indexed elements."} } },        .{ "range", HelpTopic{ .title = "range : Nat -> List Nat", .lines = &.{"  Naturals from zero up to the bound."} } },        .{ "zip_with", HelpTopic{ .title = "zip_with : (a -> b -> c) -> List a -> List b -> List c", .lines = &.{"  Zip two lists with a binary function."} } },        .{ "take", HelpTopic{ .title = "take : Nat -> List a -> List a", .lines = &.{"  Prefix of a list."} } },        .{ "index", HelpTopic{ .title = "index : Nat -> List a -> a", .lines = &.{"  Zero-based list lookup."} } },        .{ "list_eq", HelpTopic{ .title = "list_eq : (a -> a -> Bool) -> List a -> List a -> Bool", .lines = &.{"  Elementwise list equality."} } },        .{ "list=?", HelpTopic{ .title = "list=? : (a -> a -> Bool) -> List a -> List a -> Bool", .lines = &.{"  Operator-style name for list_eq."} } },        .{ "any", HelpTopic{ .title = "any : (a -> Bool) -> List a -> Bool", .lines = &.{"  True when any element matches."} } },        .{ "all", HelpTopic{ .title = "all : (a -> Bool) -> List a -> Bool", .lines = &.{"  True when all elements match."} } },        .{ "constructors_equal", HelpTopic{ .title = "constructors_equal : a -> b -> Bool", .lines = &.{"  Compare ADT constructor names."} } },        .{ "constructor=?", HelpTopic{ .title = "constructor=? : a -> b -> Bool", .lines = &.{"  Operator-style name for constructors_equal."} } },        .{ "adt_eq", HelpTopic{ .title = "adt_eq : a -> a -> Bool", .lines = &.{"  Recursive ADT equality."} } },        .{ "=?", HelpTopic{ .title = "=? : a -> a -> Bool", .lines = &.{"  Operator-style name for adt_eq."} } },        .{ "==", HelpTopic{ .title = "== : a -> a -> Bool", .lines = &.{"  Operator-style name for adt_eq."} } },        .{ "susp_list_eq", HelpTopic{ .title = "susp_list_eq : (a -> a -> Bool) -> List a -> List a -> SuspendibleBool", .lines = &.{"  Suspendible elementwise list equality."} } },        .{ "suspendible-list=?", HelpTopic{ .title = "suspendible-list=? : (a -> a -> Bool) -> List a -> List a -> SuspendibleBool", .lines = &.{"  Reference name for suspendible elementwise list equality."} } },        .{ "int1=?", HelpTopic{ .title = "int1=? : int1 -> int1 -> Bool", .lines = &.{"  Equality for one-bit integer records."} } },        .{ "int2=?", HelpTopic{ .title = "int2=? : int2 -> int2 -> Bool", .lines = &.{"  Equality for two-bit integer records."} } },        .{ "int3=?", HelpTopic{ .title = "int3=? : int3 -> int3 -> Bool", .lines = &.{"  Equality for three-bit integer records."} } },        .{ "int4=?", HelpTopic{ .title = "int4=? : int4 -> int4 -> Bool", .lines = &.{"  Equality for four-bit integer records."} } },        .{ "head-or", HelpTopic{ .title = "head-or : List a -> a -> a", .lines = &.{"  List head with fallback."} } },        .{ "float-of-nat", HelpTopic{ .title = "float-of-nat : Nat -> Float", .lines = &.{"  Convert a Nat to a float."} } },        .{ "make-uniform", HelpTopic{ .title = "make-uniform : List a -> List (Pair a Float)", .lines = &.{"  Build uniform weighted pairs."} } },        .{ "normalize-seq", HelpTopic{ .title = "normalize-seq : List (Pair a Float) -> List (Pair a Float)", .lines = &.{"  Normalize weights for sequential sampling."} } },        .{ "sample-seq", HelpTopic{ .title = "sample-seq : List (Pair a Float) -> a", .lines = &.{"  Sample from normalized sequential weights."} } },        .{ ":help", HelpTopic{ .title = ":help [topic]", .lines = &.{"  Show help for a topic."} } },        .{ ":quit", HelpTopic{ .title = ":quit", .lines = &.{"  Exit interactive mode."} } },        .{ ":reset", HelpTopic{ .title = ":reset", .lines = &.{"  Clear user definitions."} } },        .{ ":defs", HelpTopic{ .title = ":defs", .lines = &.{"  List user definitions."} } },        .{ ":type", HelpTopic{ .title = ":type <name>", .lines = &.{"  Show type information for a symbol."} } },        .{ "primitives", HelpTopic{ .title = "=== Primitives ===", .lines = &.{"  flip, factor, discrete, uniform, bgeom, geom"} } },        .{ "queries", HelpTopic{ .title = "=== Queries ===", .lines = &.{"  Marginal, Posterior, PosteriorSamples, AdaptiveRejection"} } },        .{ "syntax", HelpTopic{ .title = "=== Language Syntax ===", .lines = &.{"  syntax-overview, if, case, let, lambda, operators"} } },        .{ "types", HelpTopic{ .title = "=== Types ===", .lines = &.{"  Bool, Nat, List, Pair, SuspendibleBool, Unit"} } },        .{ "stdlib", HelpTopic{ .title = "=== Standard Library ===", .lines = &.{ "  fst, snd, and, or, not, iff, given, geom, bgeom, randnat, randnatlist", "  inc, dec, add, +, mul, *, sub, -, mod, eq_nat, nat=?, lt_nat, <, gt_nat, >", "  le_nat, <=, ge_nat, >=, iseven, car, cdr, cdr_safe, isempty, fold, length", "  append, append_one, map, mapi, filter, filteri, range, zip_with, take, index", "  list_eq, list=?, any, all, constructors_equal, constructor=?, adt_eq, =?, ==", "  susp_list_eq, suspendible-list=?, int1=?, int2=?, int3=?, int4=?", "  head-or, float-of-nat, make-uniform, normalize-seq, sample-seq" } } },        .{ "commands", HelpTopic{ .title = "=== Commands ===", .lines = &.{"  :help, :quit, :reset, :defs, :type"} } },    });    return topics.get(name);}test "help_topics lists match getHelpTopic entries" {    for (help_topics.primitives) |name| try std.testing.expect(getHelpTopic(name) != null);    for (help_topics.queries) |name| try std.testing.expect(getHelpTopic(name) != null);    for (help_topics.syntax) |name| try std.testing.expect(getHelpTopic(name) != null);    for (help_topics.types) |name| try std.testing.expect(getHelpTopic(name) != null);    for (help_topics.stdlib) |name| try std.testing.expect(getHelpTopic(name) != null);    for (help_topics.commands) |name| try std.testing.expect(getHelpTopic(name) != null);}test "getHelpTopic returns null for unknown topic" {    try std.testing.expect(getHelpTopic("nonexistent") == null);}

Audit

Definitions3
Public names3
Members2
Version26.7.0
Revisiondaab053ee433