[racket] constructing a boolean that's a filter for a given type? could be automatic?

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Mon Jan 30 15:54:51 EST 2012

On Mon, Jan 30, 2012 at 3:48 PM, John Clements
<clements at brinckerhoff.org> wrote:
>
> 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.

What you want is `define-predicate':

#lang typed/racket

(define-type GradeElement
 (Pair Bytes Null))

;; this line is not required
(: grade-element? (Any -> Boolean : GradeElement))
(define-predicate grade-element? GradeElement)

Docs here: http://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket/base-env/prims..rkt%29._define-predicate%29%29

-- 
sam th
samth at ccs.neu.edu


Posted on the users mailing list.