utils: Also generalise the contract of unstringify-pairs.
This commit is contained in:
parent
a2b8df2a67
commit
eacd2a07a0
1 changed files with 9 additions and 2 deletions
11
utils.rkt
11
utils.rkt
|
@ -15,10 +15,12 @@
|
|||
[stringify-variable-mapping (-> variable-mapping? string-variable-mapping?)]
|
||||
[string->any (-> string? any/c)]
|
||||
[read-org-table (-> string? (listof any/c))]
|
||||
[unstringify-pairs (-> (listof (list/c string? string?)) (listof (list/c symbol? any/c)))])
|
||||
[unstringify-pairs (-> (listof (general-pair/c string? string?))
|
||||
(listof (general-pair/c symbol? any/c)))])
|
||||
;; Contracts
|
||||
(contract-out [variable-mapping? contract?]
|
||||
[string-variable-mapping? contract?])
|
||||
[string-variable-mapping? contract?]
|
||||
[general-pair/c (-> contract? contract? contract?)])
|
||||
;; Syntax
|
||||
auto-hash-ref/explicit auto-hash-ref/: sgfy)
|
||||
|
||||
|
@ -174,6 +176,11 @@
|
|||
;;; table. See example.org for examples.
|
||||
(define (read-org-table str) (string->any str))
|
||||
|
||||
;;; A contract allowing pairs constructed via cons or via list.
|
||||
(define (general-pair/c key-contract val-contract)
|
||||
(or/c (list/c key-contract val-contract)
|
||||
(cons/c key-contract val-contract)))
|
||||
|
||||
;;; Given a list of pairs of strings, converts the first element of
|
||||
;;; each pair to a string, and reads the second element with
|
||||
;;; string->any.
|
||||
|
|
Loading…
Reference in a new issue