add contracts and tests for isomorphism-compose and -thrush
This commit is contained in:
parent
ec08ef67dd
commit
7e512ada88
|
@ -1,10 +1,21 @@
|
||||||
#lang sweet-exp racket/base
|
#lang sweet-exp racket/base
|
||||||
|
|
||||||
provide isomorphism-compose
|
require racket/contract/base
|
||||||
isomorphism-thrush
|
provide
|
||||||
|
contract-out
|
||||||
|
isomorphism-compose
|
||||||
|
(rest-> isomorphism-lens? isomorphism-lens?)
|
||||||
|
isomorphism-thrush
|
||||||
|
(rest-> isomorphism-lens? isomorphism-lens?)
|
||||||
|
|
||||||
require racket/match
|
require racket/match
|
||||||
|
lens/private/util/rest-contract
|
||||||
"base.rkt"
|
"base.rkt"
|
||||||
|
module+ test
|
||||||
|
require lens/private/base/main
|
||||||
|
lens/private/compound/identity
|
||||||
|
rackunit
|
||||||
|
"data.rkt"
|
||||||
|
|
||||||
(define (isomorphism-compose . args)
|
(define (isomorphism-compose . args)
|
||||||
(match args
|
(match args
|
||||||
|
@ -16,3 +27,7 @@ require racket/match
|
||||||
(define (isomorphism-thrush . args)
|
(define (isomorphism-thrush . args)
|
||||||
(apply isomorphism-compose (reverse args)))
|
(apply isomorphism-compose (reverse args)))
|
||||||
|
|
||||||
|
module+ test
|
||||||
|
(define string->vector-lens (isomorphism-thrush string->list-lens list->vector-lens))
|
||||||
|
(check-equal? (lens-view string->vector-lens "abc") #(#\a #\b #\c))
|
||||||
|
(check-equal? (lens-set string->vector-lens "abc" #(#\1 #\2 #\3)) "123")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user