package demo:gen@1.2.0; interface types { /// Where something is. record point { x: s32, y: s32, /// Optional label. label: option, } enum color { red, green, blue } flags access { read, write, exec } variant shape { nothing, circle(f32), polygon(list), } type pair = tuple; type names = list; } interface host { use types.{point, color, shape, access}; resource canvas { constructor(width: u32, height: u32); /// Opens a canvas stored on disk. open: static func(path: string) -> result; draw: func(shape: shape, at: point, color: color); /// Copies `other` on top of this canvas. blend: func(other: borrow, types: access); name: func() -> option; } /// Shows the canvas and closes it. present: func(canvas: canvas) -> u64; log: func(message: string); } interface guest { use types.{point}; describe: func() -> point; } world plugin { use host.{canvas}; use types.{shape, pair}; import host; export guest; export start: func(canvas: canvas) -> result<_, string>; export measure: func(shape: shape, scale: pair) -> f32; export stop: func(); }