Skip to content

Commit

Permalink
Merge pull request #63 from countvajhula/small-core-language
Browse files Browse the repository at this point in the history
Distill a small core language
  • Loading branch information
countvajhula authored Sep 3, 2022
2 parents 7d1afb9 + 2f5220a commit e7dee8c
Show file tree
Hide file tree
Showing 12 changed files with 481 additions and 389 deletions.
7 changes: 7 additions & 0 deletions qi-doc/scribblings/forms.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,15 @@ Note that the symbol form uses Unicode @code{0x2225} corresponding to LaTeX's @c
@deftogether[(
@defform[(== flo ...)]
@defform[(relay flo ...)]
@defidform[#:link-target? #f ==]
@defidform[#:link-target? #f relay]
)]{
Compose flows in parallel, so that inputs are passed through the corresponding @racket[flo]'s individually. The number of @racket[flo]s must be the same as the number of runtime inputs.

In the common case of @code{1 × 1} @racket[flo]s (i.e. where the flows each accept one input and produce one output), the number of outputs will be the same as the number of inputs, but as @seclink["What_is_a_Flow_"]{flows can be nonlinear}, this is not necessarily the case in general.

When used in identifier form simply as @racket[==], it behaves identically to @racket[><].

See also the field guide entry on the @seclink["Bindings_are_an_Alternative_to_Nonlinearity"]{relationship between bindings and nonlinearity}.

@examples[
Expand Down Expand Up @@ -568,11 +572,14 @@ A form of generalized @racket[sieve], passing all the inputs that satisfy each
(loop condition-flo map-flo)]
@defform[#:link-target? #f
(loop map-flo)]
@defidform[#:link-target? #f loop]
)]{
A simple loop for structural recursion on the input values, this applies @racket[map-flo] to the first input on each successive iteration and recurses on the remaining inputs, combining these using @racket[combine-flo] to yield the result as long as the inputs satisfy @racket[condition-flo]. When the inputs do not satisfy @racket[condition-flo], @racket[return-flo] is applied to the inputs to yield the result at that terminating step. If the condition is satisfied and there are no further values, the loop terminates naturally.

If unspecified, @racket[condition-flo] defaults to @racket[#t], @racket[combine-flo] defaults to @racket[_], and @racket[return-flo] defaults to @racket[⏚].

When used in identifier form simply as @racket[loop], this behaves the same as the fully qualified version, except that the flows parametrizing the loop are expected as the initial four inputs (in the same order), and the data inputs being acted upon are expected to follow.

@examples[
#:eval eval-for-docs
((☯ (loop (* 2))) 1 2 3)
Expand Down
4 changes: 2 additions & 2 deletions qi-lib/flow.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
syntax/parse
(only-in "private/util.rkt"
report-syntax-error)
"flow/expander.rkt")
"flow/compiler.rkt"
"flow/extended/expander.rkt")
"flow/core/compiler.rkt"
(only-in "private/util.rkt"
define-alias))

Expand Down
Loading

0 comments on commit e7dee8c

Please sign in to comment.