Library

class guppylang.library.GuppyLibrary(members: list[DefId])[source]

A collection of Guppy definitions that can be compiled together into a linkable unit exposing a public interface. Libraries can be created using static factory methods on this class.

from guppylang.library import GuppyLibrary

@guppy
def foo() -> int:
    return 42
@guppy
def bar() -> int:
    return 7

# Compilable collection containing `foo` and `bar`.
lib = GuppyLibrary.from_members(foo, bar)
check() None[source]

Type-check all contained definitions.

compile() Package[source]

Compile this collection of definitions into a HUGR package.

classmethod from_members(*members: GuppyDefinition) Self[source]

Decorator to attach a link name to a Guppy definition. It must be placed below the @guppy decorator.

from guppylang import guppy
from guppylang.library import link_name


@guppy.declare
@link_name("my_link_name")
def main() -> None:
    pass

main.compile()