split functional-dict? predicate into separate module
This commit is contained in:
parent
ac1fc50686
commit
9b9a74b86d
|
@ -6,7 +6,7 @@
|
||||||
(-> any/c (lens/c functional-dict? any/c))]
|
(-> any/c (lens/c functional-dict? any/c))]
|
||||||
))
|
))
|
||||||
|
|
||||||
(require racket/dict fancy-app "base/main.rkt")
|
(require lens/private/util/functional-dict racket/dict fancy-app "base/main.rkt")
|
||||||
(module+ test
|
(module+ test
|
||||||
(require rackunit))
|
(require rackunit))
|
||||||
|
|
||||||
|
@ -14,9 +14,6 @@
|
||||||
(make-lens (dict-ref _ key)
|
(make-lens (dict-ref _ key)
|
||||||
(dict-set _ key _)))
|
(dict-set _ key _)))
|
||||||
|
|
||||||
(define (functional-dict? v)
|
|
||||||
(and (dict? v) (dict-can-functional-set? v)))
|
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(check-equal? (lens-transform/list '((a . 1) (b . 2) (c . 3)) (dict-ref-lens 'a) (* 100 _))
|
(check-equal? (lens-transform/list '((a . 1) (b . 2) (c . 3)) (dict-ref-lens 'a) (* 100 _))
|
||||||
'((a . 100) (b . 2) (c . 3))))
|
'((a . 100) (b . 2) (c . 3))))
|
||||||
|
|
15
lens/private/util/functional-dict.rkt
Normal file
15
lens/private/util/functional-dict.rkt
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#lang sweet-exp racket/base
|
||||||
|
|
||||||
|
provide functional-dict?
|
||||||
|
|
||||||
|
require racket/dict
|
||||||
|
module+ test
|
||||||
|
require rackunit
|
||||||
|
|
||||||
|
(define (functional-dict? v)
|
||||||
|
(and (dict? v) (dict-can-functional-set? v)))
|
||||||
|
|
||||||
|
module+ test
|
||||||
|
(check-true (functional-dict? (hash 'a 1 'b 2)))
|
||||||
|
(check-true (functional-dict? '((a . 1) (b . 2))))
|
||||||
|
(check-false (functional-dict? (make-hash '((a . 1) (b . 2)))))
|
Loading…
Reference in New Issue
Block a user