all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: amirouche@hyper.dev
To: help-guix@gnu.org
Cc: Help-Guix <help-guix-bounces+amirouche=hyper.dev@gnu.org>
Subject: Re: guile scheme tutorial
Date: Sat, 04 May 2019 01:44:25 +0200	[thread overview]
Message-ID: <5b2251a3c4e5db01e983bfe2c7597f46@hyper.dev> (raw)
In-Reply-To: <dcd4113cfa1bbb4e004caca8f171fe9f@hyper.dev>

On 2019-05-03 14:45, amirouche@hyper.dev wrote:
> Hello!
> 
> 
> If you are getting started guix and want a glimpse of guile,
> I made a small tutorial that might get you started:
> 
>    https://github.com/a-guile-mind/book/#a-guile-mind-book

I was just made aware that the calculations results are not good
in the tutorial. I can not fix it right now. I will do it tomorrow.

You need to install guile-readline to have "normal" REPL:

   guix install guile-readline

Also, rekado made a package called guile-studio:

   This is Emacs with a few settings that make working
   with Guile easier for people new to Emacs.  Features
   include: CUA mode, Geiser, tool bar icons to evaluate
   Guile buffers, support for Guile's very own picture
   language, code completion, a simple mode line, etc.

And as noted above guile-picture-language.

In my usual workflow I don't rely only on emacs. I use somewhat
magit but for instance I don't use emacs-guix. ymmv. Anyway,
the goal of the tutorial is to get you started with scheme syntax.

The big omissions of the tutorial:

- macros, you can use macros without knowing how to write one.
   define-record-type is a macro. The package definition is a macro.
   Just remember that the evaluation of expressions in a macro is macro
   specific. Refer to an example or the documentation to learn how
   to use it.

- quasiquote, quote, unquote, unquote-splicing which is used a lot
   in guix package definitions. Their understanding and use are
   straight forward. They allow to describe a construction using
   the literal syntax e.g.:

     (list (cons 'a 42) ('b 101))

   Can be written:

     '((a . 42) (b 101))

   Which happens to be what the REPL give in the output plus the quote.

   Then if you have a variable around you can insert it inside a
   quasiquote with unquote e.g.:

      (define magic 42)
      `((a . ,magic) (b 101))

   quasiquote and unquote is used in most association lists. Like in 
package
   definition inputs, propagated inputs and the last one I don't 
remember.


One last advice, when you import a module in the REPL, it must be easier
to prefix the import (that will import everything public in that module)
so that you can TAB-complete the prefix to learn the content fo the 
module:


   (use-modules ((guix packages) #:prefix foo:))

Then when you type foo: in the REPL (or geiser) you get only what is in 
the
module prefixed with foo:

This is usually done in guile project, inside modules to avoid variable 
clash
but it is also helpful in the REPL to discover the content of a module.

The best way to learn code is to read good code like guix.

> Feel free to share your own resources to learn Guile Scheme.
> 
> Happy hacking!

  parent reply	other threads:[~2019-05-03 23:44 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-03 12:45 guile scheme tutorial amirouche
2019-05-03 17:15 ` Guy fleury
2019-05-03 21:11 ` Laura Lazzati
2019-05-03 23:44 ` amirouche [this message]
2019-05-04  1:51 ` rendaw
2019-05-04  6:08 ` rendaw
2019-05-04  8:57   ` Ludovic Courtès
2019-05-07  4:35     ` rendaw
2019-05-08 12:46       ` Ludovic Courtès
2019-05-08 13:15         ` Pierre Neidhardt
2019-05-08 16:35           ` swedebugia
2019-05-13  7:10             ` rendaw
2019-05-13  8:00               ` Pierre Neidhardt
2019-05-08 20:21           ` Guix cookbook (was: guile scheme tutorial) Ricardo Wurmus
2019-05-09 15:14             ` Pierre Neidhardt
2019-05-09 21:38               ` Ricardo Wurmus
2019-05-13  9:08                 ` Guix cookbook swedebugia
2019-05-04 11:02   ` guile scheme tutorial amirouche
2019-05-04 11:25     ` Laura Lazzati
2019-05-07  2:15     ` rendaw
2019-05-07  7:09       ` amirouche
2019-06-06 15:45 ` Laura Lazzati

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5b2251a3c4e5db01e983bfe2c7597f46@hyper.dev \
    --to=amirouche@hyper.dev \
    --cc=help-guix-bounces+amirouche=hyper.dev@gnu.org \
    --cc=help-guix@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.