[racket] [Typed Racket] define-predicate for union with functions
(And this is not a limitation of Typed Racket but a fundamental problem of CS.)
On May 20, 2013, at 11:07 AM, Eric Dobson <eric.n.dobson at gmail.com> wrote:
> No, you cannot define predicates for function types. If you explain
> the problem you have, we might be able to explain another solution
> that will work.
>
> On Mon, May 20, 2013 at 1:32 AM, Paul Leger <pleger at gmail.com> wrote:
>> Hi all,
>> Maybe, this question is very easy. In the following code, I try
>> defining a predicate for T2, but I cannot because T1 it is a function.
>>
>> (define-type T1 (Symbol -> Any) )
>> (define-type T2 (U Symbol Number T1))
>>
>> ;(define-predicate T1? Procedure) ;this line is useless
>>
>> (define-predicate T2? T2)
>>
>>> Type Checker: Type T2 could not be converted to a contract. in: T2
>>
>> My unsuccessful answer is:
>> (define-type T2 (U Symbol Number Procedure))
>>
>> I do not like it because I lose the relationship between T1 and T2. Are
>> there some possibility
>>
>> Thank in advance,
>> Paul
>>
>> ____________________
>> Racket Users list:
>> http://lists.racket-lang.org/users
>>
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users