componentized

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

world kitchen-sink:extras/greeting@0.1.0

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

Imports

interface inline

An inline interface.

use record point

from kitchen-sink:types/shapes@0.1.0

A point on a plane.

  • x: f64

    Across.

  • y: f64

    Down.

functionping: func(at: point) -> bool

use enum direction

from kitchen-sink:types/shapes@0.1.0

The cardinal directions.

  • north
  • east
  • south
  • west

type compass

A type defined in the world.

resource session

A world-level resource.

  • constructor functionconstructor()
  • functionend: func()

functionlog: func(message: string)

A function.

async functionsleep: async func(ms: u64)

An async function.

get functionvolume: get() -> u8

A property of the world.

set functionvolume: set(value: u8)

Exports

functionrun: func(args: list<string>) -> result

WIT

/// Includes a world from another package, and imports one of its interfaces.
world greeting {
  import kitchen-sink:types/gates@0.1.0;
  /// An interface, by its path in the package.
  import kitchen-sink:types/primitives@0.1.0;
  import kitchen-sink:types/containers@0.1.0;
  import kitchen-sink:types/shapes@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;
  }
  import kitchen-sink:types/resources@0.1.0;
  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;
  export kitchen-sink:types/concurrency@0.1.0;
}