[plt-dev] Typed Scheme: function type declarations should support optional args

From: Noel Welsh (noelwelsh at gmail.com)
Date: Mon Mar 29 11:01:11 EDT 2010

On Mon, Mar 29, 2010 at 2:48 PM, Matthias Felleisen
<matthias at ccs.neu.edu> wrote:
> Can't he write a macro that unfolds into a type specification, at least for
> his uses?

I have, but it seems like something that is generally useful. PLT
Scheme has had case-lambda for a long time. We know from experience
that most of the time we use case-lambda to implement optional
arguments using the pattern I described and hence the evolution from
opt-lambda to built-in support for optional args in untyped Scheme.
There is no reason to expect the situation is different in Typed

This kind of code is not beautiful (a type defn for one of the
built-ins that I recently added):

[write-bytes-avail*  (cl-> [(-Bytes) (-opt -Nat)]
                           [(-Bytes -Output-Port) (-opt -Nat)]
                           [(-Bytes -Output-Port -Nat) (-opt -Nat)]
                           [(-Bytes -Output-Port -Nat -Nat) (-opt -Nat)])]

> On Mar 29, 2010, at 9:44 AM, Sam Tobin-Hochstadt wrote:
>> Really, there are two separate issues here - a convenient syntax for
>> types with optional arguments, and support for defining functions with
>> optional arguments.  The first is less of a pain, but probably
>> something I could implement pretty easily.

This would be nice.

>> is significantly harder, because the expansion of such definitions is
>> quite convoluted.  As a short-term work-around, you can use
>> `opt-lambda' from `mzlib/etc', whose expansion is much simpler.

So Typed Scheme doesn't currently implement it's own define?


Posted on the dev mailing list.