help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: guile scheme tutorial


From: amirouche
Subject: Re: guile scheme tutorial
Date: Sat, 04 May 2019 01:44:25 +0200
User-agent: Roundcube Webmail/1.3.8

On 2019-05-03 14:45, address@hidden 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!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]