Re: [racket] Writing type predicates in typed/racket

2010-11-07 Thread Sam Tobin-Hochstadt
On Sun, Nov 7, 2010 at 10:40 AM, Eric Dobson wrote: > I ran a test and it looks like define-predicate is not constant time, > is there a way for me to write branch? that is constant time? > Otherwise a traversal algorithm turns from linear to quadratic. So, it looks like TR is failing to prove th

Re: [racket] Writing type predicates in typed/racket

2010-11-07 Thread Eric Dobson
I ran a test and it looks like define-predicate is not constant time, is there a way for me to write branch? that is constant time? Otherwise a traversal algorithm turns from linear to quadratic. Code: #lang typed/racket (define-type num-tree (Rec it (U Number (Pair it it (define-type branch

Re: [racket] Writing type predicates in typed/racket

2010-11-06 Thread Sam Tobin-Hochstadt
On Sat, Nov 6, 2010 at 6:52 PM, Eric Dobson wrote: > I don't think that define-predicate will give me a constant time > branch? because it returns something of type (Any -> Boolean : t), and > so can't use the fact that the car and cdr are num-trees without > checking it. `define-predicate' shoul

[racket] Writing type predicates in typed/racket

2010-11-06 Thread Eric Dobson
I am working with typed/racket and running into a problem on how to construct a type predicate. I know about define-predicate, but I don't think that works in my case. My code is as follows (Which does not type check): #lang typed/racket (define-type num-tree (Rec it (U Number (Pair it it ;(de