Skip to content

Instantly share code, notes, and snippets.

@christineponyl
Created April 18, 2018 00:22
Show Gist options
  • Save christineponyl/679bacf1177db8df7a8a6a2f273e5b56 to your computer and use it in GitHub Desktop.
Save christineponyl/679bacf1177db8df7a8a6a2f273e5b56 to your computer and use it in GitHub Desktop.
actor Main
new create(env: Env) =>
None
primitive TokenCount
primitive TokenItem
type Token[A: Any #share] is ((TokenCount, None, USize) | (TokenItem, A))
interface Tokens[A: Any #share]
fun next_count(iter: Iterator[Token[A]]): USize? =>
match iter.next()?
| (let _: TokenCount, let _: None, let count: USize) => count
else error
end
fun next_item(iter: Iterator[Token[A]]): A? =>
match iter.next()?
| (let _: TokenItem, let item: A) => item
else error
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment