diff --git a/graph-info.rkt b/graph-info.rkt new file mode 100644 index 0000000..f108af9 --- /dev/null +++ b/graph-info.rkt @@ -0,0 +1,43 @@ +#lang racket + +(provide (struct-out graph-info) + (struct-out node-info) + (struct-out field-info) + (struct-out rich-graph-info) + (struct-out rich-mapping-info)) + +(struct graph-info (name + multi-constructor + root + node-order + nodes)) +(struct node-info (constructor + predicate? + field-order + fields + promise-type + make-incomplete-type ;; may be removed later + incomplete-type + make-placeholder-type ;; may be removed later. + placeholder-type)) +(struct field-info (type + incomplete-type)) + +(struct rich-graph-info (name + multi-constructor + root-node + root-mapping + node-order + nodes + mapping-order + mappings)) +(struct rich-mapping-info (constructor + ;predicate? + ;field-order + ;fields + with-promises-type + ;make-incomplete-type ;; may be removed later + ;incomplete-type + ;make-placeholder-type ;; may be removed later. + ;placeholder-type + )) \ No newline at end of file diff --git a/graph.hl.rkt b/graph.hl.rkt new file mode 100644 index 0000000..792d757 --- /dev/null +++ b/graph.hl.rkt @@ -0,0 +1,109 @@ +#lang hyper-literate typed/racket/base #:no-auto-require +@(require racket/require + scribble-enhanced/doc + racket/require + hyper-literate + (subtract-in scribble/struct scribble-enhanced/doc) + scribble/decode + (for-label racket/format + racket/promise + racket/list + type-expander + (except-in (subtract-in typed/racket/base type-expander) + values) + (only-in racket/base values) + (subtract-in racket/contract typed/racket/base) + phc-toolkit + phc-toolkit/untyped-only + remember)) +@(unless-preexpanding + (require (for-label (submod "..")))) +@doc-lib-setup + +@chunk[ + (define-syntax define-graph + (syntax-parser + [ + ]))] + +@chunk[ + (_ _name + [[_nodeᵢ [_fieldᵢⱼ :colon _τᵢⱼ] …] …] + [[(_mappingₖ [_argₖₗ _τₖₗ] …) :colon _return-typeₖ . _bodyₖ] …])] + +@chunk[ + #'()] + +@section{Overview of the implementation (draft)} + +@chunk[ + + + + ] + +@chunk[ + (define/with-syntax (_indexₖ …) (stx-map gensym #'(_idxₖ …))) + #'(begin + (define-type _indexₖ (graph-index '_indexₖ)) + …)] + +@chunk[ + (struct (K) graph-index ([key : K] [index : Index]))] + +Create one queue @racket[_Qₖ] for each mapping: + +@chunk[ + #'(begin + (define _Qₖ ) + (define _Qₖ-enqueue ) + (define _Qₖ-pop ) + …)] + +Re-bind mappings to catch outbound calls: + +@chunk[ + #'(let ([_mappingₖ _make-placeholderₖ] …) + . bodyₖ)] + +Define functions which enqueue into a given @racket[_Qₖ] and start processing. +The final @racket[_name] macro dispatches to these functions. + +@chunk[ + #'(begin + (define (_entry-pointₖ _argₖₗ …) + (entry-point #:mappingₖ (list (list _argₖₗ …)))) + …)] + +These are based upon the main @racket[entry-point], which takes any number of +initial elements to enqueue, and processes the queues till they are all empty. + +@chunk[ + #'(define (entry-point #:mappingₖ [_argsₖ* : (Listof (List τₖₗ …)) '()]) + (for ([_argsₖ (in-list _argsₖ*)]) + (let-values ([(_argₖₗ …) _argsₖ]) + (Qₖ-enqueue _argₖₗ …))))] + +@chunk[ + (until queues are all empty + process item, see below)] + +@itemlist[ + @item{Find and replace references to old nodes and new incomplete nodes and + new placeholder nodes, instead insert indices.} + @item{Problem: we need to actually insert indices for references to nodes, + not for references to mappings (those have to be inlined).}] + + +@chunk[<*> + (require racket/require + (for-syntax (subtract-in (combine-in racket/base + syntax/parse) + "subtemplate-override.rkt") + phc-toolkit/untyped + type-expander/expander + "subtemplate-override.rkt") + "traversal.hl.rkt" + phc-toolkit) + + ] \ No newline at end of file diff --git a/info.rkt b/info.rkt index 8e448be..38c4ad8 100644 --- a/info.rkt +++ b/info.rkt @@ -14,7 +14,8 @@ (define build-deps '("scribble-lib" "racket-doc" "remember" - "typed-racket-doc")) + "typed-racket-doc" + "aful")) (define scribblings '(("scribblings/phc-graph.scrbl" () ("Data Structures"))