[racket] Argument type conventions

From: Jack Firth (jackhfirth at gmail.com)
Date: Thu Oct 9 17:00:57 EDT 2014

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.
​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20141009/55b56cdc/attachment.html>

Posted on the users mailing list.