I'm finding it difficult to construct filters for given types:

#lang typed/racket

(define-type GradeElement 
  (Pair Bytes Null))

(: grade-element? (Any -> Boolean : GradeElement))
(define (grade-element? a)
  (and (pair? a)
       (bytes? (car a))
       (null? (cdr a))))

=>

Type Checker: Expected result with filter ((GradeElement @ a) | (! GradeElement 
@ a)), got filter ((AndFilter (Bytes @ (car) a) ((Pairof Any Any) @ a) (Null @ 
(cdr) a)) | (OrFilter (! Null @ (cdr) a) (! Bytes @ (car) a) (! (Pairof Any 
Any) @ a))) in: (and (pair? a) (bytes? (car a)) (null? (cdr a)))

I admit that that error just makes my eyes glaze over, but I'm pretty sure that 
the problem here is that TR can't reduce this filter type, and just needs a 
cleverness injection.

Looking at this, though, it seems to me that it might be simpler just to ask TR 
to construct a filter for a given type, and it occurs to me that this might 
already be built-in.  If so, I can't find it in the documentation.

John

Attachment: smime.p7s
Description: S/MIME cryptographic signature

____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to