[racket] Argument type conventions

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Thu Oct 9 17:26:20 EDT 2014

+1


On Oct 9, 2014, at 5:06 PM, Sam Tobin-Hochstadt <samth at cs.indiana.edu> wrote:

> That's really cool. Nicely done.
> 
> Sam
> 
> On Thu, Oct 9, 2014 at 5:00 PM, Jack Firth <jackhfirth at gmail.com> wrote:
>> Following from a discussion on the list a few days ago, I’ve created a
>> package for Typed Racket that lets you define function arguments to have
>> some types by default, like so:
>> 
>> #lang typed/racket
>> (require type-conventions)
>> 
>> (define-type Bit (U Zero One))
>> (define-type-convention Bit bit)
>> 
>> (define: (flip bit) : Bit
>>  (if (zero? bit) 1 0))
>> 
>> It keeps a table of conventions and provides a modified version of define:
>> that extracts types based on the conventions table. Currently it supports
>> typed keyword arguments, optional arguments, and rest arguments, as well as
>> mixing explicitly typed arguments in with conventionally typed ones, even
>> explicitly typed parameterized arguments. There’s some more functionality I
>> want to implement, such as forms for anonymous functions and
>> partially-applied functions, but it feels quite useful currently. The source
>> is on Github here: https://github.com/JackFirth/type-conventions
>> 
>> I haven’t yet added documentation, but “example.rkt” details the exported
>> forms and how they work. If anyone has any suggestions for more
>> improvements, let me know.
>> 
>> 
>> ____________________
>>  Racket Users list:
>>  http://lists.racket-lang.org/users
>> 
> 
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users



Posted on the users mailing list.