From 7e512ada886eb157a220c4225dcfe7a7bdf51a5b Mon Sep 17 00:00:00 2001 From: AlexKnauth Date: Thu, 3 Sep 2015 16:24:05 -0400 Subject: [PATCH] add contracts and tests for isomorphism-compose and -thrush --- unstable/lens/isomorphism/compound.rkt | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/unstable/lens/isomorphism/compound.rkt b/unstable/lens/isomorphism/compound.rkt index 26b7d4f..c14bd1b 100644 --- a/unstable/lens/isomorphism/compound.rkt +++ b/unstable/lens/isomorphism/compound.rkt @@ -1,10 +1,21 @@ #lang sweet-exp racket/base -provide isomorphism-compose - isomorphism-thrush +require racket/contract/base +provide + contract-out + isomorphism-compose + (rest-> isomorphism-lens? isomorphism-lens?) + isomorphism-thrush + (rest-> isomorphism-lens? isomorphism-lens?) require racket/match + lens/private/util/rest-contract "base.rkt" +module+ test + require lens/private/base/main + lens/private/compound/identity + rackunit + "data.rkt" (define (isomorphism-compose . args) (match args @@ -16,3 +27,7 @@ require racket/match (define (isomorphism-thrush . 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")