From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Panicz Maciej Godek Newsgroups: gmane.lisp.guile.user Subject: Re: Typed Guile? Date: Thu, 8 Nov 2012 18:03:51 +0100 Message-ID: References: <24649.77.105.186.199.1348020369.squirrel@lavabit.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1352394254 24249 80.91.229.3 (8 Nov 2012 17:04:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 8 Nov 2012 17:04:14 +0000 (UTC) Cc: guile-user@gnu.org To: thorsopia@lavabit.com Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Nov 08 18:04:24 2012 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TWVWh-0001rM-L5 for guile-user@m.gmane.org; Thu, 08 Nov 2012 18:04:23 +0100 Original-Received: from localhost ([::1]:50274 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWVWY-0007fr-5X for guile-user@m.gmane.org; Thu, 08 Nov 2012 12:04:14 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:41007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWVWO-0007fR-Rr for guile-user@gnu.org; Thu, 08 Nov 2012 12:04:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TWVWE-00082F-1Q for guile-user@gnu.org; Thu, 08 Nov 2012 12:04:04 -0500 Original-Received: from mail-la0-f41.google.com ([209.85.215.41]:49320) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWVWD-00081w-HZ for guile-user@gnu.org; Thu, 08 Nov 2012 12:03:53 -0500 Original-Received: by mail-la0-f41.google.com with SMTP id p5so2642376lag.0 for ; Thu, 08 Nov 2012 09:03:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=LUbEeLjChPnzdkYsR9fnggVeWrf/kAywzTCPTiYQ1iE=; b=iItG6WcZvBZfRe0pLk4rYk2wNTca7RHUSgzrWDrboErhqS3exqLJ3PGwlQIVbVL3QG xh5JFprQWvKURvtNaa/LjDYJ7EYCone18bhWYnJt2TKqfBX2djiA/00KdnqjSxtfq/eJ IAqf31cEoiYFKXQwnLFgOA8Sw9XppBAN2tfkUZacyYNvqjy//IVm2b/uB9aNQiz0LEtu bE/iFLwtEQSvIPKJFvj82/aep/Fvnag1p2MMnlwRwnlyM7Dvj1L4vHV/sIzzFfY6zy/r n0bYl7had9fHb1Iep/0OY6/LMcGVDgBTphFn8yst49IXhnAdaCDh4eg7UENG+spiv3kv 1f7g== Original-Received: by 10.112.23.195 with SMTP id o3mr3587716lbf.6.1352394231617; Thu, 08 Nov 2012 09:03:51 -0800 (PST) Original-Received: by 10.112.38.38 with HTTP; Thu, 8 Nov 2012 09:03:51 -0800 (PST) In-Reply-To: <24649.77.105.186.199.1348020369.squirrel@lavabit.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.215.41 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:9656 Archived-At: > The first part of this message may look irrelevent, but you'll > understand why I decided to start this way. > > I'm going to write a library. > > Here is the list of things I care about (from the most important to > the least important): > > - Strict type system; > - Wide community; > - Performance. > > There are several candidates: > > - Haskell; > - Typed Racket; > - Typed Clojure*. > > Which one should I choose? > > (Please don't answer right now.) Oh, come on, it's been months! > I've already tried to ask TR people: > > "Typed Racket is designed for Racket. One day Guile will have a Typed > Guile companion, and Chez Scheme may have a Typed Chez companion but > until then TR is for Racket." [1] > > Is it this bad? Do we really need Typed Guile? > > Can we somehow adapt the static code to achieve its features in Guile? > > I'm really concerned about code reuse. It's time to stop reinventing > the wheel. > > My writing skills are not very great... > So I'm going to summarize the above: > > 1. What language should I choose for my library? > 2. Do we need Typed Guile? I'm glad that you wrote. I'm really dying for a good type system for guile. Obviously, type system can, in the long run, have some positive impact on performance, as it allows to avoid run-time type checking. But this isn't my concern for now. For me, the biggest (and most urgent) issue is the expressive power of the language, and second biggest, error-proneness. I've heard a lot about the type system of Haskell, but I don't know any details. Neither do I know much about racket's, but I know for sure that it doesn't suit my taste. There is, however, a good base for a type system shipped with guile's GOOPS. And I think that it would be wisest to extend it, so the language remains coherent. GOOPS' type system is lacking two features, the first one being the return value of a procedure, and the second, types for collections. So I think, that type annotation for the return value of a method could be a coherent extension to the existing system. For example, one could write: (define-method (name (arg1 ) ... (argN )) : body ...) slightly extending the define-method as it is used today. The second postulate is more difficult to agree upon with. I think the nicest way would be to use the omnipresent pattern language, so for instance the procedure taking the list of numbers could be written as: (define-method (mean (S ( ...))) : (/ (apply + S) (length S))) (define-method (mean (v #( ...))) : (mean (vector->list v))) It could be similarly used to define methods with variable number of arguments of the same type, e.g. (define-method (mean (n ) . (rest ( ...))) : (mean (cons n rest))) Unfortunately, the pattern language alone would be insufficient, at least not in its present shape. That's because we would also like to be able to specify the types of hashes and procedures, like below (it's actually inspired by the code that I'm writing at the moment): (define-method (handle-clients (connection ( . )) (clients (hash ( . ) (hash ))) (handle-new-connection ((procedure ) : (hash )))) [body]) I don't know to what extent is this readable. My intention is that the syntax (hash ) would express a hash table such that all its keys are of type , and values of , respectively. Similarly, ((procedure ... ) : ) stands for the procedure of a certain type. This notation is just a proposition for what I'm willing to express. There is a question regarding the implementation, however (especially, defining new types). I think it would be a problem for the pattern-matcher to distinguish between (hash ) [a hash] and ( ) [a list], so maybe another notation would be required (like (% hash ...), (% procedure ...), or #%hash( ) ..., or something similar). I think that parsimony is one of the advantages of such a type system. One could say that having any type system is better than having none, but I don't think that this refers to the realm of Scheme :) Secondly, building it atop of GOOPS would be valuable in this respect, that it could be later adapted by the chicken's scheme COOPS object system, which also derived from CLOS and seems compatible with GOOPS (vide http://wiki.call-cc.org/eggref/4/coops). I don't know what the rest of the community has to say about this, but if you managed to implement this, I can promise that you'd have at least one user :) (Among the things that I dislike in the typed Racket is that firstly it posits plurality without necessity, introducing labels like Listof, that a programmer needs to memoize or look up in the documentation, and secondly, it introduces not-much-telling identifier :, which, although looks joyfully when used ("(:"), is quite far from the spirit of SICP) BTW Does anyone here know what does the #& ("box") quasi-pattern in the Shinn-Wright pattern matcher stand for? Best regards :) M.