From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id 6N3tCumWS2fjiAAAe85BDQ:P1 (envelope-from ) for ; Sat, 30 Nov 2024 22:51:21 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id 6N3tCumWS2fjiAAAe85BDQ (envelope-from ) for ; Sat, 30 Nov 2024 23:51:21 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=cock.li header.s=mail header.b=mBI7AeRT; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=quarantine) header.from=cock.li ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1733007081; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=e09MeUmBl57wgoy+yoar2YlN8lD6oadVih0seElREs8=; b=W0QqjtkhyrgtdGcp9tCyJ9btX3/FSzv9iSvqnj61Mq7Fjbe1+2pOW2JDI0E1HP5OJzEoVu D1QxtL9AbmabAzsqTsad/hzJpqYk5JPCF8uH1CljSdmva/pLodpf7DG0xFVX7lZmOEid9c aj9/1OT7WUw1G1bBMGR8pns1UdWR0zJnrPraNH1Tde6IZVeO0fvtF1U5F+pMaZUDBMDCxK /Cjf4S0dLVLhka2A2oMOlm/ZehdYLqnm2jftzAYvtgZADWJYjkLVaXsyA3XaQ5eaMRtY3/ 4urkuVNj3lVib2V/RXIaeE/OVY4rJw40HQHc2U6lZDA1fwEkY5mQ9kMiox6mdQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=cock.li header.s=mail header.b=mBI7AeRT; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=quarantine) header.from=cock.li ARC-Seal: i=1; s=key1; d=yhetil.org; t=1733007081; a=rsa-sha256; cv=none; b=JLTmmBA5dF8wK3PraOkJvEK7otYBKS6yqArE64AxUaQZi2L56m7umIO8iqVDwnzKlz50h5 19ayvrcuPFmRV0LOaLZJImJaYSJUIjTU99Ctnf9Obnc9kKWbX1GtCfWosI2eN8820bXcD3 XkDBkiICyAqdM586DiLNHEA6eKQ0kYzGpjDzypcwtf1uAZCDf9LEPriMTo4jeNwBmhBjBU lYgp69vD6A6H3J/L8xjdAgWUYdONu4a9tovZdZBEI7itLmUuFNUzKgRZOZheta8r0TXDAj cbXdn9tHywz1Sf08WWLCJ1ceZypFM2bQh8aa8ImNReOXmbxu/FgcoNYb+1HPTw== 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 025EC7D072 for ; Sat, 30 Nov 2024 23:51:20 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tHWIM-0006kw-Uq; Sat, 30 Nov 2024 17:50:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tHWIK-0006kT-CI for guix-devel@gnu.org; Sat, 30 Nov 2024 17:50:32 -0500 Received: from mail.cock.li ([37.120.193.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tHWII-0005yW-Em for guix-devel@gnu.org; Sat, 30 Nov 2024 17:50:32 -0500 From: Justin Veilleux DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cock.li; s=mail; t=1733007016; bh=LXk92qVrjZis6m2v+WMSy9gtHa10TiQsSa98oekxeaA=; h=From:To:Subject:Date:From; b=mBI7AeRTFJRxSLaK0flHpr0tcye2tW3Ke7oY/0teOmoaGx0M6PPCwuPu424/xAzf+ Vl5g9bdPDZywGWWTtU5SZy9+ZRepciqy8BeP0c4dGaAis83FddihIKxmhE2u02Dbqi 7Urrrmp382b5ukrnGhnIT2F8A+19AnBH11zDrhIcnC651XMq9reFTv0qnMKi2qn9Uw aFqmq6mJEjJUiEUMibSwQlGGxrpeDXkOsFSgUrvbeDjOiI9gTi7BSI6NbkEWrEjc4P hEwxF9NnxHyVLiLvyQ0wIst1ovpNWoxah1Y8agm7n4/mbE1BmWvLce2ZZI09hbAUti moUyd/N5yKdxg== To: guix-devel@gnu.org Subject: Alternative syntax for interacting with the store monad Date: Sat, 30 Nov 2024 17:50:14 -0500 Message-ID: <875xo49w0p.fsf@cock.li> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=37.120.193.124; envelope-from=terramorpha@cock.li; helo=mail.cock.li X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_PBL=3.335, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: guix-devel-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Scanner: mx11.migadu.com X-Migadu-Spam-Score: -1.85 X-Spam-Score: -1.85 X-Migadu-Queue-Id: 025EC7D072 X-TUID: X0uVGNFTmk3t Hello. I was reading https://guix.gnu.org/en/blog/2023/dissecting-guix-part-2-the-store-monad/ and was wondering if using Guile scheme's ~call-with-prompt~ for interacting with the store monad had been considered. With ~call-with-prompt~, one can recreate an ~async-await~-like syntax in scheme. I think using this syntax (instead of the ~mlet~ macros and ~store-bind~) might be easier to use for beginners as many people already intuitively know how to use ~async&await~ which is not the case for the "explicitely monadic" operations. Here is a snippet of code illustrating how one could use any monad (with functions ~bind-fn~ and ~pure-fn~) through the more readable ~async&await~ forms. #+begin_src scheme (define-syntax-parameter bind (lambda (s) (syntax-violation 'bind "bind used outside `with-monad`" s))) (define-syntax-parameter pure (lambda (s) (syntax-violation 'pure "pure used outside `with-monad`" s))) (define-syntax-rule (with-monad bind-fn pure-fn body body* ...) (let ((bind-fn bind-fn) (pure-fn pure-fn) (prompt-tag (make-prompt-tag))) (syntax-parameterize ((bind (lambda (s) (syntax-case s () ((_ x) #'(abort-to-prompt prompt-tag x))))) (pure (lambda (s) (syntax-case s () ((_ x) #'(pure-fn x)))))) (define (handler kont mval) (bind-fn mval (lambda (x) (call-with-prompt prompt-tag (lambda () (kont x)) handler)))) (call-with-prompt prompt-tag (lambda () body body* ...) handler)))) (define (list-bind xs f) (apply append! (map f xs))) (define list-pure list) (with-monad list-bind list-pure (let ((x (bind '(1 2)))) (pure (list x (bind '("thing1" "thing2")))))) ;; => ((1 "thing1") (1 "thing2") (2 "thing1") (2 "thing2")) #+end_src Maybe the the performance costs associated with using delimited continuations are too high? What do you think?