Skip to content

Commit

Permalink
Split bindings module and add appropriate scribblings.
Browse files Browse the repository at this point in the history
- scribblings for qi/list module
- scribble the new literals for matching in deforestation pass
- ensure for-label bindings in the generated documentation
- new bindings.rkt module
  • Loading branch information
dzoep authored and countvajhula committed Aug 3, 2024
1 parent f7bcfc1 commit de25f55
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 2 deletions.
118 changes: 118 additions & 0 deletions qi-doc/scribblings/list-operations.scrbl
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#lang scribble/doc
@require[scribble/manual
(for-label racket/list
racket/base)]

@title{List Operations}

@defmodule[qi/list]

This module defines bindings that can leverage stream fusion /
deforestation optimization when found in succession within a
flow. When not part of optimized flow, their behavior is identical to
the bindings of the same name from @racketmodname[racket/base] and
@racketmodname[racket/list].

The bindings are categorized based on their intended usage inside the
deforested pipeline.

@section{Producers}

@defproc*[(((range (end real?)) list?)
((range (start real?) (end real?) (step real? 1)) list?))]{

Deforestable version of @racket[range] from @racketmodname[racket/list].

}

@section{Transformers}

@defproc[(filter (pred procedure?) (lst list?)) list?]{

Deforestable version of @racket[filter] from @racketmodname[racket/base].

}

@defproc[(map (proc procedure?) (lst list?) ...+) list?]{

Deforestable version of @racket[map] from @racketmodname[racket/base].

}

@defproc[(filter-map (proc procedure?) (lst list?) ...+) list?]{

Deforestable version of @racket[filter-map] from @racketmodname[racket/list].

}

@defproc*[(((take (lst list?) (pos exact-nonnegative-integer?)) list?)
((take (lst any/c) (pos exact-nonnegative-integer?)) list?))]{

Deforestable version of @racket[take] from @racketmodname[racket/list].

}

@section{Consumers}

@defproc[(foldl (proc procedure?) (init any/c) (lst list?) ...+) any/c]{

Deforestable version of @racket[foldl] from @racketmodname[racket/base].

}

@defproc[(foldr (proc procedure?) (init any/c) (lst list?) ...+) any/c]{

Deforestable version of @racket[foldr] from @racketmodname[racket/base].

}

@defproc[(car (p pair?)) any/c]{

Deforestable version of @racket[car] from @racketmodname[racket/base].

}

@defproc[(cadr (v (cons/c any/c pair?))) any/c]{

Deforestable version of @racket[cadr] from @racketmodname[racket/base].

}

@defproc[(caddr (v (cons/c any/c (cons/c any/c pair?)))) any/c]{

Deforestable version of @racket[caddr] from @racketmodname[racket/base].

}

@defproc[(cadddr (v (cons/c any/c (cons/c any/c (cons/c any/c pair?))))) any/c]{

Deforestable version of @racket[cadddr] from @racketmodname[racket/base].

}

@defproc*[(((list-ref (lst list?) (pos exact-nonnegative-integer?)) any/c)
((list-ref (lst pair?) (pos exact-nonnegative-integer?)) any/c))]{

Deforestable version of @racket[list-ref] from @racketmodname[racket/base].

}

@defproc[(length (lst list?)) exact-nonnegative-integer?]{

Deforestable version of @racket[length] from @racketmodname[racket/base].

}

@defproc[(empty? (v any/c)) boolean?]{

Deforestable version of @racket[empty?] from @racketmodname[racket/list].

}

@defproc[(null? (v any/c)) boolean?]{

Deforestable version of @racket[null?] from @racketmodname[racket/base].

}


35 changes: 35 additions & 0 deletions qi-lib/flow/core/compiler/deforest/bindings.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#lang racket/base

(require (prefix-in r: racket/base)
(prefix-in r: racket/list)
syntax/parse/define
(for-syntax racket/syntax
syntax/parse
racket/base))

(define-syntax-parser define-and-provide-deforestable-bindings
((_ ids ...)
(with-syntax (((rids ...) (for/list ((s (attribute ids)))
(format-id s "r:~a" s))))
#'(begin
(define ids rids) ...
(provide ids ...)))))

(define-and-provide-deforestable-bindings
range

filter
map
filter-map
take

foldr
foldl
car
cadr
caddr
cadddr
list-ref
length
empty?
null?)
4 changes: 2 additions & 2 deletions qi-lib/list.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
;; Upon instantiation of the module it define-and-register-pass for
;; deforestation
(require "flow/core/compiler/0100-deforest.rkt"
"flow/core/compiler/deforest/binding.rkt")
"flow/core/compiler/deforest/bindings.rkt")

(provide (all-from-out "flow/core/compiler/deforest/binding.rkt"))
(provide (all-from-out "flow/core/compiler/deforest/bindings.rkt"))

0 comments on commit de25f55

Please sign in to comment.