[plt-scheme] Re: Re: Typed Scheme: Is there any easy way around this?

From: Sam TH (samth at ccs.neu.edu)
Date: Fri Jun 1 17:59:47 EDT 2007

On 6/1/07, Anton van Straaten <anton at appsolutions.com> wrote:
> Matthias Felleisen wrote:
> >
> > On Jun 1, 2007, at 1:37 AM, Matthew Swank wrote:
> ...
> >> Well, I don't use contracts.  My basis for a claim of verbosity is my
> >> (somewhat limited) experience of Haskell and straight lisp.
> >>
> >> Compared to those, Typed Scheme is verbose.
> >
> >
> > That's something we can't fix so don't report it "-)
>
> There might be room for improvement, though.  Maybe Typed Scheme can
> already do the following, I've only read some docs so far.
>
> The approach in which types can be annotated inline, like [n : number],
> is used in the MLs too.  My experience is that such annotations make ML
> code more difficult to read and follow.  Ironically, that's partly
> because it starts requiring a lot of parentheses, which break the flow
> of argument lists.  If I find myself needing lots of annotations for
> some reason, I prefer to use a module signature to separate the
> annotations from the code.  Alternatively, the Haskell approach of
> prepending the type signature to the function is a good one.
>
> Having the option to do something like this could help mitigate the
> verbosity.  (Of course, I'm speculating having only read Typed Scheme
> code so far, not written it.)
>
> So e.g. instead of:
>
>    (define: (find [v : number] [l : (Listof number)]) : (Maybe number)
>
> ...you might use something more like:
>
> (define/type ((number * (Listof number)) -> (Maybe number))    ;[*]
>    (find v l)
>      ...)
>
> If it's already possible to do something like this, I await the
> cluestick eagerly.

There isn't something like that built-in at the moment, but I could be
persuaded to add one if there was a syntax I liked.

However, the define/type form you have there should be a very simple
syntax-rules macro, so if you want it, it's in a sense already there.

> [*] using fantasy dot-free infix type notation

No need for fantasy, the type of functions from A and B to C is (A B
-> C) in Typed Scheme.

-- 
sam th
samth at ccs.neu.edu


Posted on the users mailing list.