[racket] Typed Racket vs. Haskell

From: Patrick Mahoney (paddy.mahoney at gmail.com)
Date: Thu Sep 20 16:51:39 EDT 2012

 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, <thorsopia at lavabit.com> wrote:

> Thank you all for the replies.
>
> I'll give it a try.
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120920/81169ad5/attachment.html>

Posted on the users mailing list.