From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: Re: my latest blog post Date: Sat, 09 Jun 2018 14:14:58 +0200 Message-ID: <878t7o17i5.fsf@elephly.net> References: <87bmcmzfyz.fsf@netris.org> <87lgbpp31h.fsf@netris.org> <87a7s41bwz.fsf@elephly.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRcm4-0004M2-6f for guix-devel@gnu.org; Sat, 09 Jun 2018 08:15:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRcm1-0003FS-0a for guix-devel@gnu.org; Sat, 09 Jun 2018 08:15:16 -0400 Received: from sender-of-o51.zoho.com ([135.84.80.216]:21009) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fRcm0-0003Ex-Nk for guix-devel@gnu.org; Sat, 09 Jun 2018 08:15:12 -0400 In-reply-to: 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+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Catonano Cc: guix-devel Hi Catonano, > 2018-06-09 12:39 GMT+02:00 Ricardo Wurmus : > >> >> Catonano writes: >> >> > Assuming that users read academic articles about programming languages= in >> > order to know your way aroung Guile is not reasonable >> >> I fail to see how this follows from Guile=E2=80=99s lack of a macro step= per. > > > Then you were not following > > Mark indicated me a paper about the first macro stepper in history I did follow the discussion and I did see Mark mentioning the paper. Since Guile does not *have* a macro stepper, reading a paper about how a macro stepper was implemented is certainly not a requirement to use Guile. Obviously, to implement a macro stepper it is useful to know how to do this. But implementing a macro stepper is not what a Guile user like myself would ever do. >> And I have >> never felt the need to read computer science papers to =E2=80=9Cknow my = way >> around Guile=E2=80=9D. (I have not studied computer science, so it isn= =E2=80=99t that >> my background allowed me to skip papers that are mandatory for other >> users of Guile.) >> >> The sentence above seems like an exaggeration to me. >> > > Ok, thans for your contribution > > >> (I say this with no hostility, just with surprise.) >> > > we have a loooong way to go I sense a lot of hostility in your responses to me and I don=E2=80=99t know= why that is. The first sentence reads like unwarranted sarcasm to me, because it does not seem to relate to what I wrote; the second sounds belittling, as if my surprise at what seems like an exaggeration to me is evidence of how far behind I am in my efforts to ensure that Guix and Guile a welcoming to newcomers. I=E2=80=99m sorry that you don=E2=80=99t find anything useful in my respons= e above, which relates my personal experience with Guile as someone who is not a computer scientist. I hoped it would be a useful data point. As I find discussions like this exceptionally draining and discouraging, detrimental to my ability to volunteer time to free software, I will take some time off from this discussion after trying to respond to your other message to me in this thread. >> > The monad accessing the daemon, how would I delve in it ? >> >> The Guix manual should explain it fully, while assuming that the concept >> of a monad is known (because that=E2=80=99s not a Guix or Guile inventio= n). > > > And how would I know what a monad is without reading academic materials ? > > Maybe Haskell is a requirement in order to use Guile//Guix ? > > "assuming that the concept of a monad is known" is a problem. By analogy, do you think that assuming the concept of recursion would be a problem? Or the concept of a closure? Would you say that this should be explained in the *Guix* manual? (These are sincere questions.) We are using both of these constructs. We are also using delayed evaluation in the form of streams. Luckily, those are provided as a Guile library and are thus documented in the *Guile* manual. > Someone would want to _learn_ what a monad is AND how it can be implement= ed > in scheme, by dissecting this Guix macro based feature I used =E2=80=9C,expand=E2=80=9D in the past to see the expansion of a macro expression. Here=E2=80=99s an example with the state monad: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> ,expand (with-monad %state-monad (return 1)) $3 =3D (let ((value 1)) (lambda (state) ((@@ (guix monads) values) value state))) --8<---------------cut here---------------end--------------->8--- This shows us that returning a monadic value in the state monad is the same as returning a procedure that takes some state and returns it alongside the value. The Guix manual says about the things that we used: --8<---------------cut here---------------start------------->8--- -- Scheme Syntax: with-monad MONAD BODY ... Evaluate any =E2=80=98>>=3D=E2=80=99 or =E2=80=98return=E2=80=99 forms= in BODY as being in MONAD. -- Scheme Syntax: return VAL Return a monadic value that encapsulates VAL. --8<---------------cut here---------------end--------------->8--- Earlier, it also says something about what monads are all about: --8<---------------cut here---------------start------------->8--- This is where the =E2=80=98(guix monads)=E2=80=99 module comes in. This= module provides a framework for working with =E2=80=9Cmonads=E2=80=9D, and a parti= cularly useful monad for our uses, the =E2=80=9Cstore monad=E2=80=9D. Monads are a= construct that allows two things: associating =E2=80=9Ccontext=E2=80=9D with values (= in our case, the context is the store), and building sequences of computations (here computations include accesses to the store). Values in a monad=E2=80=94val= ues that carry this additional context=E2=80=94are called =E2=80=9Cmonadic valu= es=E2=80=9D; procedures that return such values are called =E2=80=9Cmonadic procedures= =E2=80=9D. --8<---------------cut here---------------end--------------->8--- We=E2=80=99ve just seen the first part about associating =E2=80=9Ccontext= =E2=80=9D (in this case some state) with values. The second part requires a larger expression to see how this is useful. The Guix manual has an example right there: --8<---------------cut here---------------start------------->8--- -- Scheme Syntax: >>=3D MVAL MPROC ... =E2=80=9CBind=E2=80=9D monadic value MVAL, passing its =E2=80=9Cconten= ts=E2=80=9D to monadic procedures MPROC...(1). There can be one MPROC or several of them, as in this example: (run-with-state (with-monad %state-monad (>>=3D (return 1) (lambda (x) (return (+ 1 x))) (lambda (x) (return (* 2 x))))) 'some-state) =E2=87=92 4 =E2=87=92 some-state --8<---------------cut here---------------end--------------->8--- So this is an expression that somewhat uselessly computes the number 4 in a context where =E2=80=9Csome-state=E2=80=9D is present. We can use ,ex= pand in the REPL to see how this works, this time with a slightly simpler expression that would compute 1 + 1 in some given context: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> ,expand (with-monad %state-monad (>>=3D (return 1) (lambda (x) (return (+ 1 x))))) $6 =3D (let ((mvalue (let ((value 1)) (lambda (state) ((@@ (guix monads) values) value state)))) (mproc (lambda (x) (let ((value (+ 1 x))) (lambda (state) ((@@ (guix monads) values) value state)))))) "Bind MVALUE, a value in the state monad, and pass it to MPROC." (lambda (state) ((@@ (guix monads) call-with-values) (lambda () (mvalue state)) (lambda (value state) ((mproc value) state))))) --8<---------------cut here---------------end--------------->8--- This looks similar to the previous expression (see =E2=80=9Cmvalue=E2=80=9D= ). Looking at the body, we see that this is a procedure that takes some state, computes a new value by passing the state to =E2=80=9Cmvalue=E2=80=9D, and = then passes that to the next action (the last lambda in the original expression). I don=E2=80=99t think that the presence of the relevant documentation in the Guix manual and the existence of a macro-expansion facility should be taken as evidence that we =E2=80=9Cthink that the code should be kept obscu= re and unaccessible=E2=80=9D. I would also like to state, though, that the use of the state monad is hardly essential for the purpose of extending or contributing to Guix. If you find a way to improve the existing documentation, you know from our past interactions that the maintainers and developers are very welcoming of additions or changes to the manual. -- Ricardo