From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: Typechecking I Date: Sat, 20 Nov 2010 12:46:11 +0100 Message-ID: References: <201010212223.23822.stefan.itampe@gmail.com> <87bp66q8g5.fsf@gnu.org> <201011160010.53435.stefan.itampe@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1290253344 18164 80.91.229.12 (20 Nov 2010 11:42:24 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 20 Nov 2010 11:42:24 +0000 (UTC) Cc: guile-devel@gnu.org To: Stefan Israelsson Tampe Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Nov 20 12:42:18 2010 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PJlpi-0005Ze-24 for guile-devel@m.gmane.org; Sat, 20 Nov 2010 12:42:18 +0100 Original-Received: from localhost ([127.0.0.1]:37476 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJlph-0007mk-4j for guile-devel@m.gmane.org; Sat, 20 Nov 2010 06:42:17 -0500 Original-Received: from [140.186.70.92] (port=35164 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJlpd-0007md-5d for guile-devel@gnu.org; Sat, 20 Nov 2010 06:42:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PJlpb-0006B4-Qx for guile-devel@gnu.org; Sat, 20 Nov 2010 06:42:13 -0500 Original-Received: from a-pb-sasl-sd.pobox.com ([64.74.157.62]:44794 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PJlpb-0006Ai-Lt for guile-devel@gnu.org; Sat, 20 Nov 2010 06:42:11 -0500 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 11A1A3548; Sat, 20 Nov 2010 06:42:21 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=Pw5a8RARvQg+KGoAGL9AuAMNvPM=; b=TXs1wQ VNe/OnA31ca0BtT6byuuye+OY6YnUib0Iz7HUFC6CYn91DjYwkBLRe2GaCQTEfoL 42LqK1/n2HGz2flzKXnpHX4I/e5+J01yVcseZRxDTxV2ET0uCxJ79KecpWNt5bu2 wTYn64LhX6IiHTDDaFb3yYp38PqcWX6WQFmss= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=bEqFMQq48k8OKEVIbitq4tVYq3NA5VYD ucCkZIgll0zvn8yj8uJFoC2mT8dTTStbrOvOqtHRXQr4ZO4YlSOdk6/697KRtVjt aMuQ9rssVWW7cS2bJDLVLtK373SOCAK/2/9R4s5yuxzPCdzXDMCmx5iyvCrAoQUF aTAgKMx1DL0= Original-Received: from a-pb-sasl-sd.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id F3B053544; Sat, 20 Nov 2010 06:42:19 -0500 (EST) Original-Received: from unquote.localdomain (unknown [88.0.167.219]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTPSA id 32E9B3541; Sat, 20 Nov 2010 06:42:17 -0500 (EST) In-Reply-To: <201011160010.53435.stefan.itampe@gmail.com> (Stefan Israelsson Tampe's message of "Tue, 16 Nov 2010 00:10:53 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) X-Pobox-Relay-ID: 3B7D8C8A-F49B-11DF-9AE7-B53272ABC92C-02397024!a-pb-sasl-sd.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:11155 Archived-At: Hi, Just some superficial notes while reading your code :) On Tue 16 Nov 2010 00:10, Stefan Israelsson Tampe writes: > (define-module (language prolog typecheck equationalize) > #:use-module (srfi srfi-1 ) > #:use-module (ice-9 pretty-print ) > #:use-module (ice-9 match ) > #:use-module (ice-9 receive ) > #:export (equationalize check)) Thanks for making it depend on only modules in Guile :-) The extra spaces before the close-parens should be removed, though. > (define-syntax rlet This is usually known as let-values, fwiw. > (define (compute-type Const Code) > (define (type? X) (and (symbol? X) (char-upper-case? (car (string->list (symbol->string X)))))) Try to keep your lines to less than 80 characters, please :) > (define (gen-map Code Bind Lam) > (match Code > ([X . L] (gen-map X Bind (lambda (Bind) (gen-map L Bind Lam)))) The conventional indentation for this is: (match Code ([X . L] ...)) If your emacs doesn't do this, add this to your .emacs: (put 'match 'scheme-indent-function 1) > (define (check X) > (rlet ((A X) > ((Ba Ea) (equationalize '() '() A 'Texp))) > (pp A) Likewise for rlet -- though it should be just let*-values, if it were a macro of your own, you could add a similar block to the .emacs. > (match Expr > (['and X Y] (let ((F1 (equationalize-bool Bind Eq X)) > (F2 (equationalize-bool Bind Eq Y))) > (lambda (X) > (if X > (rlet (((Bind1 Eq1) (F1 #t)) > ((Bind2 Eq2) (F2 #t))) > (values (union Bind1 Bind2) `(and ,Eq1 ,Eq2))) > (rlet (((Bind1 Eq1) (F1 #f)) > ((Bind2 Eq2) (F2 #f))) > (values (union Bind1 Bind2) `(or ,Eq1 ,Eq2))))))) > > (['or X Y] (let ((F1 (equationalize-bool Bind Eq X)) > (F2 (equationalize-bool Bind Eq Y))) > Here again, much more conventional would be (match Expr (['and X Y] (let ((F1 (equationalize-bool Bind Eq X)) (F2 (equationalize-bool Bind Eq Y))) (lambda (X) (if X (rlet (((Bind1 Eq1) (F1 #t)) ((Bind2 Eq2) (F2 #t))) (values (union Bind1 Bind2) `(and ,Eq1 ,Eq2))) (rlet (((Bind1 Eq1) (F1 #f)) ((Bind2 Eq2) (F2 #f))) (values (union Bind1 Bind2) `(or ,Eq1 ,Eq2))))))) (['or X Y] ...)) Your style is has gotten a lot more readable, for which I am grateful :) There is still some small ways to go yet, though. Syntactically yours, Andy -- http://wingolog.org/