From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id WBapHztpOGOcKgAAbAwnHQ (envelope-from ) for ; Sat, 01 Oct 2022 18:22:19 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 0CW4HztpOGN+6gAAauVa8A (envelope-from ) for ; Sat, 01 Oct 2022 18:22:19 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1A48A16618 for ; Sat, 1 Oct 2022 18:22:18 +0200 (CEST) Received: from localhost ([::1]:35398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oefFo-0005lB-Cx for larch@yhetil.org; Sat, 01 Oct 2022 12:22:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oefFa-0005kt-Pz for guix-patches@gnu.org; Sat, 01 Oct 2022 12:22:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46555) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oefFa-00060d-E3 for guix-patches@gnu.org; Sat, 01 Oct 2022 12:22:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oefFa-0003o9-9k for guix-patches@gnu.org; Sat, 01 Oct 2022 12:22:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58231] [PATCH 1/2] licenses: Let 'license?' expand to #t in trivial cases. References: <20221001161911.8116-1-ludo@gnu.org> In-Reply-To: <20221001161911.8116-1-ludo@gnu.org> Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 01 Oct 2022 16:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58231 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58231@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 58231-submit@debbugs.gnu.org id=B58231.166464127514575 (code B ref 58231); Sat, 01 Oct 2022 16:22:02 +0000 Received: (at 58231) by debbugs.gnu.org; 1 Oct 2022 16:21:15 +0000 Received: from localhost ([127.0.0.1]:45631 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oefEo-0003n0-U6 for submit@debbugs.gnu.org; Sat, 01 Oct 2022 12:21:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60682) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oefEm-0003mh-UP for 58231@debbugs.gnu.org; Sat, 01 Oct 2022 12:21:13 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:46412) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oefEh-0005wf-LM; Sat, 01 Oct 2022 12:21:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=zTkeJCBbNwHI5BOVQL9SM/OKVMiiFjeDVcEzEzXUQa4=; b=bTch/j4nOD2IAF R4PVsd7LSS5xCn2Ao8BBp7wyM5LmWJNLMkPRk/hSSJSaeq84OXICmPKYwM5cuStt6Rs7g2WAOljpi Fi257RCnEB3UXNXOwDsFqYIG7vDLRHb6F69k6BOp5UQXjdE9jq8RP0F15tkietXRnHzGoqTlAvzkd Wn3xxm+BOV2lF4TkRoRAIWT77msyyLPMWG8zblO33Ka32uziX2H1M1lhYYwE1I42NlYX+LkKfH03a MYX98b9+IVBU5vU3mkPLDwjdfqIsQJGyZxVuk9eRGyuAWbZZi+9kPm/7R9IHtqJQXrb7hRoime/X/ 7GM2OmgeryRT63pyfOuA==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:58544 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oefEg-00088x-TV; Sat, 01 Oct 2022 12:21:07 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Sat, 1 Oct 2022 18:20:57 +0200 Message-Id: <20221001162058.8214-1-ludo@gnu.org> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1664641339; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=zTkeJCBbNwHI5BOVQL9SM/OKVMiiFjeDVcEzEzXUQa4=; b=Erv27340V+ooMhhNFmc6hI63klgW00iiF+kmfef4Tp4Z1PhNyZxQJICu4QtwXpVrsStNaE Cfyuoh1Ot/X9ia13cJssCXKyiL4fgO+GemfAFY1H3HbMTEHN/3M+pRx+WvQO2awjc9n9JU bmxPdTIIEJ81lFT58tcJv7jrSjPPngMLjlskNseme9sk/iFL60raL++P1vCFjoTcqeY7HX baUUh11SFCyvomL0MXnZAtFCbuxoFSWkU6JCa5g1prbkK+cLDztfGLCqTPKrt8u2QnokcM Qae9s+453appT4FaYNVzwwRvAsTIJxT88yHJwYuvft5PRlCg9PMLSzlmZ7ogQA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1664641339; a=rsa-sha256; cv=none; b=k55cvjkRSH2XqaKMgnBldSe4wlsEBz5XaQziz5BDlg6ICxAe07BtKYC0qNmcddVpVovjSh HYmI/Kw1JGvWLpsLhukdyGzoQB7tPIRAEZhOl6+h+OClQAKOtSqKGlvX1vljaX6fT5DB1b YM43RvbAF1vnjfE0dgLrd2IJEC/oPweyN0F4QYZ3Wzy5G6NldvDt2IUWL31IPmrFRRWDz/ U+uBx4WD0uabXsCZGKOiOmUwzVYmPsxYgmtPK45j/bWmcJEYqT8K/845VX9uiYYapkdT5n yP+9y3WrjC0Q7yScqaoGPQU1nSzCeoFgls3NyyiT0n5WLBUlvqHWC3+RNekGiw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b="bTch/j4n"; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.34 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b="bTch/j4n"; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 1A48A16618 X-Spam-Score: -2.34 X-Migadu-Scanner: scn0.migadu.com X-TUID: 9lnMbcGTgCxA With this change, we have: > ,expand (license? gpl3+) $2 = #t > ,expand (license? something-else) $3 = (let ((obj something-else)) (and ((@@ (srfi srfi-9) struct?) obj) ((@@ (srfi srfi-9) eq?) ((@@ (srfi srfi-9) struct-vtable) obj) (@@ (guix licenses) )))) * guix/licenses.scm (define-license-predicate) (begin-license-definitions): New macros : Wrap definitions in 'begin-license-definitions'. --- guix/licenses.scm | 58 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/guix/licenses.scm b/guix/licenses.scm index 3b820ae07e..80cf0f1114 100644 --- a/guix/licenses.scm +++ b/guix/licenses.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012, 2014, 2015, 2017, 2019, 2020 Ludovic Courtès +;;; Copyright © 2012, 2014, 2015, 2017, 2019, 2020, 2022 Ludovic Courtès ;;; Copyright © 2013, 2015 Andreas Enge ;;; Copyright © 2012, 2013 Nikita Karetnikov ;;; Copyright © 2015 Mark H Weaver @@ -109,13 +109,6 @@ (define-module (guix licenses) hpnd fsdg-compatible)) -(define-record-type - (license name uri comment) - license? - (name license-name) - (uri license-uri) - (comment license-comment)) - ;;; Commentary: ;;; ;;; Available licenses. @@ -129,6 +122,53 @@ (define-record-type ;;; ;;; Code: +(define-record-type + (license name uri comment) + actual-license? + (name license-name) + (uri license-uri) + (comment license-comment)) + +(define-syntax define-license-predicate + (syntax-rules (define define*) + "Define PREDICATE as a license predicate that, when applied to trivial +cases, reduces to #t at macro-expansion time." + ((_ predicate (variables ...) (procedures ...) + (define variable _) rest ...) + (define-license-predicate + predicate + (variable variables ...) (procedures ...) + rest ...)) + ((_ predicate (variables ...) (procedures ...) + (define* (procedure _ ...) _ ...) + rest ...) + (define-license-predicate + predicate + (variables ...) (procedure procedures ...) + rest ...)) + ((_ predicate (variables ...) (procedures ...)) + (define-syntax predicate + (lambda (s) + (syntax-case s (variables ... procedures ...) + ((_ variables) #t) ... + ((_ (procedures _)) #t) ... + ((_ obj) #'(actual-license? obj)) + (id + (identifier? #'id) + #'actual-license?))))))) + +(define-syntax begin-license-definitions + (syntax-rules () + ((_ predicate definitions ...) + (begin + ;; Define PREDICATE such that it expands to #t when passed one of the + ;; identifiers in DEFINITIONS. + (define-license-predicate predicate () () definitions ...) + + definitions ...)))) + +(begin-license-definitions license? + (define agpl1 (license "AGPL 1" "https://gnu.org/licenses/agpl.html" @@ -717,6 +757,6 @@ (define* (fsdg-compatible uri #:optional (comment "")) https://www.gnu.org/distros/free-system-distribution-guidelines.en.html#non-functional-data." (license "FSDG-compatible" uri - comment)) + comment))) ;;; licenses.scm ends here -- 2.37.3