commit cf790f66005d06994cfaa9115e4a52b12a4e7d7b
parent 263a48521d068896e7363e861db123a76ccf6734
Author: Georges Dupéron <georges.duperon@gmail.com>
Date: Thu, 22 Dec 2016 18:58:57 +0100
Migrated some files from the old graph implementation
Diffstat:
| A | graph-info.rkt | | | 44 | ++++++++++++++++++++++++++++++++++++++++++++ |
| A | graph.hl.rkt | | | 110 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| M | info.rkt | | | 3 | ++- |
3 files changed, 156 insertions(+), 1 deletion(-)
diff --git a/graph-info.rkt 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
@@ -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[<graph>
+ (define-syntax define-graph
+ (syntax-parser
+ [<signature>
+ <implementation>]))]
+
+@chunk[<signature>
+ (_ _name
+ [[_nodeᵢ [_fieldᵢⱼ :colon _τᵢⱼ] …] …]
+ [[(_mappingₖ [_argₖₗ _τₖₗ] …) :colon _return-typeₖ . _bodyₖ] …])]
+
+@chunk[<implementation>
+ #'()]
+
+@section{Overview of the implementation (draft)}
+
+@chunk[<implementation-draft>
+ <create-Qₖ>
+ <re-bind-mappings>
+ <define-indices>
+ <process-queues>]
+
+@chunk[<define-indices>
+ (define/with-syntax (_indexₖ …) (stx-map gensym #'(_idxₖ …)))
+ #'(begin
+ (define-type _indexₖ (graph-index '_indexₖ))
+ …)]
+
+@chunk[<define-index>
+ (struct (K) graph-index ([key : K] [index : Index]))]
+
+Create one queue @racket[_Qₖ] for each mapping:
+
+@chunk[<create-Qₖ>
+ #'(begin
+ (define _Qₖ <create-queue>)
+ (define _Qₖ-enqueue <TODO>)
+ (define _Qₖ-pop <TODO>)
+ …)]
+
+Re-bind mappings to catch outbound calls:
+
+@chunk[<re-bind-mappings>
+ #'(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[<entry-pointₖ>
+ #'(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[<entry-point>
+ #'(define (entry-point #:mappingₖ [_argsₖ* : (Listof (List τₖₗ …)) '()])
+ (for ([_argsₖ (in-list _argsₖ*)])
+ (let-values ([(_argₖₗ …) _argsₖ])
+ (Qₖ-enqueue _argₖₗ …))))]
+
+@chunk[<process-queues>
+ (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)
+ <define-index>
+ <graph>]
+\ No newline at end of file
diff --git 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"))