screen in guile

2012-03-08 Thread Thien-Thi Nguyen
Hey, here's a summer (to start with) of code idea:

Rewrite GNU Screen in Guile Scheme.
Bonus points for adding "vertical split" a la tmux.

(I got this idea after reading some screen vs tmux posts,
 not ever having used tmux, personally, but somewhat irked
 anyway by the "aging code base" vibe...)

I suppose if nobody else picks this up, it will go on my queue
after {RPX, Guile-{WWW,SDL,PG}} in Guile 2, {RCS, Git} in Guile...
Do you all really want to wait that long?!



Re: screen in guile

2012-03-08 Thread Thien-Thi Nguyen
() Andrew Gwozdziewycz 
() Thu, 8 Mar 2012 06:02:46 -0500

   Maybe I'm missing something, but doesn't screen
   *have* vertical split a la tmux?

   http://i.imgur.com/IXdEF.png

Certainly seems like it.  Well then, we will need
something else bonus-points worthy, i suppose.  The
only thing that strikes me as interesting (personally)
would be schemier ~/.screenrc syntax, but i assume that
any reasonable porting effort would address that issue
de rigueur.

[Hangs head in shame, peeking at ~/.rpxrc ...]



Re: prompts: any example ?

2012-03-08 Thread Ian Price
Ian Price  writes:

> The trick comes from, I think, Filinski's "Representing Monads",
> although it has been quite a while since I've read it. Instead of monads
> being represented by the usual 'bind' and 'unit' functions, or the
> (categorical?) definition of 'unit', 'fmap', 'join', they are instead
> represented by two operators 'reflect' and 'reify'. 
>
> reify : (() -> a) -> m a
> reflect : m a -> a
>
> reify takes a function that returns a value, and returns a monadic
> value i.e. it lifts a pure expression to an effectful one.
>
> reflect takes a monadic value and returns the value. i.e. it lowers the
> effectful value into the pure layer.

One thing I forgot to mention is that there is a simple way to turn the
unit/bind representation into the reify/reflect representation, and you
see it at the top of the gist.

(define (reify thunk)
  (reset (return (thunk

(define (reflect m)
  (shift k (>>= m k)))

only I used tagged variants of shift/reset instead to allow mixing (as
already mentioned)

-- 
Ian Price

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"



Re: screen in guile

2012-03-08 Thread Thien-Thi Nguyen
() Andrew Gwozdziewycz 
() Thu, 8 Mar 2012 11:57:48 -0500

   Not to strike you down twice,

No worries, the mud's fine.

   but I'm not sure how .screenrc's syntax would be better served
   with s-expressions.  To my knowledge it's completely line
   oriented without any sort of section delimiting.

Here's a fragment from my ~/.screenrc:

  # special xterm hardstatus: use the window title.
  termcap  xterm 'hs:ts=\E]2;:fs=\007:ds=\E]0;Screen\007'
  terminfo xterm 'hs:ts=\E]2;:fs=\007:ds=\E]0;Screen\007'

It shows a comment and two directives of the form:
  CATEGORY KEY VALUE

Since KEY and VALUE are identical, it would be nice to be able to
express that using some kind of ‘for-each’ or ‘map’ expression.
Furthermore, IWBN to compose the string from meaningful bits
instead of having to cart around (for 15 years, no less :-) such
grot...

(define (both-termcap-and-terminfo name value)
  ;; do ‘termcap NAME VALUE’
  ;; do ‘terminfo NAME VALUE’
  )

(both-termcap-and-terminfo
 'xterm (string-join (map format-attribute
  '(hs
(ts escape "]2;")
(fs bell)
(ds escape "]0;Screen" bell)))
 ":"))

or something like that.



guile macros and binary API

2012-03-08 Thread Alexei Matveev
[resend to guile-user, first copy went to bug-guile]

Hi, All,

For use from a Fortran program I am collecting API fixes for libguile.so
as wrapper functions for what is provided to C-programs as macros.
I noted that some of the macros are function-macros some are symbol
macros. An example of the latter is

  #define scm_to_int scm_to_int23

This is inconsistent and makes escaping such macros slightly more difficult.
(Honestly I dont know a way yet).

One guile developer on IRC said this is "probably a good thing to fix"
so I report
it here. I dont build Guile 2 myself as the installations I use are quite
dated/conservative.

As a background, Fortran allows you to declare "foreign" functions, for example,
like this:

type, public, bind(c) :: scm_t
   private
   integer(c_intptr_t) :: do_not_ever_use
end type scm_t

interface
  function scm_symbol_p (obj) result (yes) bind (c)
 type(scm_t), intent(in), value :: obj
type(scm_t) :: yes
  end function scm_symbol_p
  ...
end interface

This makes use of library functions quite handy. But it does not provide a
way to access a C-macro, naturally.

Alexei

#include 

SCM guile_macro_scm_from_int (int i);
int guile_macro_scm_to_int (SCM obj);

int (scm_is_true) (SCM obj);
int (scm_is_symbol) (SCM obj);

int (scm_is_null) (SCM obj);
SCM (scm_eol) (void);

SCM guile_macro_scm_from_int (int i)
{
  return scm_from_int(i);
}

int guile_macro_scm_to_int (SCM obj)
{
  return scm_to_int(obj);
}

int (scm_is_true) (SCM obj)
{
  return scm_is_true(obj);
}

int (scm_is_symbol) (SCM obj)
{
  return scm_is_symbol(obj);
}

int (scm_is_null) (SCM obj)
{
  return scm_is_null(obj);
}

SCM (scm_eol) ()
{
  return SCM_EOL;
}



Re: screen in guile

2012-03-08 Thread Andrew Gwozdziewycz
On Thu, Mar 8, 2012 at 11:43 AM, Thien-Thi Nguyen  wrote:

> () Andrew Gwozdziewycz 
> () Thu, 8 Mar 2012 06:02:46 -0500
>
>   Maybe I'm missing something, but doesn't screen
>   *have* vertical split a la tmux?
>
>   http://i.imgur.com/IXdEF.png
>
> Certainly seems like it.  Well then, we will need
> something else bonus-points worthy, i suppose.  The
> only thing that strikes me as interesting (personally)
> would be schemier ~/.screenrc syntax, but i assume that
> any reasonable porting effort would address that issue
> de rigueur.
>
> [Hangs head in shame, peeking at ~/.rpxrc ...]
>

Not to strike you down twice, but I'm not sure how .screenrc's syntax would
be better served with s-expressions. To my knowledge it's completely line
oriented without any sort of section delimiting.





-- 
http://www.apgwoz.com


Re: screen in guile

2012-03-08 Thread Ludovic Courtès
Hello!

Thien-Thi Nguyen  skribis:

> Rewrite GNU Screen in Guile Scheme.
> Bonus points for adding "vertical split" a la tmux.

Good idea.  :-)

