Define deforestable runtime - #207
Conversation
- extend the info struct to contain syntax with CPS runtime reference (as a bound identifier) - amend define-deforestable to allow lambda with CPS runtime - move map-cstream-next into define-deforestable of map form fix fallback codegen to properly match on extended info struct
- filter - filter-map - take - require racket/contract/base to allow virtual contract failures within the deforested pipeline - needed by take
- extend the deforestable-info with `kind` field
- when `'T`, it is a transformer
- add #:transformer, #:producer, and #:consumer keywords to define-deforestable
- use #:transformer to define all transformers in list.rkt
- remove all old remaining transformer classes:
- `fst` (from cps.rkt)
- `fst-filter-map`, `fst-map`, and `fst-take` (from syntax.rkt)
- add new `fst-new` syntax class providing both:
- ability to match deforestable transformers within a sequence
(see `make-deforest-rewrite` in fusion.rkt)
- providing all attributes needed for generating fused operation
(see `deforest-pass` in cps.rkt)
- add `filter-not` form using (define-deforestable #:transformer ...) - add test for it (including support predicate)
- documentation: - new `list-tail` form with `drop` alias - add all new forms to the overall grammar - document previously added `filter-not` form - deforested `list-tail` - add the new form using (define-deforestable #:transformer ...) - provide it twice - including variant as `drop` - tests - deforested sequence including `list-tail` - testing functionality with basic use-cases
- remove make-producer-curry - remove make-blanket-curry - simplify make-fine-curry - make both producers' prepare a lambda instead of case-lambda
- remove make-fine-curry - add preliminary producer state expression to the syntax classes - remove unused attributes of range syntax class
- simplify contract to specify only in-flow arguments (none for range, list? for implicit producer) - merge `curry` and `prepare` attributes (and prepare's runtime) into the `prepare` attribute - simplify `deforest-pass` - remove curry - fill-in contract details - cleanup consing - remove runtime implementations for producers' prepare - start preliminary work on `fsp-new`
- remove range->cstream-next - support producer-specific identifiers
- implement rest alias for (list-tail 1) - implement cdr, cddr, cdddr, cddddr, and cdddddr aliases - document the new aliases
- add prepare field to deforestable-info struct - expand arguments upon matching actual deforestable producer (range) - copy deforestable-clause-parser temporarily to deforest/syntax.rkt - add separate define-deforestable #:producer pattern
THIS IS BROKEN WORK IN PROGRESS - move list->cstream-next into list.rkt as define-deforestable (list->cstream) - matching (#%deforestable ...) on the injected list->cstream->cstream-next does not work - the naming issue is not the probllem (this IS the generated name for the moment) - (list->cstream->cstream-next) is injected in fusion.rkt, lines 63-76 - generate-fused operation sees only the identifier, not the expanded form (to core language) - those loops thru hoops with local-expand and friends are just one of many random attempts
- use expand-flow from invoke submod flow/extended/expander - expand both use-cases in fusion.rkt - fix fsp-new pattern - #%deforestable - NOT #:deforestable - explicitly name the info struct for producers
- remove original fsp syntax class - remove unused requires from cps.rkt - remove unused list->cstream-next producer runtime - fix and remove unused requires in syntax.rkt - remove fsp-* syntax classes - reduce fsp-new attributes
…not use syntax quote on prepare.
| (expand-flow | ||
| ((make-interned-syntax-introducer 'qi) | ||
| #'list->cstream)))) |
There was a problem hiding this comment.
This is horrifying; why do we need the expand-flow again? I wonder if we could hoist/extract the horrors too so we at least don't need to repeat it.
There was a problem hiding this comment.
Factored into a separate procedure expand-qi-syntax within the same module and using introduce-qi-syntax instead of explicitly invoking make-interned-syntax-introducer with 'qi all over again. Still horrifying, but cannot be easily improved anymore.
| [(#%deforestable list-ref* _info | ||
| ((~datum expr) (#%host-expression n)) | ||
| ((~datum expr) (#%host-expression (quote (~datum list-ref))))) | ||
| #'(list-ref n)] | ||
| [(#%deforestable list-ref* _info | ||
| ((~datum expr) (#%host-expression n)) | ||
| ((~datum expr) (#%host-expression (quote name)))) | ||
| #'name] |
There was a problem hiding this comment.
This is slightly ugly 😃 and feels brittle with the host-expression stuff, but it's ultimately only used for display, right?
|
@benknoble - can you, please, pretty please, have a look at this PR? |
benknoble
left a comment
There was a problem hiding this comment.
Just a bunch of little things! Feel free to ignore as you see fit.
Looks like a lot of hard work has gone into this ;) I certainly won't hold it up myself.
Summary of Changes
Remaining Work
WIP
Won't Do
Done
Release steps
Public Domain Dedication
(Why: The freely released, copyright-free work in this repository represents an investment in a better way of doing things called attribution-based economics. Attribution-based economics is based on the simple idea that we gain more by giving more, not by holding on to things that, truly, we could only create because we, in our turn, received from others. As it turns out, an economic system based on attribution -- where those who give more are more empowered -- is significantly more efficient than capitalism while also being stable and fair (unlike capitalism, on both counts), giving it transformative power to elevate the human condition and address the problems that face us today along with a host of others that have been intractable since the beginning. You can help make this a reality by releasing your work in the same way -- freely into the public domain in the simple hope of providing value. Learn more about attribution-based economics at drym.org, tell your friends, do your part.)