misc.scrbl (2063B)
1 #lang scribble/manual 2 3 @(require (for-label typed/racket/base 4 phc-toolkit/misc)) 5 6 @(module racket-ids racket/base 7 (require scribble/manual 8 (for-label predicates)) 9 10 (define or?-id (racket or?)) 11 (provide (all-defined-out))) 12 13 @(require 'racket-ids) 14 15 @title{Miscellaneous utilities} 16 17 @section{Typed miscellaneous utilities} 18 19 @defmodule[phc-toolkit/misc] 20 21 @defproc[(hash-set** [h (HashTable K V)] [l* (Listof (Pairof K V))]) 22 (HashTable K V)]{ 23 Calls @racket[hash-set] on the hash @racket[h] for each 24 key-value pair contained in each list of @racket[l*].} 25 26 @defform[(with-output-file [var filename] maybe-mode maybe-exists body …) 27 #:grammar ([var Identifier] 28 [filename (ExpressionOf String)] 29 [maybe-mode (code:line) (code:line #:mode mode)] 30 [maybe-exists (code:line) (code:line #:exists exists)])]{ 31 Executes body with @racket[var] bound to the 32 @racket[output-port?] obtained when opening the file. The 33 port is automatically closed at the end of the 34 @racket[body]. This is a macro version of 35 @racket[call-with-output-file].} 36 37 @defproc[(or? [f (→ A Boolean)] ...) (→ A (U A #f))]{ 38 Typed version of @or?-id from the 39 @racketmodname[predicates] package, which returns the value 40 itself when all predicates are satisfied instead of just 41 returning @racket[#t].} 42 43 @subsection{Untyped versions of miscellaneous utilities} 44 45 @defmodule[phc-toolkit/untyped #:link-target? #f] 46 47 @defproc[(hash-set** [h (HashTable K V)] [l* (Listof (Pairof K V))]) 48 (HashTable K V)]{ 49 Untyped version.} 50 51 @defform[(with-output-file [var filename] maybe-mode maybe-exists body …) 52 #:grammar ([var Identifier] 53 [filename (ExpressionOf String)] 54 [maybe-mode (code:line) (code:line #:mode mode)] 55 [maybe-exists (code:line) (code:line #:exists exists)])]{ 56 Untyped version.} 57 58 59 @defproc[(or? [f (→ A Boolean)] ...) (→ A (U A #f))]{ 60 Untyped version.} 61 62 @include-section{misc-untyped.scrbl}