builtwithbend
6 views in the last 24 hours
← Blog
11 min read Built with Bend

Bend 2 Packages: Find and Import

Find a Bend 2 package with JendHub, inspect its input type, and check a versioned import with a worked example tested on two compilers.

To use a Bend 2 package, find the function you need, inspect its source and input type, then copy its versioned import into a small program. Check that file before running it. This walkthrough follows a JendHub search to a byte-to-hex function and a known result, rather than stopping at an import line.

Built with Bend checked this example on October 18, 2026, with Bend 2.0.35 and 2.0.37 on Linux. Both returned "42656e64" for the ASCII text Bend. This is a worked example of one package, not a compatibility survey, performance benchmark or independent proof of its implementation.

The workflow is:

  1. Search for an operation, not just a package name.
  2. Read the definition and its input type.
  3. Copy the exact package version and file path.
  4. Check the program and compare its result with an expected value.

Confirm you are using Bend 2

You need an installed Bend 2 compiler, a terminal and a text editor. Start with bend version and bend guide; they identify the compiler and show its matching reference. The commands below follow the official 2.0.35 guide and 2.0.37 guide. They are not instructions for the older Bend 1/HVM toolchain.

From a package search to a checked example Search finds candidate definitions. Source inspection identifies the type and import. The local compiler checks the program. Comparing its output checks the example's result. Each stage answers a different question. Search: which definition might fit?Source: which type, version and file?Compiler: does this program check?Result: does this example agree? Built with Bend · checked October 18, 2026
A search result is a candidate. A checked, observed example answers a narrower question than package-wide compatibility.

1. Find a definition for your task

Suppose you want to display bytes as hexadecimal text. A package name alone does not tell you whether its function accepts a string, a linked list, an array or a custom byte buffer. Search for the operation first: hex encode bytes in JendHub.

JendHub searches definitions from Base and packages on BendHub. Its agent instructions describe searching in plain language and opening a result's source before choosing it. The text endpoint is useful for a terminal or agent; the website also provides a browser interface.

In the checked response, Bytes.to_hex appeared in more than one package. We selected the definition in bend-kit-bytes 0.3.2.0, rather than assuming that every result called to_hex was interchangeable. The result supplied a source link, a function signature and an import line. Search results change: the October 25 source review returned bend-kit-bytes 0.3.3.0. The worked example below still uses the originally tested 0.3.2.0; it is not a test of 0.3.3.0. Use the pinned source link below rather than replacing the import with the newest search result.

For broader browsing, Bend Packages is another discovery surface. It is a community catalog, not the compiler or official hub. Use a catalog to find a library, definition search to locate an operation, and the original sources to decide what to call. None of those steps replaces checking your own program.

2. Inspect the type before copying the call

JendHub’s current read endpoint can open older releases even when definition search indexes a newer one. Open the versioned Bytes source. Its to_hex definition takes the package's Bytes type and returns a String. The same file provides from_string, which constructs that byte buffer from a string. Its dependency comment identifies bend-kit-int 0.2.0.0, with a content-hash import for int.bend: this is not a dependency-free snippet.

Those details explain the complete expression used below. Bytes.from_string("Bend") produces the input expected by Bytes.to_hex. Passing "Bend" directly is a different program, even though the task sounds like “turn this text into hex.”

Keep this example ASCII. The reviewed from_string implementation keeps the low eight bits of each character. Do not treat it as a general UTF-8 encoder or substitute arbitrary Unicode text and expect this recipe to preserve the intended bytes. For non-ASCII data, identify the encoding you need and inspect the appropriate conversion before using the result.

Hex encoding is neither encryption nor hashing.

Also separate this exact package release from its wider source repository. A successful import of bend-kit-bytes@0.3.2.0 does not establish that every current bend-kit module works with the same compiler. The package version, compiler version and imported file are separate pieces of the reproduction.

3. Copy the version and file into a small program

