Skip to content

Instantly share code, notes, and snippets.

@samdphillips
Last active April 13, 2023 01:00
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 samdphillips/283ed1bf0df7b14175446a2c1d044f24 to your computer and use it in GitHub Desktop.
Save samdphillips/283ed1bf0df7b14175446a2c1d044f24 to your computer and use it in GitHub Desktop.
#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