I presume GNU Guile-NCurses could be of help here?

Extra bonus point: getting the Scheme implementation of screen actually
become the new GNU Screen (may well be the hardest part.)

Cheers,
Ludo’.




Re: screen in guile

2012-03-08 Thread Andrew Gwozdziewycz
On Thu, Mar 8, 2012 at 4:14 AM, Thien-Thi Nguyen  wrote:

> Hey, here's a summer (to start with) of code idea:
>
> Rewrite GNU Screen in Guile Scheme.
> Bonus points for adding "vertical split" a la tmux.
>

Maybe I'm missing something, but doesn't screen *have* vertical split a la
tmux?

http://i.imgur.com/IXdEF.png


(I got this idea after reading some screen vs tmux posts,
>  not ever having used tmux, personally, but somewhat irked
>  anyway by the "aging code base" vibe...)
>
> I suppose if nobody else picks this up, it will go on my queue
> after {RPX, Guile-{WWW,SDL,PG}} in Guile 2, {RCS, Git} in Guile...
> Do you all really want to wait that long?!
>
>


-- 
http://www.apgwoz.com


Re: Problem with modules in Guile 2.0

2012-03-08 Thread Gubinelli Massimiliano
Hi Mark,
 thanks again. I start to understand better the Guile 2 compile system. I 
decided to dig into boot-9.scm to have a more precise idea of the ecosystem 
around my scripts. Unfortunately it seems that the basic TeXmacs scripting 
infrastructure need a major change to be run into Guile 2.0 and I'm afraid not 
to be sufficiently proficient in scheme to do this in a short time. Is there 
anyone on this list which would like to assist me to port GNU TeXmacs to Guile 
2.0. Currently the code in svn builds fine against 2.0 so the problem is just 
to adapt the scheme scripts which rely on a customized module system. If you 
are interested you can contact me privately. In the meantime I will dig into 
the code hoping to find illumination among parentheses….

best
max


On Mar 8, 2012, at 3:01 AM, Mark H Weaver wrote:

