Re: [racket] Typed racket problem

2014-12-01 Thread Matthias Felleisen
On Nov 30, 2014, at 11:18 PM, Manfred Lotz wrote: >> >> Now if you are sure that the 15 options you have are all you ever >> need, why not use a struct with 15 fields or a class with 15 fields? >> Then you get static checking, without needing any instance-of checks >> plus occurrence typing. >

Re: [racket] Typed racket problem

2014-11-30 Thread Manfred Lotz
On Sun, 30 Nov 2014 17:47:23 -0500 Matthias Felleisen wrote: > > In terms of cost, that's identical to what I had __and__ it locks in > the number of variants you can deal with. I agree that in terms of cost there is no difference. Yes, it locks in the number of variants. Therefore I have one

Re: [racket] Typed racket problem

2014-11-30 Thread Matthias Felleisen
In terms of cost, that's identical to what I had __and__ it locks in the number of variants you can deal with. In contrast, mine allows extensions at the point where you define Myopt; for the new "fields", just pass in the additional type at the new call site. Now if you are sure that the 15

Re: [racket] Typed racket problem

2014-11-30 Thread Manfred Lotz
On Sun, 30 Nov 2014 22:21:14 +0100 Manfred Lotz wrote: > No I hadn't considered the variant using type?. Thanks for this. > > Not quite sure if I'm happy about it as I would prefer to have the > type checking at one place instead of providing a type each time I > check/use options. > Saying t

Re: [racket] Typed racket problem

2014-11-30 Thread Manfred Lotz
On Sun, 30 Nov 2014 15:26:09 -0500 Thanks, Vincent. Vincent St-Amour wrote: > At Sun, 30 Nov 2014 16:38:02 +0100, > Manfred Lotz wrote: > > 1. You offered assert? as an alternative. Is this preferable in > > comparison to cast? > > Yes. Assertions are simple first order checks, and are quite >

Re: [racket] Typed racket problem

2014-11-30 Thread Manfred Lotz
No I hadn't considered the variant using type?. Thanks for this. Not quite sure if I'm happy about it as I would prefer to have the type checking at one place instead of providing a type each time I check/use options. -- Manfred On Sun, 30 Nov 2014 14:36:26 -0500 Matthias Felleisen wrote:

Re: [racket] Typed racket problem

2014-11-30 Thread Vincent St-Amour
At Sun, 30 Nov 2014 16:38:02 +0100, Manfred Lotz wrote: > 1. You offered assert? as an alternative. Is this preferable in > comparison to cast? Yes. Assertions are simple first order checks, and are quite inexpensive. Casts, on the other hand, use contracts and may require wrapping for mutable dat

Re: [racket] Typed racket problem

2014-11-30 Thread Matthias Felleisen
Have you considered this: #lang typed/racket (define-type Myopt (U String Boolean Integer)) (define-type OptList (Listof (Pairof Symbol Myopt))) (: olist OptList) (define olist (list '(dir . ".") '(verbose . #t) '(size . 12))) ; This is a fake type, where the "filter" flows

Re: [racket] Typed racket problem

2014-11-30 Thread Manfred Lotz
On Sun, 30 Nov 2014 09:25:57 -0500 Sam Tobin-Hochstadt wrote: > I think this is exactly what you need. You could write (< (assert s > integer?) 0) or (and s (integer? s) (< s 0)), which mostly do the same > thing. > > But the fundamental issue is that this program is well-typed: > > (proces

Re: [racket] Typed racket problem

2014-11-30 Thread Sam Tobin-Hochstadt
I think this is exactly what you need. You could write (< (assert s integer?) 0) or (and s (integer? s) (< s 0)), which mostly do the same thing. But the fundamental issue is that this program is well-typed: (process (list (cons 'size "hi"))) since that's a perfectly valid `OptList`. If you

Re: [racket] Typed racket problem

2014-11-30 Thread Manfred Lotz
Well, I should have added that I've found this: (: process (-> OptList Void)) (define (process ol) (let ([s (optval 'size ol)]) (if (and s (< (cast s Integer) 0)) (displayln "wrong value") (displayln "ok"))) ) but I didn't find this really nice. Actually, I was hoping

