Guile-Config 0.1 Released

2016-02-16 Thread Alex Sassmannshausen
Hello,

I have the pleasure of officially announcing the first release of
Guile-Config.

Guile Config is a library providing a declarative approach to application
configuration specification.  The library provides clean configuration
declaration forms, and processors that take care of:

- Configuration file creation
- Configuration file parsing
- Command-line parameter parsing using getopt-long
- Basic GNU command-line parameter generation (--help, --usage, --version)
- Output generation for (compiled from the configuration declaration):
  + --help and --usage
  + --version

You can download the release tarball at:
  http://alex.pompo.co/software/guile-config-0.1.tar.gz

You can find the git repository at:
  https://github.com/a-sassmannshausen/guile-config

Both addresses may well be augmented soon to Savannah based addresses.

You should only need Guile to perform the usual
  ./configure && make && make install

Documentation can be found as an info manual that is part of the
tarball.

You can also conveniently install guile-config using Guix:
  guix package -i guile-config

(the patch for guile-config is pending, so the above command will not
work yet — but it should in a few days).

Any feedback or comments welcome.

Happy hacking!

Alex


signature.asc
Description: PGP signature


[potluck dish] an small GTP lib for playing Go game with Scheme

2016-02-16 Thread Nala Ginrut
GTP stands for Go Text Protocol is a protocol used by several engines
for playing the board game Go on the computer. The GTP1 is implemented
in GNU Go.

Maybe someone here remember the news:
Google’s AI beat a professional Go player
http://siliconangle.com/blog/2016/01/27/googles-ai-beat-a-professional-go-player-and-its-kind-of-a-big-deal/

Well, at that time I feel I'd like to try to play Go with Scheme on my
own way. ;-)

I was busy to celebrate Chinese new year last few weeks, so I didn't
have much time to hack. ;-P
This project is still preliminary, but it works if you installed GNU Go.

I'd like to implement some algorithms on it to make sure Guile has
little AI. ;-D

Here it is:
https://github.com/NalaGinrut/goile





[potluck dish] the module (potluck regexc)