> Gubinelli Massimiliano  writes:
> 
>> Thanks for the prompt reply to both of you. However the proposed
>> solution do not work in my case.
> 
> I think it _did_ solve your original problem, but now you have moved on
> to other unrelated problems.
> 
>> After implementing the
>> begin-for-syntax alternative I now get
>> 
>> scheme@(guile-user)> (load "main.scm")
>> ;;; compiling /Users/mgubi/t/build-64-guile-2.0/test-modules/main.scm
>> ;;; note: source file 
>> /Users/mgubi/t/build-64-guile-2.0/test-modules/test-modules.scm
>> ;;; newer than compiled
>> /Users/mgubi/.cache/guile/ccache/2.0-LE-8-2.0/Users/mgubi/t/build-64-guile-2.0/test-modules/test-modules.scm.go
>> ;;; compiling /Users/mgubi/t/build-64-guile-2.0/test-modules/test-modules.scm
>> ;;;
>> /Users/mgubi/t/build-64-guile-2.0/test-modules/test-modules.scm:15:34:
>> warning: possibly unbound variable `compile-interface-spec'
> 
> Note that 'compile-interface-spec' was an undocumented internal
> procedure of Guile 1.x, and no longer exists in Guile 2.
> 
>> ;;; /Users/mgubi/t/build-64-guile-2.0/test-modules/test-modules.scm:32:11: 
>> warning: possibly unbound variable `:use'
>> ;;; /Users/mgubi/t/build-64-guile-2.0/test-modules/test-modules.scm:33:11: 
>> warning: possibly unbound variable `:inherit'
>> ;;; /Users/mgubi/t/build-64-guile-2.0/test-modules/test-modules.scm:34:11: 
>> warning: possibly unbound variable `:export'
> 
> In order to use the shorter keyword syntax ':use' (instead of '#:use'),
> you must set the prefix keywords reader option.  Put the following at
> the beginning of your 'begin-for-syntax' form:
> 
>  (read-set! keywords 'prefix)
> 
>> ;;; compiled 
>> /Users/mgubi/.cache/guile/ccache/2.0-LE-8-2.0/Users/mgubi/t/build-64-guile-2.0/test-modules/test-modules.scm.go
>> ;;; WARNING: compilation of 
>> /Users/mgubi/t/build-64-guile-2.0/test-modules/main.scm failed:
>> ;;; ERROR: No variable named %module-public-interface in #> mymodule) 10507ed80>
>> ERROR: In procedure scm-error:
>> ERROR: No variable named %module-public-interface in #> mymodule) 10507ed80>
>> 
>> Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
>> scheme@(guile-user) [1]> 
>> 
>> if I understand correctly this backtrace it seems that the module is
>> not completely loaded at compile time and there is not public
>> interface available. How can I force the evaluation of the loaded
>> modules in order to get a list of exported symbols?
> 
> I cannot reproduce this.  When I try using your example code, Guile
> 2.0.5 tries to compile (sub mymodule).  Are you sure that you remembered
> to set GUILE_LOAD_PATH during this test run?
> 
> This is what I see:
> 
>  GNU Guile 2.0.5
>  Copyright (C) 1995-2012 Free Software Foundation, Inc.
> 
>  Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
>  This program is free software, and you are welcome to redistribute it
>  under certain conditions; type `,show c' for details.
> 
>  Enter `,help' for help.
>  scheme@(guile-user)> (load "main.scm")
>  ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
>  ;;;   or pass the --no-auto-compile argument to disable.
>  ;;; compiling /home/mhw/guile-modules/main.scm
>  ;;; compiling /home/mhw/guile-modules/./test-modules.scm
>  ;;; test-modules.scm:15:34: warning: possibly unbound variable 
> `compile-interface-spec'
>  ;;; compiled 
> /home/mhw/.cache/guile/ccache/2.0-LE-4-2.0/home/mhw/guile-modules/test-modules.scm.go
>  ;;; compiling /home/mhw/guile-modules/sub/mymodule.scm
>  ;;; sub/mymodule.scm:1:0: warning: possibly unbound variable `texmacs-module'
>  ;;; sub/mymodule.scm:1:16: warning: possibly unbound variable `sub'
>  ;;; sub/mymodule.scm:1:16: warning: possibly unbound variable `mymodule'
>  ;;; compiled 
> /home/mhw/.cache/guile/ccache/2.0-LE-4-2.0/home/mhw/guile-modules/sub/mymodule.scm.go
>  ;;; WARNING: compilation of /home/mhw/guile-modules/main.scm failed:
>  ;;; ERROR: In procedure module-lookup: Unbound variable: texmacs-module
>  sub/mymodule.scm:1:0: In procedure #:
>  sub/mymodule.scm:1:0: In procedure module-lookup: Unbound variable: 
> texmacs-module
> 
>  Entering a new prompt.  Type `,b

Re: guile macros and binary API

2012-03-08 Thread dsmich

 Alexei Matveev  wrote: 
> As a background, Fortran allows you to declare "foreign" functions, for 
> example,
> like this:
> 
> type, public, bind(c) :: scm_t
>private
>integer(c_intptr_t) :: do_not_ever_use
> end type scm_t
> 
> interface
>   function scm_symbol_p (obj) result (yes) bind (c)
>  type(scm_t), intent(in), value :: obj
> type(scm_t) :: yes
>   end function scm_symbol_p
>   ...
> end interface

Sorry I can't contribute to the actual topic, but I just got say,  Wow!  That's 
fortran!!??

;^)

-Dale