Created
April 18, 2018 00:22
-
-
Save christineponyl/679bacf1177db8df7a8a6a2f273e5b56 to your computer and use it in GitHub Desktop.
Shared via Pony Playground (https://playground.ponylang.org/?gist=679bacf1177db8df7a8a6a2f273e5b56)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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