2016-02-16 Thread Matt Wette
The (potluck regexc) module provides a macro for throwing a stringat a sequence of regular expressions, executing an associated bodywhen a match is found.Attached are three files:* regexc.scm: the source code* regexc.texi: documentation* regexc.test: test codeRegexp Utilities -- Scheme Procedure: regexp-case str case ... [else body]     Match the string STR against each CASE in turn.  Each CASE is of     the form          ((pat VAR1 VAR2 ...)           body)     where pat is a regular _expression_ string literal, VAR1 ... are     bound to the ordered list of matched subexpressions, and BODY is a     sequence of expressions.  If no match is found and the optional     ELSE case exists, the associated body is executed, otherwise an     error is signaled.   The following example matches a string aginst either a simplevariable name, or a simple variable name with an array reference, andreturns a list with the variable name and the string index, or '"1"'.If no match is found, '#f' is returned.     (define str "foo")     (regexp-case str      (("^([a-z]+)\\(([0-9]+)\\)$" var idx)       (list var idx))      (("^([a-z]+)$" var)       (list var "1"))      (else #f))     ==>     ("foo" "1") -- Scheme Procedure: make-string-matcher (str ...) case ... [else body]     This is similar to 'regexp-case' but generates a procedure '(lambda     (str ...) ...)' that matches its string argument STR againt each     CASE in turn.     (define my-matcher       (make-string-matcher (str a b c)        (("^([a-z]+)\\(([0-9]+)\\)$" var idx)         (list var idx))        (("^([a-z]+)$" var)         (list var "1"))        (else #f))

regexc.scm
Description: Binary data


regexc.test
Description: Binary data


regexc.texi
Description: Binary data


[potluck dish] the (potluck struct) module

2016-02-16 Thread Matt Wette
If you have used the Python struct module then this will lookfamiliar.  Otherwise, check outhttps://docs.python.org/2/library/struct.htmlAttached are three files: * struct.scm: the source code * struct.texi:documentation * struct.test: test codeStruct Module =The '(potluck struct)' module provides procedures for packing andunpacking scheme data to and from bytevectors based on a formatstring.     (use-modules (potluck struct))     ;; pack two unsigned shorts and a double float in big endian     order (define data (pack ">2Hd" 3 22 34.0)) (write data)     (newline) ==> #vu8(0 3 0 22 64 65 0 0 0 0 0 0)     ;; verify using unpack (write (unpack ">2Hd" data)) (newline) ==>     (3 22 34.0) -- Scheme Procedure: pack format vals ...  Return a bytevector that     contains encoded data from VALS, based on the string FORMAT. -- Scheme Procedure: unpack format bvec Return a list of scheme     objects decoded from the bytevector BVEC, based on the string     FORMAT. -- Scheme Procedure: packed-size format Return the number of bytes     represented by the string FORMAT.   The _format_ string used for PACK and UNPACK is constructed as asequence of digits, representing a repeat count, and codes,representing the binary content.The string may optionally begin with a special character thatrepresents the endianness: = native endianness < little-endian >big-endian !  network order -- i.e., big-endianType codes used in the format string are interpreted as follows: x    blank byte c 8-bit character ?  boolean b signed 8-bit integer B    unsigned 8-bit integer h signed 16-bit integer H unsigned 16-bit    integer i signed 32-bit integer I unsigned 32-bit integer l signed    32-bit integer L unsigned 32-bit integer q signed 64-bit integer Q    unsigned 64-bit integer f 32-bit IEEE floating point d 64-bit IEEE    floating point s string   The following issues remain to be addressed: string padding 'pack'assumes that the string length in the format is the same as in thepassed string.  Non-conformance is not trapped as an error.

struct.scm
Description: Binary data


struct.test
Description: Binary data


struct.texi
Description: Binary data


Re: [potluck dish] the (potluck struct) module

2016-02-16 Thread Matt Wette
First message got garbled.  Redo:

If you have used the Python struct module then this will look familiar.
Otherwise, check out https://docs.python.org/2/library/struct.html

Attached are three files:
* struct.scm: the source code 
* struct.texi: documentation 
* struct.test: test code

Struct Module
=

The '(potluck struct)' module provides procedures for packing and
unpacking scheme data to and from bytevectors based on a format string.

 (use-modules (potluck struct))

 ;; pack two unsigned shorts and a double float in big endian order
 (define data (pack ">2Hd" 3 22 34.0))
 (write data) (newline)
 ==>
 #vu8(0 3 0 22 64 65 0 0 0 0 0 0)

 ;; verify using unpack
 (write (unpack ">2Hd" data)) (newline)
 ==>
 (3 22 34.0)

 -- Scheme Procedure: pack format vals ...
 Return a bytevector that contains encoded data from VALS, based on
 the string FORMAT.

 -- Scheme Procedure: unpack format bvec
 Return a list of scheme objects decoded from the bytevector BVEC,
 based on the string FORMAT.

 -- Scheme Procedure: packed-size format
 Return the number of bytes represented by the string FORMAT.

   The _format_ string used for PACK and UNPACK is constructed as a
sequence of digits, representing a repeat count, and codes, representing
the binary content.

The string may optionally begin with a special character that represents
the endianness:
=native endianness
big-endian
!network order -- i.e., big-endian

Type codes used in the format string are interpreted as follows:
xblank byte
c8-bit character
?boolean
bsigned 8-bit integer
Bunsigned 8-bit integer
hsigned 16-bit integer
Hunsigned 16-bit integer
isigned 32-bit integer
Iunsigned 32-bit integer
lsigned 32-bit integer
Lunsigned 32-bit integer
qsigned 64-bit integer
Qunsigned 64-bit integer
f32-bit IEEE floating point
d64-bit IEEE floating point
sstring

   The following issues remain to be addressed:
string padding
 'pack' assumes that the string length in the format is the same as
 in the passed string.  Non-conformance is not trapped as an error.



[potluck dish] attributed variables for minikanren

2016-02-16 Thread Stefan Israelsson Tampe
I repost this as a separate thread, the code had been debugged and a few
loopholes patched
since last anouncement.


Hey Guilers

My potluk contibution is tp implement attributed variables for minikanren
ontop af the source written by  William E. Byrd.

You can find the source at https://gitlab.com/tampe/attributed-minikanren

The source containes examples using attributed variables to implement =/=
symbolo numbero absento freezeo and wheno

API
(define AttributeId  (make-attribute unify-fkn portray-fkn)

(unify-fkn var data val lam)
var is the varibale that is unified (not yet unified at the execution of
this fkn) data is the data associated with AttributedId for variable var
and val is the value that var will be unified to and lam is a variable that
can be bound to a predicate to be executed after the unification have
been taken.

(portray-fkn var data s)
Return a list of  representations of attribuete AttributedId with data data
for variable var. s is the variable binding stack.

(get-attr var id data)
Get data associated with attributed id if no attribute exists fail

(put-attr var id data)
Put attributed data data of kind id to variable var.

New Examples
(wheno (cons test1 lam1) (cons test2 lam2) u1 u2 ...)
If u1 u2 ... is bound then before bounding test1 will by tried with no
unification as a result and if success lam2 will be executed else the
binding will fail
then the variable will be bound and test2 lam2 combo will be tried
similarly, the conses can be repaced with #f to indicate a void semantics.

(freezeo u lam1 lam2)
before the binding of u lam1 will be tried and after the binding of u lam2
will be tried.

The rest of the constraints was implemented by other means before and is
known please read the documentation by  William E. Byrd.

Regards
Stefan


[potluck dish] the module (potluck struct)

2016-02-16 Thread Matt Wette
If you have used the Python struct module then this will lookfamiliar.  Otherwise, check outhttps://docs.python.org/2/library/struct.htmlAttached are three files: * struct.scm: the source code * struct.texi:documentation * struct.test: test codeStruct Module =The '(potluck struct)' module provides procedures for packing andunpacking scheme data to and from bytevectors based on a formatstring.     (use-modules (potluck struct))     ;; pack two unsigned shorts and a double float in big endian     order (define data (pack ">2Hd" 3 22 34.0)) (write data)     (newline) ==> #vu8(0 3 0 22 64 65 0 0 0 0 0 0)     ;; verify using unpack (write (unpack ">2Hd" data)) (newline) ==>     (3 22 34.0) -- Scheme Procedure: pack format vals ...  Return a bytevector that     contains encoded data from VALS, based on the string FORMAT. -- Scheme Procedure: unpack format bvec Return a list of scheme     objects decoded from the bytevector BVEC, based on the string     FORMAT. -- Scheme Procedure: packed-size format Return the number of bytes     represented by the string FORMAT.   The _format_ string used for PACK and UNPACK is constructed as asequence of digits, representing a repeat count, and codes,representing the binary content.The string may optionally begin with a special character thatrepresents the endianness: = native endianness < little-endian >big-endian !  network order -- i.e., big-endianType codes used in the format string are interpreted as follows: x    blank byte c 8-bit character ?  boolean b signed 8-bit integer B    unsigned 8-bit integer h signed 16-bit integer H unsigned 16-bit    integer i signed 32-bit integer I unsigned 32-bit integer l signed    32-bit integer L unsigned 32-bit integer q signed 64-bit integer Q    unsigned 64-bit integer f 32-bit IEEE floating point d 64-bit IEEE    floating point s string   The following issues remain to be addressed: string padding 'pack'assumes that the string length in the format is the same as in thepassed string.  Non-conformance is not trapped as an error.

struct.scm
Description: Binary data


struct.test
Description: Binary data


struct.texi
Description: Binary data


[potluck dish] an hyper-graphdb known as culture

2016-02-16 Thread Amirouche Boubekki

Héllo!!

# Introduction

For the potluck I prepared a release of a database I've been working
on as part of an AI project that try to implement opencog.org [1] in
pure scheme (or mostly pure scheme).

This dish contains the database part called AtomSpace in OpenCog which
is an hypergraph database. The summarize what is an hyper graph
database.

The following summarize the what is an hypergraph database then, I
conclude with the other features:

# hyper graph API

## `(create-atom #:optional (assoc '()))`

Create an `` with `ASSOC`.

## `(atom-link! atom other context)`

Create a direct link between `ATOM` and `OTHER` inside the database
referenced by `CONTEXT`

# culture database

Culture has as extra features an: exact an index and a fuzzy index. A
spatial index [2] was also started but I did not have time to complete 
it.


The database is implemented on top of wiredtiger [3].

Right now it's hosted at github [4] but you can find all the pieces as
attachment.

HTH and happy hacking!

[1] OpenCog is an Artificial General Intelligence framework.
[2] See znumber.scm
[3] https://git.framasoft.org/a-guile-mind/guile-wiredtiger
[4] https://github.com/amirouche/culturia

--
Amirouche ~ amz3 ~ http://www.hyperdev.fr
# culturedb


## Kesako culturedb?

`culturedb` is hypergraph database ie. a graph database with single
kind of entity the `` which is linked to other ``. It's
similar to a graph database, but the datamodel simpler *ahem* more
generic.

It also comes with two kind of indices: exact and fuzzy.

## Reference API

Procedures with a exclamation mark suffix `!` mutate the database.

Throught this documentation `CONTEXT` is a wiredtiger**z** database
context created with `context-open`.

### `` API

 `(atom-uid atom)

Return the unique identifier of `ATOM`.

 `(atom-assoc atom)`

Return the assoc of `ATOM`.

 `(create-atom #:optional (assoc '()))`

Create an `` with `ASSOC`.

 `(atom-set atom key value)`

Shortcut to set `ATOM`'s assoc this returns a new `` record.

 `(atom-ref atom key)`

Shortcut to reference `ATOM` assoc.

 `(atom-insert! atom context)`

Insert as new atom `ATOM` in the wiredtiger database referenced by `CONTEXT`.

 `(atom-update! atom context)`

Update `ATOM` inside the database reference by `CONTEXT`.

 `(atom-ref* uid context)`

Reference `` with `UID` as unique identifier inside the database
referenced by `CONTEXT`.

 `(atom-link! atom other context)`

Create a directed link between `ATOM` and `OTHER` inside the database
referenced by `CONTEXT`

 `(atom-incomings atom context)`

Retrieve every **incomings** links of `ATOM` found inside the database
referenced by `CONTEXT`.

 `(atom-outgoings atom context)`

Retrieve every **outgoings** links of `ATOM` found inside the database
referenced by `CONTEXT`.

 `(atom-unlink! atom other context)`

Remove the directed link between `ATOM` and `OTHER` inside the database
referenced by `CONTEXT`.

 `(atom-remove! atom context)`

Remove `ATOM` from the database referenced by `CONTEXT`.

### index API

 `(index-set! key value context)`

Create an exact index as `KEY` on any scheme `VALUE` in database
referenced by `CONTEXT`.

 `(index-ref key context)`

Reference scheme value indexed at `KEY` in the database referenced by
`CONTEXT`

### fuzzy index

 `(fuzzy-index! word value context)`

Fuzzy index scheme `VALUE` as `WORD` inside the database referenced by
`CONTEXT`.

 `(fuzzy-search word context)`

Fuzzy search `WORD` inside the database referenced by `CONTEXT`.

Returns top 10 results according to levenstein distance.
(define-module (culture))

(use-modules (rnrs hashtables))

(use-modules (srfi srfi-1))
(use-modules (srfi srfi-26))

(use-modules (ice-9 optargs))

(use-modules (plain))
(use-modules (wiredtiger))
(use-modules (wiredtigerz))


;;; database table definition


(define *atoms* '(atoms ((uid . record))
((assoc . string))
()))


(define *links* '(links ((start . unsigned-integer)
 (end . unsigned-integer))
((value . string))
((outgoings (start) (end))
 (incomings (end) (start)


(define *index* '(index ((key . string))
((value . string))
()))

(define *trigrams* '(trigrams ((key . record))
  ((word . string)
   (trigram . string)
   (value . string))
  ((index (trigram) (word value))
   (value (value) (key)


(define-public *culture* (list *atoms* *links* *index* *trigrams*))


;;;
;;;  procedures
;;;

(define-record-type*  uid assoc)

(export atom-uid atom-assoc)


(define*-public (create-atom #:optional (assoc '()))
  (make-atom #nil assoc))


(define-public (atom-set atom key value)
  (let* ((assoc (atom-assoc atom))
 (ass

Re: [potluck dish] Compiler for the Joy language

2016-02-16 Thread Christopher Allan Webber
Eric Bavier writes:

> I started this project a few weeks ago, and managed to make enough
> progress that I thought I'd share it for the potluck.
>
> Joy is a simple, forth-like, purely functional, concatenative
> programming language:
>
> https://en.wikipedia.org/wiki/Joy_(programming_language)
> http://www.latrobe.edu.au/humanities/research/research-projects/past-projects/joy-programming-language

This is pretty cool!

> - Distribution: part of Guile, or separate?

I'd say, make a separate package, and package for Guix!  :)

But in general, it would be nice to have more languages for Guile that
are generally available.



Potluck - thread safe event loop with await semantics

2016-02-16 Thread Chris Vine
Hi,

Here for potluck is a considerably improved version of the event loop on
which I responded a few months ago, which I have spent some time
tidying up this week.

It features an a-sync procedure (in coroutines.scm) which can be used to
provide await semantics on asynchronous code (so as to remedy inversion
of control), and will work with callbacks for any event loop, including
the glib event loop wrapped by guile-gnome.  More to the point, it also
provides a thread safe event loop for guile (event-loop.scm) with
support for watches on ports/file descriptors, and now supports proper
timeouts, and permits events to be posted by other tasks.  This
includes tasks running on other threads, for which there is a helper
procedure a-sync-run-task-in-thread.

It would be nice to have a monotonic clock available for timeouts where
the system supports it, but guile does not provide that out of the box.
It would therefore be a separate exercise to wrap clock_gettime() with a
CLOCK_MONOTONIC argument to replace the use of the gettimeofday
procedure in event-loop.scm.

Chris;; Copyright Chris Vine 2014 and 2016

;; This library is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Lesser General Public
;; License as published by the Free Software Foundation; either
;; version 3 of the License, or (at your option) any later version.
;; 
;; This library is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; Lesser General Public License for more details.
;; 
;; You should have received a copy of the GNU Lesser General Public
;; License along with this library; if not, write to the Free Software
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

(define-module (coroutines)
  #:use-module (event-loop) ;; for event-post!
  #:export (make-iterator
	make-coroutine
	a-sync
	a-sync-run-task-in-thread))

;; this procedure takes a generator procedure, namely a procedure
;; which has a 'yield' parameter for its first or only argument,
;; followed by such other arguments (other than the one for the
;; 'yield' parameter) as the generator procedure requires, and
;; constructs an iterator from them.  When the iterator is invoked, it
;; will begin executing the procedure unless and until the argument
;; comprising the yield procedure is called, which will cause the
;; iterator to suspend computation and instead return the value passed
;; to yield (yield is a procedure taking no or one argument).  If
;; invoked again, the iterator will resume computation at the point
;; where it last left off (returning the value, if any, passed to the
;; iterator on resuming).  When the generator procedure has executed
;; to the end, the iterator returns 'stop-iteration.  This procedure
;; has some resemblance to call/ec, except that (i) instead of
;; executing the passed procedure immediately, it returns an iterator
;; which will do so, (ii) it is resumable, and (iii) the procedure to
;; be executed can receive starting arguments in addition to the
;; yield/break argument, to provide an alternative to binding them
;; with a lambda closure.  It is similar to ECMAScript generators and
;; python generators.
(define (make-iterator proc . args)
  (define tag (make-prompt-tag))
  (define send-back '())
  (define (thunk)
(apply proc
	   (lambda* (#:optional val)
	 (abort-to-prompt tag val)
	 send-back)
	   args)
;; the generator procedure has returned - reset thunk to do
;; nothing except return 'stop-iteration and return
;; 'stop-iteration after this last call to proc
(set! thunk (lambda () 'stop-iteration))
'stop-iteration)
  (lambda* (#:optional send-arg)
(set! send-back send-arg)
(call-with-prompt tag
		  thunk
		  (lambda (cont ret)
			(set! thunk cont)
			ret

;; this procedure takes a generator procedure, namely a procedure
;; which has a 'yield' parameter for its first or only argument,
;; followed by such other arguments (other than the one for the
;; 'yield' parameter) as the generator procedure requires, and
;; constructs a coroutine.  It is similar to make-iterator, in that it
;; takes a generator procedure and returns a lambda object (a
;; coroutine) which when called will begin executing the generator
;; procedure unless and until the argument comprising the yield
;; procedure is called, which will cause computation to be suspended.
;; However unlike make-iterator, the resumption continuation generated
;; on yielding is returned by the coroutine when yielding rather than
;; being stored internally in an iterator, so there is no explicit
;; retained mutable state.  The return value of the coroutine
;; comprises two values: first the resumption continuation, and second
;; the value (if any) passed to 'yield' when called.  If the returned
;; resumption continuation is subsequently called 

[potluck dish] A CommonMark parser

2016-02-16 Thread Erik Edrosa
Hello,

I've been working on a parser for CommonMark[0], a specified version of
Markdown[1] being worked on (still not 1.0). It currently does not parse
the full spec, but it works so far for all block structures except for
HTML blocks. The code is still pretty rough and I welcome any feedback
to improve it. I am following their suggested strategy of parsing
CommonMark in two steps by parsing the block level structure and then
inline.

The code can be found at https://github.com/OrangeShark/guile-commonmark

Here is an example usage:
(use-modules (commonmark)
 (sxml simple))

(define doc
  "A CommonMark Document
===
Here is some scheme code
```scheme
(display \"Hello, World!\")
```

1. A list
2. Another item")

;; Parse the CommonMark document into sxml
(define doc-sxml (commonmark->sxml doc))

;; Writes to current output port
(sxml->xml doc-sxml)
(newline)


which outputs(formatted for readability):
A CommonMark Document
Here is some scheme code

  
(display "Hello, World!")
  


  
A list
  
  
Another item
  



I plan to have the 0.1 release cover both blocks and inlines and as much
of the current spec as possible. This will include parsing HTML in
CommonMark documents, but I am unsure if whether the default behavior
should be unsafe (does not escape any HTML) with a safe flag or the
opposite. Any suggestions to improve is appreciated.

Thanks
Erik - OrangeShark


[0]: http://commonmark.org/
[1]: http://daringfireball.net/projects/markdown/



Re: Guile-Config 0.1 Released

2016-02-16 Thread Arne Babenhauserheide
Hi Alex,

Alex Sassmannshausen writes:

> I have the pleasure of officially announcing the first release of
> Guile-Config.

That’s great!

> You can download the release tarball at:
>   http://alex.pompo.co/software/guile-config-0.1.tar.gz
…
> You can also conveniently install guile-config using Guix:
>   guix package -i guile-config

Is there a recommended way to use this in my project when my users don’t
use Guix?

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken


signature.asc
Description: PGP signature


Re: Guile-Config 0.1 Released

2016-02-16 Thread Alex Sassmannshausen
Hi Arne,

Arne Babenhauserheide writes:

> Hi Alex,
>
> Alex Sassmannshausen writes:
>
>> I have the pleasure of officially announcing the first release of
>> Guile-Config.
>
> That’s great!
>
>> You can download the release tarball at:
>>   http://alex.pompo.co/software/guile-config-0.1.tar.gz
> …
>> You can also conveniently install guile-config using Guix:
>>   guix package -i guile-config
>
> Is there a recommended way to use this in my project when my users don’t
> use Guix?

You should be able to do the usual GNU installation procedure of:
- download tarball
- untar
- run ./configure && make && make install

You may need to install some additional build tools for this, but
outside build tools the only dependency should be guile.

HTH, let me know if you run into problems with that :-)

Alex