Last active
April 13, 2023 01:00
-
-
Save samdphillips/283ed1bf0df7b14175446a2c1d044f24 to your computer and use it in GitHub Desktop.
This file contains 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
#lang rhombus/static/and_meta | |
import: | |
lib("racket/stream.rkt") | |
export: | |
Stream | |
meta: | |
namespace Stream: | |
export annot_key | |
def annot_key = '#{#%stream-annot}' | |
namespace Stream: | |
export: | |
of | |
is_stream | |
first | |
rest | |
annot.macro 'of($(ann :: annot_meta.Parsed))': | |
annot_meta.pack_predicate('Stream.is_stream', | |
'(($(Stream.annot_key), $ann.group), | |
($(statinfo_meta.dot_provider_key), | |
stream_dot_provider))') | |
def is_stream = stream.#{stream?} | |
def is_empty = stream.#{stream-empty?} | |
def first = stream.#{stream-first} | |
def rest = stream.#{stream-rest} | |
annot.macro 'Stream': | |
annot_meta.pack_predicate('Stream.is_stream', | |
'(($(Stream.annot_key), Any), | |
($(statinfo_meta.dot_provider_key), | |
stream_dot_provider))') | |
dot.macro 'stream_dot_provider $left $dot $right': | |
match right | |
| 'is_empty': 'Stream.is_empty($left)' | |
| 'first': 'Stream.first($left)' | |
| 'rest': 'Stream.rest($left)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment