[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: guile scheme tutorial
Re: guile scheme tutorial
Sat, 04 May 2019 01:44:25 +0200
On 2019-05-03 14:45, address@hidden wrote:
If you are getting started guix and want a glimpse of guile,
I made a small tutorial that might get you started:
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
definition inputs, propagated inputs and the last one I don't
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
(use-modules ((guix packages) #:prefix foo:))
Then when you type foo: in the REPL (or geiser) you get only what is in
module prefixed with foo:
This is usually done in guile project, inside modules to avoid variable
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.
- guile scheme tutorial, amirouche, 2019/05/03
- Re: guile scheme tutorial, Guy fleury, 2019/05/03
- Re: guile scheme tutorial, Laura Lazzati, 2019/05/03
- Re: guile scheme tutorial,
- Re: guile scheme tutorial, rendaw, 2019/05/04
- Re: guile scheme tutorial, Ludovic Courtès, 2019/05/04
- Re: guile scheme tutorial, rendaw, 2019/05/07
- Re: guile scheme tutorial, Ludovic Courtès, 2019/05/08
- Re: guile scheme tutorial, Pierre Neidhardt, 2019/05/08
- Re: guile scheme tutorial, swedebugia, 2019/05/08
- Re: guile scheme tutorial, rendaw, 2019/05/13
- Re: guile scheme tutorial, Pierre Neidhardt, 2019/05/13
- Guix cookbook (was: guile scheme tutorial), Ricardo Wurmus, 2019/05/08
- Re: Guix cookbook (was: guile scheme tutorial), Pierre Neidhardt, 2019/05/09