[racket] Typed racket problem

2014-11-30 Thread Manfred Lotz
Hi there, I've got another problem with typed racket. Let us say I have an assoc list with options for a program. These options could be of type String, Boolean, or Integer. Now in my program I want to check certain options but I don't know how to do without Typed Racket screaming at me. Here a

Re: [racket] [Typed Racket] Problem with case->

2012-05-16 Thread Sam Tobin-Hochstadt
This ought to work. I'll look into why it currently doesn't. On Tue, May 15, 2012 at 4:37 PM, Sylvain Sanesti wrote: > I don't understand why this code doesn't work : > > (: & (case-> [True -> One] [False -> Zero])) > (define (& x) (if (eq? x #t) 1 0)) > > -> Type Checker: Expected Zero, but got

[racket] [Typed Racket] Problem with case->

2012-05-15 Thread Sylvain Sanesti
I don't understand why this code doesn't work : (: & (case-> [True -> One] [False -> Zero])) (define (& x) (if (eq? x #t) 1 0)) -> Type Checker: Expected Zero, but got One in: 1 Any idea ? Racket Users list: http://lists.racket-lang.org/users

Re: [racket] Typed Racket: problem with interaction between typed/untyped modules

2011-12-02 Thread Sam Tobin-Hochstadt
On Fri, Dec 2, 2011 at 6:57 PM, Ismael Figueroa Palet wrote: > > > 2011/12/2 Sam Tobin-Hochstadt >> >> On Fri, Dec 2, 2011 at 6:26 PM, Ismael Figueroa Palet >> wrote: >> > What I'm trying to do, so you get the full picture, is to write a >> > variation >> > of Aspect Scheme in Typed Racket, so y

Re: [racket] Typed Racket: problem with interaction between typed/untyped modules

2011-12-02 Thread Ismael Figueroa Palet
2011/12/2 Sam Tobin-Hochstadt > On Fri, Dec 2, 2011 at 6:26 PM, Ismael Figueroa Palet > wrote: > > Sam, first I want to thank you for all your answers, you've helped me a > lot. > > Thanks! > > > >> > I'm trying to implement a function wrapper, that given any function > >> > returns > >> > a fun

Re: [racket] Typed Racket: problem with interaction between typed/untyped modules

2011-12-02 Thread Sam Tobin-Hochstadt
On Fri, Dec 2, 2011 at 6:26 PM, Ismael Figueroa Palet wrote: > Sam, first I want to thank you for all your answers, you've helped me a lot. > Thanks! > >> > I'm trying to implement a function wrapper, that given any function >> > returns >> > a function of the same type, but that maybe applies a d

Re: [racket] Typed Racket: problem with interaction between typed/untyped modules

2011-12-02 Thread Ismael Figueroa Palet
Sam, first I want to thank you for all your answers, you've helped me a lot. Thanks! > I'm trying to implement a function wrapper, that given any function > returns > > a function of the same type, but that maybe applies a different > argument. So > > far I haven't been successful, and based on p

Re: [racket] Typed Racket: problem with interaction between typed/untyped modules

2011-12-02 Thread Sam Tobin-Hochstadt
On Fri, Dec 2, 2011 at 5:38 PM, Ismael Figueroa Palet wrote: > > > I'm trying to implement a function wrapper, that given any function returns > a function of the same type, but that maybe applies a different argument. So > far I haven't been successful, and based on previous questions to the mail

[racket] Typed Racket: problem with interaction between typed/untyped modules

2011-12-02 Thread Ismael Figueroa Palet
Greetings, I'm trying to implement a function wrapper, that given any function returns a function of the same type, but that maybe applies a different argument. So far I haven't been successful, and based on previous questions to the mail list it seemed that I needed to go to an untyped module bec