diff --git a/scribblings/utils.scrbl b/scribblings/utils.scrbl index 91a9354..f7bd6fc 100644 --- a/scribblings/utils.scrbl +++ b/scribblings/utils.scrbl @@ -1,6 +1,8 @@ #lang scribble/manual @(require scribble/example racket/sandbox - (for-label typed/racket/base graph (submod "../utils.rkt" typed))) + (for-label typed/racket/base graph + (submod "../utils.rkt" typed) + (only-in typed/graph Graph))) @title[#:tag "utils"]{dds/utils: Various Utilities} @@ -217,6 +219,14 @@ produces from tables. ]} @section{Additional graph utilities} +@defproc[(dotit [graph Graph]) Void]{ + +Typeset the graph via graphviz and display it. + +@examples[#:eval utils-evaluator +(require typed/graph) +(dotit (weighted-graph/directed '((1 a b) (2 b c)))) +]} @section{Pretty printing} diff --git a/utils.rkt b/utils.rkt index 09bc324..a5ddfe6 100644 --- a/utils.rkt +++ b/utils.rkt @@ -20,7 +20,7 @@ eval-with eval1-with auto-hash-ref/explicit auto-hash-ref/: extract-symbols any->string stringify-variable-mapping string->any handle-org-booleans map-sexp read-org-sexp unorg unstringify-pairs - read-org-variable-mapping unorgv) + read-org-variable-mapping unorgv dotit) (define-type Variable Symbol) (define-type (VariableMapping A) (Immutable-HashTable Variable A)) @@ -249,20 +249,21 @@ (check-equal? (hash-ref m1 'b) '(or b (not a))) (check-equal? (hash-ref m2 'b) '(or b (not a))) (check-equal? (hash-ref m3 'b) '(or b (not a))))) + + (define dotit (compose display graphviz)) ) (require 'typed) (provide eval-with eval1-with auto-hash-ref/explicit auto-hash-ref/: extract-symbols any->string stringify-variable-mapping string->any map-sexp read-org-sexp unorg unstringify-pairs - read-org-variable-mapping unorgv) + read-org-variable-mapping unorgv dotit) ;;; Untyped section. (provide ;; Functions - (contract-out [dotit (-> graph? void?)] - [read-symbol-list (-> string? (listof symbol?))] + (contract-out [read-symbol-list (-> string? (listof symbol?))] [drop-first-last (-> string? string?)] [list-sets->list-strings (-> (listof (set/c any/c)) (listof string?))] [pretty-print-set-sets (-> (set/c (set/c symbol?) #:kind 'dont-care) string?)] @@ -309,9 +310,6 @@ (or/c (list/c key-contract val-contract) (cons/c key-contract val-contract))) -;;; Typeset the graph via graphviz and display it. -(define dotit (compose display graphviz)) - ;;; Reads a list of symbols from a string. (define (read-symbol-list str) (string->any (string-append "(" str ")")))