componentized/directory

Synthetic sample. This package shows how the directory renders each WIT feature. It isn't published to any registry.

kitchen-sink:extras

interface

Uses and includes items from another package. Synthetic: not published to any registry.

Uses and includes items from another package.

A synthetic package: it isn't published to any registry.

Interfaces

  • greeter — Uses types from another package, one under a new name.

Worlds

greeting

Includes a world from another package, and imports one of its interfaces.

Imports

WIT

/// Uses and includes items from another package.
///
/// A synthetic package: it isn't published to any registry.
package kitchen-sink:extras@0.1.0;

/// Uses types from another package, one under a new name.
interface greeter {
  use kitchen-sink:types/shapes@0.1.0.{point, direction as heading};
  use kitchen-sink:types/resources@0.1.0.{canvas};

  /// Greets a point, facing a heading.
  greet: func(name: string, at: point, facing: heading) -> string;

  /// Draws a greeting.
  draw: func(on: borrow<canvas>, name: string);
}

/// Includes a world from another package, and imports one of its interfaces.
world greeting {
  import kitchen-sink:types/gates@0.1.0;
  /// An interface under a name of its own.
  import pictures: kitchen-sink:types/resources@0.1.0;
  /// An inline interface.
  import inline: interface {
    use kitchen-sink:types/shapes@0.1.0.{point};

    ping: func(at: point) -> bool;
  }
  use kitchen-sink:types/shapes@0.1.0.{direction};

  /// A type defined in the world.
  type compass = direction;

  /// A world-level resource.
  resource session {
    constructor();
    end: func();
  }
  /// A function.
  import log: func(message: string);
  /// An async function.
  import sleep: async func(ms: u64);
  /// A property of the world.
  import volume: get() -> u8;
  import volume: set(value: u8);

  export run: func(args: list<string>) -> result;
  export greeter;
}