From fcd4c4e38dcdca086d6d1de8dd4bd47439dff2da Mon Sep 17 00:00:00 2001 From: Sam Tobin-Hochstadt Date: Mon, 16 Nov 2009 13:59:13 +0000 Subject: [PATCH] Fix prop values for DrDr. Add plt-responsible props. Add hash-union to unstable. Fix doc for compound-paragraph. Fix unstable/scribblings/util. svn: r16811 --- collects/scribblings/scribble/core.scrbl | 2 +- collects/typed-scheme/infer/constraints.ss | 2 +- collects/typed-scheme/infer/dmap.ss | 3 +- collects/typed-scheme/utils/utils.ss | 20 +++---------- collects/unstable/hash.ss | 13 +++++++++ collects/unstable/scribblings/hash.scrbl | 30 ++++++++++++++++++++ collects/unstable/scribblings/unstable.scrbl | 1 + collects/unstable/scribblings/utils.ss | 12 ++++---- 8 files changed, 58 insertions(+), 25 deletions(-) create mode 100644 collects/unstable/hash.ss create mode 100644 collects/unstable/scribblings/hash.scrbl diff --git a/collects/scribblings/scribble/core.scrbl b/collects/scribblings/scribble/core.scrbl index a339545f21..08ff197ef0 100644 --- a/collects/scribblings/scribble/core.scrbl +++ b/collects/scribblings/scribble/core.scrbl @@ -522,7 +522,7 @@ The following @tech{style properties} are currently recognized: ]} -@defstruct[compound-paragraph ([style any/c] +@defstruct[compound-paragraph ([style style?] [blocks (listof block?)])]{ A @techlink{compound paragraph} has a @tech{style} and a list of diff --git a/collects/typed-scheme/infer/constraints.ss b/collects/typed-scheme/infer/constraints.ss index 08534ef421..54d0495dd9 100644 --- a/collects/typed-scheme/infer/constraints.ss +++ b/collects/typed-scheme/infer/constraints.ss @@ -4,7 +4,7 @@ (types convenience utils union subtype) (rep type-rep) (utils tc-utils) - unstable/sequence + unstable/sequence unstable/hash "signatures.ss" "constraint-structs.ss" scheme/match) diff --git a/collects/typed-scheme/infer/dmap.ss b/collects/typed-scheme/infer/dmap.ss index 412482e336..1a3a9baa42 100644 --- a/collects/typed-scheme/infer/dmap.ss +++ b/collects/typed-scheme/infer/dmap.ss @@ -3,8 +3,7 @@ (require "../utils/utils.ss" "signatures.ss" "constraint-structs.ss" (utils tc-utils) - unstable/sequence - scheme/match) + unstable/sequence unstable/hash scheme/match) (import constraints^) (export dmap^) diff --git a/collects/typed-scheme/utils/utils.ss b/collects/typed-scheme/utils/utils.ss index d2a2491481..78a54952de 100644 --- a/collects/typed-scheme/utils/utils.ss +++ b/collects/typed-scheme/utils/utils.ss @@ -6,13 +6,12 @@ at least theoretically. |# (require (for-syntax scheme/base syntax/parse scheme/string) - scheme/contract mzlib/plt-match scheme/require-syntax scheme/provide-syntax - mzlib/struct scheme/unit - scheme/pretty mzlib/pconvert - (except-in syntax/parse id)) + scheme/contract scheme/match scheme/require-syntax + scheme/provide-syntax mzlib/struct scheme/unit + scheme/pretty mzlib/pconvert syntax/parse) ;; to move to unstable -(provide == hash-union debug reverse-begin) +(provide == debug reverse-begin) (provide ;; timing @@ -186,17 +185,6 @@ at least theoretically. #'([prop:custom-write pseudo-printer])) #f)])) -;; map map (key val val -> val) -> map -(define (hash-union h1 h2 f) - (for/fold ([h* h1]) - ([(k v2) h2]) - (let* ([v1 (hash-ref h1 k #f)] - [new-val (if v1 - (f k v1 v2) - v2)]) - (hash-set h* k new-val)))) - - ;; turn contracts on and off - off by default for performance. (define-for-syntax enable-contracts? #f) diff --git a/collects/unstable/hash.ss b/collects/unstable/hash.ss new file mode 100644 index 0000000000..a93d09da3e --- /dev/null +++ b/collects/unstable/hash.ss @@ -0,0 +1,13 @@ +#lang scheme/base + +(provide hash-union) + +;; map map (key val val -> val) -> map +(define (hash-union h1 h2 f) + (for/fold ([h* h1]) + ([(k v2) h2]) + (let* ([v1 (hash-ref h1 k #f)] + [new-val (if v1 + (f k v1 v2) + v2)]) + (hash-set h* k new-val)))) diff --git a/collects/unstable/scribblings/hash.scrbl b/collects/unstable/scribblings/hash.scrbl new file mode 100644 index 0000000000..4eb96384c0 --- /dev/null +++ b/collects/unstable/scribblings/hash.scrbl @@ -0,0 +1,30 @@ +#lang scribble/doc +@(require scribble/base + scribble/manual + scribble/eval + "utils.ss" + (for-label unstable/hash + scheme/contract + scheme/base)) + +@(define the-eval (make-base-eval)) +@(the-eval '(require unstable/hash)) + +@title[#:tag "hash"]{Hash Tables} + +@defmodule[unstable/hash] + +@unstable[@author+email["Sam Tobin-Hochstadt" "samth@ccs.neu.edu"]] + +@defproc[(hash-union [t1 hash?] [t2 hash?] [combine (any/c any/c any/c . -> . any/c)]) hash?]{ +Produces the combination of @scheme[t1] and @scheme[t2]. If either +@scheme[t1] or @scheme[t2] has a value for key @scheme[k], then the +result has the same value for @scheme[k]. If both @scheme[t1] and +@scheme[t2] have a value for @scheme[k], the result has the value +@scheme[(combine k (hash-ref t1 k) (hash-ref t2 k))] for @scheme[k]. + +@examples[#:eval the-eval +(hash-union #hash((a . 5) (b . 0)) #hash((d . 12) (c . 1)) (lambda (k v1 v2) v1)) +(hash-union #hash((a . 5) (b . 0)) #hash((a . 12) (c . 1)) (lambda (k v1 v2) v1)) +] +} \ No newline at end of file diff --git a/collects/unstable/scribblings/unstable.scrbl b/collects/unstable/scribblings/unstable.scrbl index d92d2ff1ac..819a3e6d8e 100644 --- a/collects/unstable/scribblings/unstable.scrbl +++ b/collects/unstable/scribblings/unstable.scrbl @@ -85,6 +85,7 @@ Keep documentation and tests up to date. @include-section["find.scrbl"] @include-section["class-iop.scrbl"] @include-section["sequence.scrbl"] +@include-section["hash.scrbl"] @;{--------} diff --git a/collects/unstable/scribblings/utils.ss b/collects/unstable/scribblings/utils.ss index 633dee902c..c21e298715 100644 --- a/collects/unstable/scribblings/utils.ss +++ b/collects/unstable/scribblings/utils.ss @@ -1,13 +1,15 @@ #lang at-exp scheme/base -(require scribble/base scribble/manual) +(require scribble/base scribble/manual scribble/core) (provide unstable addition) (define (unstable . authors) - (begin - (apply author authors) - @para{This library is @emph{unstable}; compatibility will not be maintained. - See @secref{unstable} for more information.})) + (make-compound-paragraph + plain + (list (apply author authors) + @para{This library is @emph{unstable} + ; compatibility will not be maintained. + See @secref{unstable} for more information.}))) (define (addition name) @margin-note{The subsequent bindings were added by @|name|.})