Does using andmap with the custom predicates you alluded to for that union
you mentioned work?
Something like this perhaps?:
#lang typed/racket
(struct: T1 ())
(struct: T2 ())
(define-type T1or2 (U T1 T2))
(: T1or2? (-> Any Boolean : T1or2))
(define (T1or2? a)
(or (T1? a) (T2? a)))
(: listo
Andrew Kent writes:
> Will andmap work for you?
Interesting... I didn't know about that one.
For my demonstration code, that's indeed a good solution. In my real
application, the test is more complicated. I need to check all
elements of a list for conformance to a union type, so I have no
prefa
Will andmap work for you?
(struct: foo ())
(struct: bar ())
(define-type FooOrBar (U foo bar))
(: f-bar (-> (Listof bar) Void))
(define (f-bar xs)
(void))
(: f-mixed (-> (Listof FooOrBar) Void))
(define (f-mixed xs)
(void))
(: f (-> (Listof FooOrBar) Void))
3 matches
Mail list logo