[racket] Tricky case of occurrence typing in Typed Racket

From: Andrew Kent (amk.kent at gmail.com)
Date: Fri Sep 26 12:48:05 EDT 2014

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)))


(: listof-T1or2 (-> Any Boolean : (Listof T1or2)))
(define (listof-T1or2 l)
  (and (list? l) (andmap T1or2? l)))



On Fri, Sep 26, 2014 at 12:28 PM, Konrad Hinsen <konrad.hinsen at fastmail.net>
wrote:

> 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
> prefabricated predicate, not even for the elements of my list.
>
> Konrad.
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140926/30da28f4/attachment.html>

Posted on the users mailing list.