Save the following as hex.bend. The import syntax comes from the official guides linked above; the package path and calls come from the versioned Bytes source. Built with Bend checked this complete example with both named compiler versions.

import Base
import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes

def main() -> String:
  Bytes.to_hex(Bytes.from_string("Bend"))

import Base supplies the standard library used by this example. Keep it alongside the separate third-party package import.

The package import names four things worth keeping together: package bend-kit-bytes, version 0.3.2.0, file bytes.bend, and the local alias Bytes. The alias is the name this file uses for imported definitions. It is not the compiler version and does not mean that a module with the same alias from another package has the same interface.

The official Modules reference also documents imports by content hash. A named, versioned import identifies a package through the hub; a hash import identifies its content directly. For this walkthrough, keep the returned named import intact. Do not guess a hash, shorten the version or replace the file path with the package name alone.

Bend fetches hub imports as part of loading them. The source shown by a search service is useful for inspection, but this example still uses the compiler's normal package import; it does not download code from JendHub into your project. An available source page is therefore not proof that your machine can reach every required package dependency.

4. Check first, then compare the result

The --help output from both tested compilers lists --check-only for checking without running a program. This command was exercised with the 2.0.35 and 2.0.37 releases. From the directory containing hex.bend, use:

bend hex.bend --check-only

For this file, the ordinary compiler check printed ALL PROOFS CHECK, followed by its reminder about --verdict. That message is not a report that we ran the independent kernel check. We did not use --verdict for this walkthrough, and a passing example does not prove all behavior of the package.

Next, run the file using the same compiler, following the guide's ordinary file invocation:

bend hex.bend

The observed result on both tested versions was "42656e64", including the displayed string quotes. The expected value was also checked independently with a standard hexadecimal conversion of the ASCII bytes for Bend. Keep a known input and expected output when trying another function; “it printed something” is a weak check.

Here main returns a value, so Bend normalizes that value and prints it, as described in the official guide. This is not a native-binary build, GPU run or speed test. It is enough to check that this small import-and-call example produces the expected result in the tested environments. Larger programs, IO, other package releases and other platforms need their own checks.

Troubleshooting questions

Why does the checker reject a string?

Read the failure before changing dependencies. During this walkthrough we deliberately replaced the inner conversion with a raw string. On both tested compilers, the check failed with expected Bytes.Bytes, observed String. Restoring Bytes.from_string("Bend") supplied the required type. A visible function name is not enough to determine its calling convention.

What should I check after an import error?

For an import or fetch error, compare the exact package name, version and path with the source you inspected. Then distinguish a failed network request from a compiler diagnostic. Do not silently substitute a different library and call the original example fixed. Record the compiler version and first error so you can reproduce the problem.

Why can my editor disagree with the terminal?

If the terminal succeeds but your editor complains, check which compiler or language server is producing the message. The Bend 2 editor and LSP guide explains why an installed compiler and an editor's bundled checker can differ. Reinstalling unrelated tools before identifying that boundary makes the result harder to explain.

Keep the reproduction small

When sharing a result, include the complete file, the output of bend version, the exact command and the first diagnostic or returned value. Separate the compiler's output from your interpretation. If you change the package version, input or imported file, mark that as a new case instead of overwriting the record of the working one.

Our check used the public search response and versioned source, then the ordinary local compiler. It did not test a deliberately empty package cache or measure network downloads. Repeated runs are therefore not evidence of cold-start behavior. Preserve that distinction if you use the example to investigate a fetch failure on another machine.

What to try next

Repeat the same process with an operation your project actually needs: search, inspect the signature and source, keep the exact import, and test a small known case. Inspect dependencies and data representation before expanding the example. A useful search result saves discovery work; it does not remove the need to understand the function.

For examples of larger applications and experiments, return to what people build with Bend 2. For this task, success is smaller and concrete: you found an existing definition, understood the input it expects, and checked a program that calls it. Keep that working file and its compiler version as your starting point.

Curated by LVTDBuilt for the people building.