[ANN] A pre-release of the Scribble syntax in Clojure

2013-09-20 Thread Bogdan Opanchuk
Hello all,

There was a thread a while ago with me asking about the ways to modify the 
S-expression syntax in Clojure as it's done in 
Scribblehttp://docs.racket-lang.org/scribble/reader.html. 
Long story short, I'm happy to announce a working (well, to my current 
knowledge) implementation: on clojars https://clojars.org/scribble, or on 
github https://github.com/Manticore/clojure-scribble. The readme file on 
github contains some usage instructions, and the list of differences from 
the original Scribble syntax (with explanations). The current version is a 
snapshot, since I depend on a snapshot version of 
chiarahttps://clojars.org/chiara. 
I'll update the version as soon as chiara is released.

I've made this for my own purposes, but perhaps it may be useful to other 
people as a generalized template engine. Anyway, it is my first Clojure 
project, so I'll be grateful for any comments, or even pull requests.

P.S. Given the current list of differences from the original Scribble 
syntax, and the fact that the original Scribble is actually a syntax + a 
documentation generation system, I do not insist on keeping the name.  

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


A library function for the repeated application of a lambda with values from a sequence

2013-09-14 Thread Bogdan Opanchuk
Hello,

Consider the following problem:

(def v [1 2 3])
(def l '(4 5 6))

; we need to apply in sequence 
; `v - (func v e)`, 
; where `e` goes over elements of the list `l`
(def new-v (apply-from-list func v l))

For example, if `(def func conj)`, then the value of `new-v` is `[1 2 3 4 5 
6]`. Is there some function (or a simple combination of functions) from the 
standard library that does that? It seems to me that it could be done with 
something like `-`, but a function, not a macro. At the moment I have the 
following ugly implementation:

(defn apply-from-list
  [init-res func init-l]
  (if (empty? init-l)
init-res
(loop [res init-res
   l init-l]
  (let [first-elem (first l)
rest-elems (rest l)
res (func res first-elem)]
(if (empty? rest-elems)
  res
  (recur res rest-elems))

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: A library function for the repeated application of a lambda with values from a sequence

2013-09-14 Thread Bogdan Opanchuk
Hi Cedric,

Thanks, I'm feeling really silly now... I should have thought about folds 
the first second after encountering this :)

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Implementing a Scribble-like preprocessor for Clojure

2013-09-07 Thread Bogdan Opanchuk
For what it's worth, I've finished a draft implementation using reader API 
utilities from Clarity https://github.com/one-more-minute/clarity. The 
result can be seen on github https://github.com/Manticore/clojure-scribble, 
the example of syntax in 
testshttps://github.com/Manticore/clojure-scribble/blob/master/test/scribble/core_test.clj.
 
This is my first ever Clojure project, so I'll gladly accept any comments 
(or push requests). I'm planning to push it on clojars when it's cleaned 
up, and the uncertainties in syntax are dealt with.

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Implementing a Scribble-like preprocessor for Clojure

2013-08-24 Thread Bogdan Opanchuk
Hi Jeremy,

Thank you for your suggestion, it's worth a try. It seems though that it 
might not be suitable for my more distant plans for this project, because:

1) The full Scribble syntax is not context-free: multiline text mode has to 
remember the starting indentation (although I'm not sure if this feature is 
necessary);
2) It would be very convenient to be able to write this pseudo-Scribble 
code with the full use of REPL, autocompletion etc (for example, in 
LightTable), and it requires a custom reader, and not just a separate 
parser.


On Saturday, August 24, 2013 7:18:40 PM UTC+10, JeremyS wrote:

 Hi Bogdan,

 That's a cool Idea ! I'm wondering if you wouldn't be better off with 
 something like Instaparse https://github.com/Engelberg/instaparse.

 Cheers,

 Jeremys.

 On Friday, August 23, 2013 3:37:53 PM UTC+2, Bogdan Opanchuk wrote:

 Hi all,

 For those who are not familiar with Scribble, it is basically a 
 preprocessor for Racket (a dialect of Lisp) which makes its syntax more 
 concise when working with lots of text, effectively turning it into a 
 template engine (see http://docs.racket-lang.org/scribble/reader.htmlfor 
 details). TLDR: a very small subset of Scribble would transform

 @func{text text @other-func{more text} final words.}

 to

 (func text text  (other-func more text)  final words.)

 I would like to implement it in Clojure as a learning project (say, the 
 simple subset of it shown above, for a start). My question is, what should 
 I use? Let's say for simplicity that the entry point is some function 
 (load-file-scribble filename.scribble) that returns Clojure code same as 
 (load-file filename.clj) does. As far as my general understanding of 
 programming languages goes, I have to:

1. extend the tokenizer to support additional syntax;
2. extend the parser (?) to convert the new tokens into corresponding 
Clojure tokens;
3. feed the result to the Clojure parser

 (although I might be completely wrong).

 There is the ``tools.reader`` module, which seems more or less suitable, 
 but I cannot find the hooks that would allow me to extend its functionality 
 in the required way. Is it the right tool, or should I look some other way?

  



-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Implementing a Scribble-like preprocessor for Clojure

2013-08-23 Thread Bogdan Opanchuk
Hi all,

For those who are not familiar with Scribble, it is basically a 
preprocessor for Racket (a dialect of Lisp) which makes its syntax more 
concise when working with lots of text, effectively turning it into a 
template engine (see http://docs.racket-lang.org/scribble/reader.html for 
details). TLDR: a very small subset of Scribble would transform

@func{text text @other-func{more text} final words.}

to

(func text text  (other-func more text)  final words.)

I would like to implement it in Clojure as a learning project (say, the 
simple subset of it shown above, for a start). My question is, what should 
I use? Let's say for simplicity that the entry point is some function 
(load-file-scribble filename.scribble) that returns Clojure code same as 
(load-file filename.clj) does. As far as my general understanding of 
programming languages goes, I have to:

   1. extend the tokenizer to support additional syntax;
   2. extend the parser (?) to convert the new tokens into corresponding 
   Clojure tokens;
   3. feed the result to the Clojure parser

(although I might be completely wrong).

There is the ``tools.reader`` module, which seems more or less suitable, 
but I cannot find the hooks that would allow me to extend its functionality 
in the required way. Is it the right tool, or should I look some other way?

 

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.