### Install application package Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/pkg/package_index.md Builds and installs an application package binary into the local bin directory. ```console acton install PACKAGE ``` -------------------------------- ### Verbose build output example Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/compilation/incremental.md Example output from the acton build command showing staleness detection. ```text Stale a: source changed Stale c: impl changes in a.a (used by _test_foo) ``` -------------------------------- ### Serve documentation locally Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/README.md Use this command to start a local development server for the documentation. ```sh mdbook serve ``` -------------------------------- ### Syntax Transformation Example Source: https://github.com/actonlang/acton/blob/main/ecolift/CLAUDE.md Format for providing old versus new syntax examples. ```text Old syntax: "Hello " + name + "!" New syntax: f"Hello {name}!" ``` -------------------------------- ### Build.act Dependency Configuration Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/pkg/add_dependency.md Example of how a dependency is represented in the Build.act file after being added. ```python dependencies = { "foo": ( repo_url="https://github.com/actonlang/foo", repo_ref="main", url="https://github.com/actonlang/foo/archive/0123456789abcdef0123456789abcdef01234567.zip", hash="1220cd47344f8a1e7fe86741c7b0257a63567b4c17ad583bddf690eedd672032abdd", ), } zig_dependencies = {} ``` -------------------------------- ### Feature Description Example Source: https://github.com/actonlang/acton/blob/main/ecolift/CLAUDE.md Format for describing feature changes with concrete examples. ```text Added comprehensions: transform loops like `for x in items: result.append(x*2)` to `[x*2 for x in items]` ``` -------------------------------- ### Implement Protocols Source: https://github.com/actonlang/acton/blob/main/base/CLAUDE.md Example of implementing a protocol method for a type in C. ```c // Implement protocol for type static B_bool str_eq(B_str self, B_value other) { if (other->_class != &str_class) return B_False; return strcmp(self->data, ((B_str)other)->data) == 0 ? B_True : B_False; } ``` -------------------------------- ### Install a basic stdin handler Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/environment/stdin.md Registers a handler to receive input as a decoded string. ```acton actor main(env): def interact(input): print("Got some input:", input) env.stdin_install(interact) ``` -------------------------------- ### Importing Dependency Modules Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/pkg/add_dependency.md Example of importing and using a function from an added dependency. ```python import foo actor main(env): print(foo.foo()) env.exit(0) ``` -------------------------------- ### View test output Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/testing/async_actor_test.md Example output generated after running the test suite. ```sh Building project in /home/user/foo Compiling example.act for release Finished compilation in 0.028 s Final compilation step Finished final compilation step in 0.516 s Tests - module example: asyncact1: OK: 1171 runs in 56.181ms All 1 tests passed (0.695s) ``` -------------------------------- ### Example module source files Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/compilation/incremental.md Source files demonstrating a simple dependency chain where module c depends on module a. ```acton # a.act def apa() -> int: return 1 def a() -> int: return apa() ``` ```acton # c.act import a import testing def _test_foo() -> None: testing.assertEqual(a.a(), 1) ``` -------------------------------- ### Performance test output example Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/testing/perf_record.md Sample console output showing performance metrics and comparison percentages. ```sh Building project in /home/user/foo Compiling example.act for release Finished compilation in 0.017 s Final compilation step Finished final compilation step in 0.452 s Tests - module example: simple: OK: 3.25ms Avg: 4.16ms 7.38ms 122 runs in 1006.002ms All 1 tests passed (1.565s) Building project in /home/user/foo Compiling example.act for release Already up to date, in 0.000 s Final compilation step Finished final compilation step in 0.116 s Tests - module example: simple: OK: 3.23ms -0.50% Avg: 4.17ms +0.19% 6.35ms -13.91% 119 runs in 1001.375ms All 1 tests passed (1.215s) ``` -------------------------------- ### Output of higher order function example Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/functions/higher_order.md The expected console output from the apply_twice example. ```sh 12 16 ``` -------------------------------- ### Method Resolution Order (MRO) Examples Source: https://github.com/actonlang/acton/blob/main/workspace/Typesystem.txt Calculated MRO lists for various protocols and classes. ```text MRO(Eq) = [Eq] MRO(Ord) = [Ord,Eq] MRO(Rational) = [Rational] MRO(Integer) = [Integer,Rational] MRO(tt) = [tt] MRO(tt_1) = [tt_1,tt,Integer,Rational] MRO(tt_2) = [tt_2,tt_1,tt,Integer,Rational,Ord,Eq] MRO(tt_1) = [tt,Integer,Rational] MRO(tt_2) = [tt,Ord,Eq] ``` -------------------------------- ### Performance test output example Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/testing/performance.md Example output showing the timing results for a performance test run. ```sh Building project in /home/user/foo Compiling example.act for release Finished compilation in 0.016 s Final compilation step Finished final compilation step in 0.451 s Tests - module example: simple: OK: 3.21ms Avg: 4.20ms 5.11ms 106 runs in 1005.261ms All 1 tests passed (1.571s) ``` -------------------------------- ### Install Acton on Debian/Ubuntu Source: https://github.com/actonlang/acton/blob/main/README.md Use the official APT repository to install Acton on Debian or Ubuntu systems. ```sh sudo install -m 0755 -d /etc/apt/keyrings sudo wget -q -O /etc/apt/keyrings/acton.asc https://apt.acton-lang.io/acton.gpg sudo chmod a+r /etc/apt/keyrings/acton.asc echo "deb [signed-by=/etc/apt/keyrings/acton.asc arch=amd64] http://apt.acton-lang.io/ stable main" | sudo tee -a /etc/apt/sources.list.d/acton.list sudo apt-get update sudo apt-get install -qy acton ``` -------------------------------- ### Install Acton on RPM/DNF/YUM Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/install.md Adds the Acton RPM repository and installs the package using dnf or yum. ```console sudo rpm --import https://rpm.acton.now/acton.gpg sudo tee /etc/yum.repos.d/acton.repo >/dev/null <<'EOF' [acton] name=Acton baseurl=https://rpm.acton.now/$basearch enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://rpm.acton.now/acton.gpg EOF sudo dnf install -y acton ``` -------------------------------- ### Function Invocation and Tuple Unpacking Source: https://github.com/actonlang/acton/blob/main/workspace/Plan-scribble.txt Examples of function calls, tuple handling, and argument unpacking. ```Acton kalle(*None) p : struct((int,str)) p.f((1,""),7) def f(x) : bool f((1,"",pi)) : bool h : (int,str,float) -> bool h(1,"",pi) : bool x : (int,str,float) h(*x) g : (int) -> bool g(7) : bool x : T = (1,"",pi) x,y = f(a,b,c) ``` -------------------------------- ### Start and Exit the REPL Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/repl.md Launch the interactive shell and exit using the :quit command. ```console $ acton repl Welcome to InterActon, the interactive Acton REPL shell. Type :help for commands, :quit to exit. acton> 1 + 2 3 acton> :quit ``` -------------------------------- ### Install Acton on macOS Source: https://github.com/actonlang/acton/blob/main/README.md Install Acton using the Homebrew package manager. ```sh brew install actonlang/acton/acton ``` -------------------------------- ### Define base classes and types Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/types/troubleshooting.md Example module defining WorkItem, RunContext, and a Step base class. ```python # pipeline.act class WorkItem(object): title: str tags: set[str] output_path: str def __init__(self, title: str, tags: set[str], output_path: str): self.title = title self.tags = tags self.output_path = output_path class RunContext(object): run_id: str user: str def __init__(self, run_id: str, user: str): self.run_id = run_id self.user = user class Step(object): def apply(self, item: WorkItem, ctx: RunContext): raise NotImplementedError() ``` -------------------------------- ### Advanced optional chaining Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/types/optionals.md Examples of chaining method calls and indexing/slicing operations. ```acton def loud_residence_name(person: ?Person) -> ?str: return person?.residence?.name?.upper() def first_port(config: ?dict[str, list[int]]) -> ?int: return config?.get("ports")?[0] ``` -------------------------------- ### Define a Contact class Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/types/troubleshooting.md Example class definition in src/directory.act. ```python # src/directory.act class Contact(object): display_name: str email_addresses: list[str] def __init__(self, display_name: str, email_addresses: list[str]): self.display_name = display_name self.email_addresses = email_addresses ``` -------------------------------- ### Requesting Commit IDs Source: https://github.com/actonlang/acton/blob/main/ecolift/CLAUDE.md Example format for requesting specific commit IDs from the user. ```text Please provide the commit ID(s) that introduced this feature: abc123def ``` -------------------------------- ### Expected output of the re.match example Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/stdlib/re.md The console output produced by the matching operation. ```sh Got a match: foobar ``` -------------------------------- ### Define struct and class structures Source: https://github.com/actonlang/acton/blob/main/workspace/Plan-scribble.txt Examples of struct definitions with sync methods and class definitions with constructors. ```Acton struct(A): f : (A,int) -> bool d : (A) -> bool d : sync new (int) -> bool e : sync () -> None f : (a,b) -> () g : (a,b) -> None kalle : sync () -> None def kalle(): pass class C(): def __init__(self, x, y): self.x = x self.y = y def sum(self): return self.x + self.y ``` -------------------------------- ### Cleanup Execution Output Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/actors/cleanup.md Example output showing the cleanup action triggered for multiple actor instances. ```sh Cleaning up after myself... Cleaning up after myself... Cleaning up after myself... Cleaning up after myself... Cleaning up after myself... Cleaning up after myself... Cleaning up after myself... Cleaning up after myself... Cleaning up after myself... Cleaning up after myself... Cleaning up after myself... Cleaning up after myself... Cleaning up after myself... Cleaning up after myself... Cleaning up after myself... Cleaning up after myself... Cleaning up after myself... Cleaning up after myself... Cleaning up after myself... Cleaning up after myself... ``` -------------------------------- ### Define function implementation and type aliases Source: https://github.com/actonlang/acton/blob/main/workspace/Plan-scribble.txt Example of a function implementation and a type alias definition. ```Acton def fun2(x:int, y:int, z:bool) -> bool: c = (a,b) = f(3) return z type apa(A) = (A,B) -> {A:B} ``` -------------------------------- ### Running Batch Debugging Sessions Source: https://github.com/actonlang/acton/blob/main/utils/lldb/README.md Examples of executing LLDB commands in batch mode for automated debugging tasks. ```text lldb examples/stackdemo -o 'command script import utils/lldb/acton.py' -o 'b stackdemo.act:7' -o 'run' -o 'acton locals' -o 'acton bt' --batch ``` ```text lldb -o 'command script import utils/lldb/acton.py' -o 'br s -r "stackdemoQ_.*"' -o run -- examples/stackdemo ``` -------------------------------- ### Define Hashable and Eq protocols Source: https://github.com/actonlang/acton/blob/main/workspace/Type-hierarchy.txt Example syntax for defining protocols to express hashability and equality in Acton. ```Acton protocol Hashable (Eq): __hash__ : () -> int protocol Eq: @staticmethod __eq__ : (Self,Self) -> bool @staticmethod __ne__ : (Self,Self) -> bool def __ne__(a,b): return not (a == b) ``` -------------------------------- ### Verbose Build Output for Deferred Back Passes Source: https://github.com/actonlang/acton/blob/main/docs/acton-dev-guide/src/compiler/incremental_compilation.md Example output from running the Acton build command with the verbose flag, showing dependency resolution and stale module detection. ```text $ acton build --verbose Building project in /path/proj Resolving dependencies (fetching if missing)... Stale a: source changed Hash deltas a: ~foo{src 12fa0b1c -> 3e3485be, impl 4bf97616 -> f736da16} Finished type check of /path/proj/a 0.004 s Stale b: impl changes in a.foo 4bf97616 -> f736da16 (used by bar) Finished compilation of /path/proj/a 0.002 s Finished compilation of /path/proj/b 0.003 s ``` -------------------------------- ### Generate Hash for a Value Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/stdlib/builtin_protocols/hashable.md Example of creating a hasher and generating a hash for a custom type instance. ```acton p = Point(10, 20) h = hash(p) print("hash:", h) ``` -------------------------------- ### Example Acton test output Source: https://github.com/actonlang/acton/blob/main/docs/acton-dev-guide/src/getting_started/tests.md Sample output showing test results for an Acton project. ```text $ acton test Building project in /path/to/project Final compilation step Finished final compilation step in 0.462 s Test results: c.bar: OK: 445 runs in 50.160ms c.foo: OK: 444 runs in 50.188ms All 2 tests passed ( 0.528 s) ``` -------------------------------- ### Example .tydb Key Structure Source: https://github.com/actonlang/acton/blob/main/docs/acton-dev-guide/src/compiler/interface_caches.md A representation of the keys used in a .tydb file for a module containing encode and decode definitions. ```text name-count -> 2 stmt-count -> 2 name-order/000000000000 -> p/encode name-info/p/encode -> (Name "encode", NameInfo for encode) name-order/000000000001 -> p/decode name-info/p/decode -> (Name "decode", NameInfo for decode) name-hash/p/decode -> NameHashInfo for decode name-hash/p/encode -> NameHashInfo for encode deps -> dependency modules and module hashes deps/__builtin__ -> dependency names and name hashes deps/__builtin__/p/bytes -> local names using __builtin__.bytes stmt/000000000000 -> typed Stmt for encode stmt/000000000001 -> typed Stmt for decode ``` -------------------------------- ### Establish a TCP connection using capabilities Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/security/capabilities.md Demonstrates initializing a TCP connection by narrowing the root WorldCap to a specific TCPConnectCap. ```acton import net actor main(env): def on_connect(c): c.close() def on_receive(c, data): pass def on_error(c, msg): print("Client ERR", msg) connect_cap = net.TCPConnectCap(net.TCPCap(net.NetCap(env.cap))) client = net.TCPConnection(connect_cap, env.argv[1], int(env.argv[2]), on_connect, on_receive, on_error) ``` -------------------------------- ### Implement Hashable Protocol with Subclassing Source: https://github.com/actonlang/acton/blob/main/workspace/Type-hierarchy.txt Example of a class implementing the Hashable protocol and a subclass overriding the hash method. ```Acton class MyClass (Hashable): def __eq__(a, b): return hash(a) == hash(b) def hash(self): return cheap_hash(self) def my_method(self): return hash(self) class MySubClass (MyClass): def hash(self): return expensive_hash(self) ``` -------------------------------- ### Run the project Source: https://github.com/actonlang/acton/blob/main/test/compiler/mixed-dots/README.org Execute the compiled binary located in the output directory. ```shell out/bin/rebuild ``` -------------------------------- ### Example output of environment variable operations Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/environment/variables.md Shows the expected console output after executing the environment variable manipulation code. ```sh User: myuser FOO: bar ``` -------------------------------- ### Define a Pure Acton Module Source: https://github.com/actonlang/acton/blob/main/base/CLAUDE.md Example of defining functions and classes within a pure Acton source file. ```acton # src/mymodule.act def my_function(x: int) -> int: return x * 2 class MyClass: def method(self) -> str: return "hello" ``` -------------------------------- ### Define Zig dependencies in build.zig.zon Source: https://github.com/actonlang/acton/blob/main/docs/acton-dev-guide/src/compiler/project_dependencies.md Example showing how Acton generates separate entries for Zig dependencies with different build options. ```zig .dependencies = .{ .tls_a = .{ ... }, .tls_b = .{ ... }, .acton_zig_mbedtls = .{ ... }, // options { .pic = true } .acton_zig_mbedtls_2 = .{ ... }, // options { .pic = false } }, ``` -------------------------------- ### Hello World with Command Line Arguments Source: https://github.com/actonlang/acton/blob/main/docs/tutorial/example-0.md Accesses command line arguments via the env.argv list to greet a specific name. ```acton actor main(env): print("Hello, " + env.argv[1] + "!") ``` -------------------------------- ### Implementation-only change example Source: https://github.com/actonlang/acton/blob/main/docs/acton-dev-guide/src/compiler/incremental_compilation.md Demonstrates how changing a function body affects hashes and triggers back passes without requiring re-typechecking of downstream modules. ```acton # a.act def foo(x: int) -> int: return x + 1 # b.act import a def bar() -> int: return a.foo(1) ``` ```acton # a.act def foo(x: int) -> int: return x + 2 ``` -------------------------------- ### Perform Top-Level Assignments Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/repl.md Top-level assignments are replayed as setup code, allowing for effectful operations like actor creation. ```python acton> actor Foo(): ... print("hello from Foo") ... acton> f = Foo() hello from Foo ``` -------------------------------- ### Initialize and retrieve Data Source: https://github.com/actonlang/acton/blob/main/compiler/lib/test/doc-golden/bar.txt Demonstrates creating a Data instance and accessing its stored value. ```python >>> d = Data("hello", "test-data") >>> d.get_value() "hello" ``` -------------------------------- ### Build and Test Commands Source: https://github.com/actonlang/acton/blob/main/backend/CLAUDE.md Standard commands for building the backend and executing tests. ```bash # Build backend (part of main build) make # Run backend tests make test-backend # Build standalone cd backend && zig build ``` -------------------------------- ### Uninstall application package Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/pkg/package_index.md Removes an installed application package. ```console acton uninstall PACKAGE ``` -------------------------------- ### Default build process Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/compilation.md Shows the build output when compiling for the local platform using prebuilt libraries. ```bash $ acton helloworld.act Building file helloworld.act Compiling helloworld.act for release Finished compilation in 0.013 s Final compilation step Finished final compilation step in 0.224 s $ ``` -------------------------------- ### Install a raw bytes stdin handler Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/environment/stdin.md Registers a handler to receive raw bytes, useful for binary data or delayed decoding. ```acton actor main(env): def interact(bytes_input): # Decode only when this code is ready to decide how. print("Got some input:", bytes_input.decode()) env.stdin_install(on_stdin_bytes=interact) ``` -------------------------------- ### Create a new Acton project Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/projects.md Initialize a new project directory structure using the acton CLI. ```console acton new foo ``` -------------------------------- ### Install a stdin handler with explicit encoding and error handling Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/environment/stdin.md Configures stdin processing with specific encoding and a custom error handler for decoding failures. ```acton actor main(env): def interact(input): print("Got some input:", input) def on_stdin_error(err, data): print("Some error with decoding the input data:", err) print("Raw bytes data:", data) env.stdin_install(on_stdin=interact, encoding="utf-8", on_error=on_stdin_error) ``` -------------------------------- ### Generate Documentation via CLI Source: https://github.com/actonlang/acton/blob/main/compiler/CLAUDE.md Run documentation generation for specific files or the entire project. ```bash acton doc src/basics.act # Whole project acton doc ``` -------------------------------- ### Importing Modules and Names Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/modules.md Demonstrates various import styles including direct module imports, aliasing, and importing specific names. ```acton import time import time as timmy from time import now from time import now as rightnow actor main(env): print(time.now()) print(timmy.now()) print(now()) print(rightnow()) env.exit(0) ``` -------------------------------- ### Demonstrating Build Cache Performance Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/compilation.md Shows the difference in compilation time between an initial build and a subsequent build using the cache. ```bash $ acton new hello Created project hello Enter your new project directory with: cd hello Compile: acton build Run: ./out/bin/hello Initialized empty Git repository in /home/kll/hello/.git/ $ cd hello/ $ acton build --target native Building project in /home/kll/hello Compiling hello.act for release Finished compilation in 0.012 s Final compilation step Finished final compilation step in 6.120 s $ acton build --target native Building project in /home/kll/hello Compiling hello.act for release Already up to date, in 0.000 s Final compilation step Finished final compilation step in 0.068 s $ ``` -------------------------------- ### Initialize External C Module Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/ext/integrating_c_library.md Every external module requires a __ext_init__ function that runs when the module is loaded. ```c void zlibQ___ext_init__() {} ``` -------------------------------- ### Build and Test Source: https://github.com/actonlang/acton/blob/main/ecolift/CLAUDE.md Verify changes by building and running tests within the repository. ```bash acton build acton test ``` -------------------------------- ### Visualize the actor tree Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/actors/root.md A diagram representing the hierarchical structure of actors starting from the root. ```bob .────. ( root ) `----' / \ / \ V V .─. .─. ( A ) ( B )---+ `-' `-' \ / \ | \ \ / \ | \ \ V V V V V .─. .─. .─. .─. .─. ( 1 ) ( 2 ) ( 3 ) ( 4 ) ( 5 ) `─' `─' `─' `─' `─' ``` -------------------------------- ### Compiling and running an Acton program with arguments Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/hello/args.md Compile the source file and execute the resulting binary with a command-line argument. ```sh acton hello.act ./hello Johan ``` -------------------------------- ### Define an interactive actor Source: https://github.com/actonlang/acton/blob/main/docs/tutorial/example-1.md An actor that installs a callback on stdin to process user input interactively. ```py actor harmonicMain2(env): def response(input): print(harmonic(int(input))) env.stdin_install(response) ``` -------------------------------- ### Display RTS help options Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/rts.md Use the --rts-help flag to list all available configuration options for the Acton RTS. ```sh $ acton examples/helloworld.act Building file examples/helloworld.act Compiling helloworld.act for release Finished compilation in 0.012 s Final compilation step Finished final compilation step in 0.198 s $ examples/helloworld --rts-help The Acton RTS reads and consumes the following options and arguments. All other parameters are passed verbatim to the Acton application. Option arguments can be passed either with --rts-option=ARG or --rts-option ARG --rts-bt-dbg Interactively debug on SIGILL / SIGSEGV --rts-debug RTS debug, requires program to be compiled with --optimize Debug --rts-ddb-host=HOST DDB hostname --rts-ddb-port=PORT DDB port [32000] --rts-ddb-replication=FACTOR DDB replication factor [3] --rts-node-id=ID RTS node ID --rts-rack-id=RACK RTS rack ID --rts-dc-id=DATACENTER RTS datacenter ID --rts-host=RTSHOST RTS hostname --rts-help Show this help --rts-mon-log-path=PATH Path to RTS mon stats log --rts-mon-log-period=PERIOD Periodicity of writing RTS mon stats log entry --rts-mon-on-exit Print RTS mon stats to stdout on exit --rts-mon-socket-path=PATH Path to unix socket to expose RTS mon stats --rts-no-bt Disable automatic backtrace --rts-log-path=PATH Path to RTS log --rts-log-stderr Log to stderr in addition to log file --rts-verbose Enable verbose RTS output --rts-wthreads=COUNT Number of worker threads [#CPU cores] $ ``` -------------------------------- ### Define collection types Source: https://github.com/actonlang/acton/blob/main/workspace/Plan-scribble.txt Examples of literal syntax for lists, dictionaries, and sets with their corresponding types. ```Acton [1,2,3] : [int] {'x':1,'y':2} : {str:int} {1,2,3} : {int} [1,2,3] : frozenlist(int) {'x':1,'y':2} : frozendict(str,int) {1,2,3} : frozenset(int) [1,2,3] : list(int) {'x':1,'y':2} : dict(str,int) {1,2,3} : set(int) [1,2,3] : A(int) \ IsList(A) {'x':1,'y':2} : A(str,int) \ IsDict(A) {1,2,3} : A(int) \ IsSet(A) list([1,2,3]) : list(int) list(x) : list(int) list : (A(B)) -> list(B) \ IsList(A) frozenlist : (A(B)) -> frozenlist(B) \ IsList(A) frozenlist : A(B) -> frozenlist(B) \ IsList(A) [1,2,3] : list(int) {'x':1,'y':2} : dict(str,int) {1,2,3} : set(int) [1,2,3] : list(int) {'x':1,'y':2} : dict(str,int) {1,2,3} : set(int) ![1,2,3] : list(int) !{'x':1,'y':2} : dict(str,int) !{1,2,3} : set(int) mut([1,2,3]) : list(int) mut({'x':1,'y':2}) : dict(str,int) mut({1,2,3}) : set(int) ``` -------------------------------- ### Define function signatures and types Source: https://github.com/actonlang/acton/blob/main/workspace/Plan-scribble.txt Examples of function type signatures and dictionary type definitions. ```Acton fun1 : (int) -> (float,float) -> str fun2 : (int,int,bool) -> bool fun3 : (int,int,bool) -> (int,int) fun4 : ((int,int),bool) -> (int,int) fun5 : ((int,int,bool)) -> (int,int) fun6 : (int,(int,),bool) -> str fun7 : () -> str dict1 : {str:(float,float)} dict2 : {(int,str):apa} ``` -------------------------------- ### Execute Build Commands Source: https://github.com/actonlang/acton/blob/main/base/CLAUDE.md Common commands for building the base library, running standard library tests, and building specific modules. ```bash # Build base (included in main build) make # Run stdlib tests make test-stdlib # Build specific module cd base && zig build ``` -------------------------------- ### Attempt to delete an unmerged branch Source: https://github.com/actonlang/acton/blob/main/docs/git-feature-workflow.md Example output when attempting to delete a branch that has not been merged into main. ```bash kll@Boxy:~/terastream/acton$ git branch -d add-git-develop-workflow-cheat-sheet error: The branch 'add-git-develop-workflow-cheat-sheet' is not fully merged. If you are sure you want to delete it, run 'git branch -D add-git-develop-workflow-cheat-sheet'. kll@Boxy:~/terastream/acton$ ``` -------------------------------- ### Delete a merged local branch Source: https://github.com/actonlang/acton/blob/main/docs/git-feature-workflow.md Example output when deleting a branch that is fully merged into main. ```bash kll@Boxy:~/terastream/acton$ git branch -d regression-actor-method-call-not-async Deleted branch regression-actor-method-call-not-async (was 1a34a28). kll@Boxy:~/terastream/acton$ ``` -------------------------------- ### Clone Repository Source: https://github.com/actonlang/acton/blob/main/ecolift/CLAUDE.md Initial step to clone a repository into the local workspace. ```bash cd ecolift/repos git clone cd ``` -------------------------------- ### Build and Run Dynamic Module Prototype Source: https://github.com/actonlang/acton/blob/main/test/compiler/dynamic_module/README.md Commands to build the dynamic library and executable, verify the library linkage, and test hot-reloading by modifying the source. ```sh acton build --color never src/b.act ./out/bin/b otool -L out/bin/b # Edit src/a.act to return a different string. acton build --color never src/a.act ./out/bin/b ``` -------------------------------- ### Simple if/else Conditional Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/control_flow/if_else.md A basic example showing a parity check using an if/else block. ```acton n = 7 if n % 2 == 0: print("even") else: print("odd") ``` -------------------------------- ### Define and implement a protocol Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/protocols/intro.md Demonstrates defining a protocol with a generic type parameter and implementing it for a class using an extension. ```acton protocol Processable[T]: process : () -> T class Message(object): def __init__(self, text): self.text = text extension Message(Processable[str]): def process(self): return self.text.upper() ``` -------------------------------- ### Actor Execution Output Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/actors/concurrency.md Example output showing interleaved execution of two concurrent actors. ```text I am Foo and I have counted to 0 I am Bar and I have counted to 0 I am Foo and I have counted to 1 I am Bar and I have counted to 1 I am Foo and I have counted to 2 I am Bar and I have counted to 2 I am Foo and I have counted to 3 I am Bar and I have counted to 3 I am Foo and I have counted to 4 I am Bar and I have counted to 4 I am Bar and I have counted to 5 I am Foo and I have counted to 5 I am Bar and I have counted to 6 I am Foo and I have counted to 6 I am Bar and I have counted to 7 I am Foo and I have counted to 7 I am Foo and I have counted to 8 I am Bar and I have counted to 8 I am Foo and I have counted to 9 I am Bar and I have counted to 9 ``` -------------------------------- ### Project build and execution output Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/projects.md Standard output displayed after creating a new project, showing build and run commands. ```console Created project foo Enter your new project directory with: cd foo Compile: acton build Run: ./out/bin/foo ``` -------------------------------- ### Add a C library dependency Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/ext/integrating_c_library.md Use the acton zig-pkg add command to fetch a C library and specify the artifact name for linking. ```console acton zig-pkg add https://github.com/allyourcodebase/zlib/archive/refs/tags/1.3.1.tar.gz zlib --artifact z ``` -------------------------------- ### Applying functions as arguments Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/functions/higher_order.md Demonstrates passing functions as arguments to another function to reuse logic with different operations. ```acton def apply_twice(fun, value): return fun(fun(value)) def double(n): return 2 * n def square(n): return n * n actor main(env): print(apply_twice(double, 3)) print(apply_twice(square, 2)) env.exit(0) ``` -------------------------------- ### Importing the Acton LLDB Plugin Source: https://github.com/actonlang/acton/blob/main/utils/lldb/README.md Commands to load the plugin into an active LLDB session or automatically on startup. ```text (lldb) command script import /absolute/path/to/acton/utils/lldb/acton.py ``` ```text (lldb) command script import -r /absolute/path/to/acton/utils/lldb/acton.py ``` -------------------------------- ### Implement C Functions Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/ext/integrating_c_library.md Implement the C functions in src/zlib.ext.c to match the Acton function signatures. ```c B_bytes zlibQ_compress (B_bytes data) { return data; } B_bytes zlibQ_decompress (B_bytes data) { return data; } ``` -------------------------------- ### Define a test function for performance measurement Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/testing/perf_record.md Example test function used to generate performance data. ```python import testing def _test_simple(): a = 0 for i in range(99999): a += i ``` -------------------------------- ### Basic Hello World Actor Source: https://github.com/actonlang/acton/blob/main/docs/tutorial/example-0.md Defines a root actor named main that prints a message to the console. ```acton actor main(env): print("Hello, World!") ``` -------------------------------- ### View flaky test output Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/testing/flaky.md Example output showing a test marked as flaky after multiple iterations. ```sh Building project in /home/user/foo Compiling example.act for release Finished compilation in 0.017 s Final compilation step Finished final compilation step in 0.453 s Tests - module example: flaky: FLAKY FAIL: 565 failures out of 1140 runs in 50.043ms testing.NotEqualError: Expected equal values but they are non-equal. A: 1 B: 2 1 out of 1 tests failed (0.625s) ``` -------------------------------- ### Manage Dependencies Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/repl.md Add external library packages to the REPL session using the :dep command. ```console acton> :dep add textfsm Added dependency textfsm ``` -------------------------------- ### Define a flaky test case Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/testing/flaky.md This example demonstrates a test that fails non-deterministically due to random behavior. ```python import random import testing def _test_flaky(): i = random.randint(0, 2) if i == 0: return elif i == 1: testing.assertEqual(1, 2) else: raise ValueError("Random failure") ``` -------------------------------- ### Signature change staleness output Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/compilation/incremental.md Example output indicating that a public signature change has triggered re-evaluation. ```text Stale c: pub changes in a.a (used by _test_foo) ``` -------------------------------- ### Compile and Run Acton Program Source: https://github.com/actonlang/acton/blob/main/README.md Compile the source file and execute the resulting binary. ```sh $ acton helloworld.act $ ./helloworld Hello, world! ``` -------------------------------- ### Create Data Instance Source: https://github.com/actonlang/acton/blob/main/compiler/lib/test/doc-golden/foo-color.txt Demonstrates creating a new bar.Data instance using the create_data function. ```python >>> d = create_data("test") >>> d.get_value() "test" ``` -------------------------------- ### Build Project via CLI Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/ext/integrating_c_library.md Use the acton build command to compile the project and generate necessary skeletons. ```console user@host$ acton build ... some large error message ``` ```console user@host:~/acton-zlib$ acton build Building project in /Users/user/acton-zlib Compiling zlib.act for release Finished compilation in 0.005 s Compiling test_zlib.act for release Finished compilation in 0.019 s Final compilation step user@host:~/acton-zlib$ ``` -------------------------------- ### Essential Acton Build Commands Source: https://github.com/actonlang/acton/blob/main/CLAUDE.md Use these make and CLI commands to build the compiler, run tests, and manage Acton projects. ```bash make # Build everything make dist/bin/acton # Build only the compiler (faster when working on compiler) make test # Run all tests make test-compiler # Run compiler tests only dist/bin/acton build # Build an Acton project dist/bin/acton test # Test an Acton project ``` -------------------------------- ### Call harmonic function in Python Source: https://github.com/actonlang/acton/blob/main/docs/tutorial/example-1.md Example of a valid function call in Python's dynamic typing system. ```py harmonic(3) ``` -------------------------------- ### Run performance testing commands Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/testing/perf_record.md Commands to record initial performance data and perform subsequent comparisons. ```sh acton test perf --record acton test perf ``` -------------------------------- ### Restore a deleted remote-tracked branch Source: https://github.com/actonlang/acton/blob/main/docs/git-feature-workflow.md Example output when checking out a branch that was previously deleted locally but exists on the remote. ```bash kll@Boxy:~/terastream/acton$ git checkout warnings-as-errors Branch 'warnings-as-errors' set up to track remote branch 'warnings-as-errors' from 'origin'. Switched to a new branch 'warnings-as-errors' kll@Boxy:~/terastream/acton$ ``` -------------------------------- ### Execute churn loops Source: https://github.com/actonlang/acton/blob/main/docs/acton-dev-guide/src/runtime/io_memory.md Repeatedly runs a test binary to catch intermittent crashes. ```bash for i in $(seq 40); do ./out/bin/.test_test_net_tls test; done ``` -------------------------------- ### Build and Test Commands Source: https://github.com/actonlang/acton/blob/main/compiler/CLAUDE.md Common shell commands for building the compiler, running tests, and profiling. ```bash # Build just the compiler (fastest iteration) make dist/bin/acton # Run compiler tests make test-compiler # Run specific test suite cd compiler && stack test --test-arguments "--filter pattern" # Build with profiling cd compiler && stack build --profile ``` -------------------------------- ### Define a unit test in Acton Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/testing/unit_test.md Define a test function starting with '_test_' using the testing module for assertions. ```python import testing def _test_simple(): foo = 3+4 testing.assertEqual(7, foo) ``` -------------------------------- ### Define dependencies in Build.act Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/pkg/override_dependency.md The configuration file specifies the default URL and hash for project dependencies. ```python dependencies = { "foo": ( url="https://github.com/actonlang/foo/archive/refs/tags/v1.0.zip", hash="1220cd47344f8a1e7fe86741c7b0257a63567b4c17ad583bddf690eedd672032abdd", ), } zig_dependencies = {} ``` -------------------------------- ### Range iteration Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/control_flow/for.md Use range() to iterate a specific number of times or with custom start, stop, and step values. ```acton for n in range(5): print(n) ``` ```acton for n in range(2, 10, 2): print(n) ``` -------------------------------- ### Run Acton via Docker Source: https://github.com/actonlang/acton/blob/main/README.md Execute Acton commands using the official container image without local installation. ```sh docker run --rm ghcr.io/actonlang/acton:latest version docker run --rm -v "$PWD":/work -w /work ghcr.io/actonlang/acton:latest build ``` -------------------------------- ### Create a release branch Source: https://github.com/actonlang/acton/blob/main/CLAUDE.md Use this command to initiate a new release branch with the required version prefix. ```bash git checkout -b release-v0.26.0 ``` -------------------------------- ### Define generic types and higher-order functions Source: https://github.com/actonlang/acton/blob/main/workspace/Plan-scribble.txt Examples of generic type usage and function signatures involving higher-order types. ```Acton f : (A) -> Apa(A) \ Hashable(A) g : (int) -> Apa(int) fun13 : (Apa(int),(int)->str) -> Apa(str) fun14 : (Apa(A),(A)->B) -> Apa(B) fun15 : ((apa:[A],bepa:{int:A}), (A)->B) -> (apa:[A],bepa:{int:B}) ``` -------------------------------- ### Counter implementation using Class and Actor Source: https://github.com/actonlang/acton/blob/main/docs/tutorial/example-3.md Side-by-side comparison of a counter implemented as a class and as an actor, including usage examples for both. ```py class CounterC(): actor CounterA(initval=0): def __init__(self,initval=0): var val = initval self._val = initval def inc(self): def inc(): self._val += 1 val += 1 def read(self): def read(): return self._val return val def reset(self): def reset(): self._val = 0 val = 0 actor main(env): actor main(env) c = CounterC(5) a = CounterA(5) c.inc() a.inc() c.inc() a.inc() v = c.read() v = a.read() print(v) # prints 7 print(v) # prints 7 ``` -------------------------------- ### Setting Executable Permissions and Running Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/hello/shebang.md Use chmod to make the Acton file executable, then run it directly from the terminal. ```console chmod a+x hello.act ./hello.act ``` -------------------------------- ### Define Fruit Class Hierarchy with Eq Protocol Source: https://github.com/actonlang/acton/blob/main/workspace/Type-hierarchy.txt Demonstrates implementing the Eq protocol for a base class and its specializations using static __eq__ methods. ```Acton class Fruit (Eq): ... def __eq__(a, b): return a.weight == b.weight class Apple (Fruit): ... def __eq__(a, b): return Fruit.__eq__(a,b) and a.appleness == b.appleness class Orange (Fruit): ... def __eq__(a, b): return Fruit.__eq__(a,b) and a.orangeness == b.orangeness ``` -------------------------------- ### Import and use Contact class Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/types/troubleshooting.md Example usage in src/main.act that triggers a type error due to an incorrect attribute name. ```python # src/main.act from directory import Contact def email_count(contact: Contact) -> int: return len(contact.email_address) ``` -------------------------------- ### Delete a branch pushed to remote but not merged Source: https://github.com/actonlang/acton/blob/main/docs/git-feature-workflow.md Example output when deleting a branch that exists on the remote but is not merged into the local HEAD. ```bash kll@Boxy:~/terastream/acton$ git branch -d warnings-as-errors warning: deleting branch 'warnings-as-errors' that has been merged to 'refs/remotes/origin/warnings-as-errors', but not yet merged to HEAD. Deleted branch warnings-as-errors (was 60703e6). kll@Boxy:~/terastream/acton$ ``` -------------------------------- ### Search for packages Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/pkg/package_index.md Searches the package index for available libraries. ```console acton pkg search PACKAGE ``` -------------------------------- ### Stress test status output Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/testing/stress.md Example of the live status line displayed in an interactive terminal during a stress test run. ```txt racy_sum: RUN : 2400 runs in 1500.000ms @ 1600.0/s | workers=8 (sync=2 drift=6) iter~2.340ms coarse~0.037ms sweep=64 cov=37/64(57.8pct) ``` -------------------------------- ### REPL Command Reference Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/repl.md List of available commands for the interactive shell. ```console :help Show REPL help :quit, :q Exit :reset Clear retained imports, definitions, setup, and dependencies :show Show retained session source :dep list Show online package dependencies :dep add NAME Add an online package dependency :dep rm NAME Remove an online package dependency ``` -------------------------------- ### Create a Hello World Actor Source: https://github.com/actonlang/acton/blob/main/README.md Define a basic actor in Acton that prints a message and exits. ```Acton actor main(env): print("Hello, world!") env.exit(0) ``` -------------------------------- ### Define a Test Case for List Comprehension Source: https://github.com/actonlang/acton/blob/main/compiler/CLAUDE.md Example of a test case written in Acton to verify list comprehension functionality. ```haskell -- AI writes test cases based on requirements -- Human reviews and approves test suite -- Example: test/comprehensions/generic_test.act def test_generic_list_comp(): result = [x * 2 for x in [1, 2, 3]] testing.assertEqual(result, [2, 4, 6]) ``` -------------------------------- ### re.match(pattern, string, start_pos=0) Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/stdlib/re.md Attempts to match a regular expression pattern against a string, optionally starting from a specific index. ```APIDOC ## re.match(pattern, string, start_pos=0) ### Description Matches the provided regular expression pattern against the input string. Returns a match object if successful, or None if no match is found. ### Parameters - **pattern** (string) - Required - The regular expression pattern to match. - **string** (string) - Required - The string to search within. - **start_pos** (int) - Optional - The index at which to begin scanning (defaults to 0). ``` -------------------------------- ### Compile and execute an Acton program Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/hello.md Use the acton compiler to build the source file and then run the resulting binary. ```console acton hello.act ./hello ``` -------------------------------- ### Perform basic float arithmetic and formatting Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/primitives/float.md Demonstrates defining float variables, performing division, rounding, and string formatting. ```acton actor main(env): distance = 12.5 time = 4.0 speed = distance / time print("speed:", speed) print("rounded:", round(speed, 2)) print("formatted: %.2f" % speed) env.exit(0) ``` -------------------------------- ### Inspect snapshot differences Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/testing/snapshot.md Use standard diff tools to compare the expected and output snapshot files. ```sh diff -u snapshots/expected/main/rendered_profile snapshots/output/main/rendered_profile ``` -------------------------------- ### Non-propagating Change Example Source: https://github.com/actonlang/acton/blob/main/docs/acton-dev-guide/src/compiler/incremental_compilation.md Shows a change that triggers local re-compilation but does not affect downstream modules because public hashes remain unchanged. ```acton # before (b.act) import a def bar() -> int: return a.foo() # after (b.act) import a import testing # unused def bar() -> int: return a.foo() ``` -------------------------------- ### Run tests with capabilities Source: https://github.com/actonlang/acton/blob/main/docs/acton-guide/src/testing.md Enable specific capabilities when running tests. ```sh acton test --tag external-service ``` -------------------------------- ### Define a Module with C Extension Source: https://github.com/actonlang/acton/blob/main/base/CLAUDE.md Example of declaring an external function in Acton and implementing it in C using the Acton C API. ```acton # src/mymodule.act # C functions are declared as external def native_function(x: int) -> int: NotImplemented ``` ```c // src/mymodule.ext.c #include B_int native_function(B_int x) { return intFromInt(asInt(x) * 2); } ``` -------------------------------- ### Run proxy tests Source: https://github.com/actonlang/acton/blob/main/test/proxy/README.md Execute the proxy test suite using make or directly via the run script. ```bash make test-proxy ``` ```bash ACTON_DIST=/path/to/dist bash test/proxy/run.sh # test a specific dist DOCKER_DEFAULT_PLATFORM=linux/amd64 bash test/proxy/run.sh # cross-arch (emulated) ``` -------------------------------- ### Call harmonic function with invalid argument in Python Source: https://github.com/actonlang/acton/blob/main/docs/tutorial/example-1.md Example of a function call that triggers a TypeError at runtime due to dynamic type checking. ```py harmonic(7.5) ```