From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id iFtlAlVp1WPY9AAAbAwnHQ (envelope-from ) for ; Sat, 28 Jan 2023 19:28:37 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id SAJFAlVp1WOnUAEAauVa8A (envelope-from ) for ; Sat, 28 Jan 2023 19:28:37 +0100 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 D628820857 for ; Sat, 28 Jan 2023 19:28:36 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pLpw5-0001k7-Ok; Sat, 28 Jan 2023 13:28:21 -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 1pLpw4-0001jv-Fj; Sat, 28 Jan 2023 13:28:20 -0500 Received: from server0.selfhosted.xyz ([217.64.149.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pLpw1-00013Q-OW; Sat, 28 Jan 2023 13:28:20 -0500 Received: from server0.selfhosted.xyz (localhost [127.0.0.1]) by server0.selfhosted.xyz (Postfix) with ESMTP id CB6442E97205; Sat, 28 Jan 2023 19:28:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=selfhosted.xyz; s=dkim; t=1674930488; bh=CG9wNBAv3QjWKb9/GKMyWNLBknzHfG29Omz3Dt1K7gE=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=v3N/5TjvdoCwy6LdMoUq9/f9F+clR3EbEGyO5qPwpzFynEHYmh79VdQaJHqSWr90y FNJIiTo4tqyXbwwzr1wvuaodG5FJSjuzpOWY2BOFOuBGzQhaJ9SaOre3bYZX0NHAey wXp2GEIDdTjeeGAdqXOWP7GtRUb3OAEI4WsftRs55pSZL5fg5Ys44jum/x7PqSvz/h rCk88iB5l2QgUQ4BVR03qktstQUTgHyfMmMTlVRSABNuvIx34OzKJ8cjxxTb/LTa3J 7LF3G0D643jzoz/9YdKVzenaJ2wEQebGyPd6DCW8nr+QBtawNwijVYJOLuBeXaa42/ ArLnsB+A1d3iA== X-Fuglu-Suspect: ca6c002299724f7ab3224afe1bb7a20a X-Fuglu-Spamstatus: NO Received: from webmail.selfhosted.xyz (office.selfhosted.xyz [192.168.1.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: mail@selfhosted.xyz) by server0.selfhosted.xyz (Postfix) with ESMTPSA; Sat, 28 Jan 2023 19:28:02 +0100 (CET) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=_61ab33ddc6be93f7658f48876f02154e" Date: Sat, 28 Jan 2023 19:28:02 +0100 From: david larsson To: "(" Cc: guix-devel@gnu.org, guix-devel-bounces+david.larsson=selfhosted.xyz@gnu.org Subject: Re: Struggling to write Dissecting Guix, Part 2 In-Reply-To: References: Message-ID: X-Sender: david.larsson@selfhosted.xyz Received-SPF: pass client-ip=217.64.149.7; envelope-from=david.larsson@selfhosted.xyz; helo=server0.selfhosted.xyz X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 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, FROM_SUSPICIOUS_NTLD=0.499, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_PDS_OTHER_BAD_TLD=0.01 autolearn=ham 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1674930516; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=CG9wNBAv3QjWKb9/GKMyWNLBknzHfG29Omz3Dt1K7gE=; b=NJhOffFEjXnSJI/DrR2CfbDG+LGF9vMbyJ/HqkQ62MpbfxEQn3KR32TA+XxhrtJnDody2J nMAD+FJ7MEsMxLE5s+pcwLk+1S1iywnfVvET2mEQym1kKV0FBPCXCSaKYP8iHHO8lEhaIA Dqlqy6REbD+1hebs5REAhZrSk2z71BeUUBfqs6+5g4D+F4X/IaoBNMlemciSGY97yKXqCl amlLeD7HC0a0x01QIOgMyZXiZKiGj+eBCsy/y1PZxHjGo4N4Yq+IQgdZTUQspNfhKghl/2 muWPWrTUokJ22zQFV2AM312ToMsE3CcOtm50sOgMaGrQTnIhKMlPa4xIDAxgPA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=selfhosted.xyz header.s=dkim header.b="v3N/5Tjv"; dmarc=pass (policy=none) header.from=selfhosted.xyz; 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1674930516; a=rsa-sha256; cv=none; b=WRetg30FKfk/9CCagK1IPWbYYbke+PsL/dxCBXblhEoCNmBpTsv+fo4Lze/9e9F3MpjeNh u/xof5urQV4S/Kk+NP8moFXzwcMLhussQ/zhVgYl7bDdMNqtm/7bqYa+4nUi5JSAhjH1Ba zyUJqQJ1/hgdaCgo7h1Ay2CQUfTfXZ1CL7UWk//NqCr9tSVL9Bz3iwrX4UmtEYcX/Issnq O+/qtz6FU9nnOohs+Cm2uSj5VZ74rd6kOhv436+ZwlvNlFRUxdGIR1M9wBrIwvBTvVZoZG yi1D/junmbh5lORlEM8KDFQkagVtHXDkGC4hsKbQIm0n/VdVxP0/oOFoOFE6MQ== X-Spam-Score: -3.67 X-Migadu-Spam-Score: -3.67 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=selfhosted.xyz header.s=dkim header.b="v3N/5Tjv"; dmarc=pass (policy=none) header.from=selfhosted.xyz; 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" X-Migadu-Queue-Id: D628820857 X-Migadu-Scanner: scn1.migadu.com X-TUID: O7QuXx+4btjS --=_61ab33ddc6be93f7658f48876f02154e Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed On 2023-01-26 07:34, ( wrote: > On Wed Jan 25, 2023 at 7:39 PM GMT, david larsson wrote: >> https://towardsdatascience.com/monads-from-the-lens-of-imperative-programmer-af1ab8c8790c > > I'm not too sure about this one, I'm afraid. > > -- ( What are you not too sure about? There is also pseudo-code (so not python) version of it on Wikipedia that's almost identical: https://en.wikipedia.org/wiki/Monad_(functional_programming)#Program_logging I thought the wikipedia version is kind of clearer mainly because it's a little more "complete"-feeling. I added some stuff myself to the first article making it more like the wikipedia, etc, the and attached it here if anyone's interested. That's still in python, but if I ever were to write a monad in guile, I'd almost certainly start with trying to translate this one. Best regards, David --=_61ab33ddc6be93f7658f48876f02154e Content-Transfer-Encoding: base64 Content-Type: text/x-python; name=mathlogsmonad-mini.py Content-Disposition: attachment; filename=mathlogsmonad-mini.py; size=1941 ZnJvbSB0eXBpbmcgaW1wb3J0IFR1cGxlCmRlZiBzcXVhcmUobnVtOiBpbnQpIC0+IGludDoKICAg IHJldHVybiBudW0gKiBudW0KZGVmIGRvdWJsZShudW06IGludCkgLT4gaW50OgogICAgcmV0dXJu IG51bSArIG51bQpkZWYgc3F1YXJlX3dpdGhfcHJpbnRfcmV0dXJuKG51bTogaW50KSAtPiBUdXBs ZVtpbnQsIHN0cl06CiAgICBsb2dzID0gIkN1cnJyZW50IG51bSAiICsgc3RyKG51bSkgKyAiLiAi CiAgICByZXR1cm4gKHNxdWFyZShudW0pLCBsb2dzKQpkZWYgZG91YmxlX3dpdGhfcHJpbnRfcmV0 dXJuKG51bTogaW50KSAtPiBUdXBsZVtpbnQsIHN0cl06CiAgICBsb2dzID0gIkN1cnJyZW50IG51 bSAiICsgc3RyKG51bSkgKyAiLiAiCiAgICByZXR1cm4gKGRvdWJsZShudW0pLCBsb2dzKQpkZWYg YmluZChmdW5jLCB0dXBsZTogVHVwbGVbaW50LCBzdHJdKSAtPiBUdXBsZVtpbnQsIHN0cl06CiAg ICByZXMgPSBmdW5jKHR1cGxlWzBdKQogICAgcmV0dXJuIChyZXNbMF0sIHR1cGxlWzFdICsgcmVz WzFdKQpkZWYgdW5pdChudW1iZXI6IGludCkgLT4gVHVwbGVbaW50LCBzdHJdOgogICByZXR1cm4g KG51bWJlciwgIiIpCgojIE5vdyB5b3UgY2FuIGRvIHRoaXMsIG1vcmUgb3IgbGVzcyBuZXN0ZWQ6 CiNwcmludChiaW5kKHNxdWFyZV93aXRoX3ByaW50X3JldHVybiwgdW5pdCg1KSkpCiNwcmludChi aW5kKHNxdWFyZV93aXRo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