Technically this should be possible and conceptually preferable. However, it does come with redundancies that conventional type annotations avoid and I am not sure how much of this redundancy we should push on programmers.
On Sep 20, 2012, at 4:51 PM, Patrick Mahoney wrote: > Hey all, > > One feature of typed racket that makes translation between untyped and typed > code somewhat less simple than adding or removing type signatures is that > certain forms require rewriting/alteration of the untyped form itself. Others > allow stand-alone declaration of the types prior to the form. > > #lang racket > (define (louder s) (string-append s "!")) > > becomes > #lang typed/racket > (: louder : String -> String) > (define (louder s) (string-append s "!")) > > but > > #lang racket > (struct arrow (dom cod)) > > becomes > #lang typed/racket > (struct: arrow ([dom : Any] [cod : Any])) > > or a stricter > #lang typed/racket > (struct: (A B) arrow ([dom : A] [cod : B])) > > I tend to prefer the former case, as moving to untyped code just requires > removal of the (: louder ...) type declaration. > > I'd really dig the addition of an alternate way to declare types on structs > in particular: > > #lang typed/racket > (: arrow (ForAll (A B) (StructOf A B))) > (struct arrow (a b)) > > This allows me to reuse my mental untyped code parser for struct forms, while > the struct: form requires an additional rule. It also makes declaration of > types more uniform. Not sure whether this is possible. > > Thanks all, > -Patrick > > On 20 September 2012 12:02, <thorso...@lavabit.com> wrote: > Thank you all for the replies. > > I'll give it a try. > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users ____________________ Racket Users list: http://lists.racket-lang.org/users