Skip to content

Instantly share code, notes, and snippets.

@alexcrichton
Created March 19, 2021 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexcrichton/bd3983b363e8f899c278caf5557b5cab to your computer and use it in GitHub Desktop.
Save alexcrichton/bd3983b363e8f899c278caf5557b5cab to your computer and use it in GitHub Desktop.
;; documentation comment
type $my_record = record {
;; field documentation
field1: u32,
field2: $other_record,
field3: list[string],
field4: in-buffer[u8],
}
;; comment on this type
type $other_record = (f32, f64)
type $errno = variant {
invalid,
too_big(string),
way_too_big($my_record)
}
;; importing types from other modules
use $other_type from $other_module
fn the_meaning_of_life() -> u32;
fn read(
fd: handle $fd,
buf: out-buffer[u8]
) -> result[u32, $errno];
fn write(
fd: handle $fd,
buf: in-buffer[u8]
) -> result[u32, $errno];
fn multivalue_return() -> u32, u64;
fn tuple_return() -> (u32, u64);
;; documentation on functions
fn what_in_the_world(record: $my_record);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment