Re: [ANN] Buffy The ByteBuffer Slayer, Clojure library to working with binary data

2013-12-03 Thread Cesar Canassa
Hi,

I see that the repeated-type requires a constant repeat count. Are you
planning to include a more dynamic version à la Gloss prefixes/headers?

The lib looks really nice. Binary handling libraries are really helpful.

Thanks,
Cesar Canassa



On Mon, Dec 2, 2013 at 7:09 PM, Alex P  wrote:

> It's different in a way we manipulate the data:
>
> We've opted out for default-lazy way (you're getting and setting separate
> values instead of serialising/deserialising an entire payload).
>
> Another difference is that we don't have Lamina as a loaded artifact
> (which may not be an issue for majority of people, but was for us
> because of an internal version conflict with some other library).
> Obviously, there are ways around it, but we tried to bring in minimum
> possible amount of dependencies, and be able to use it with Netty4 (which
> is currently underrepresented in Clojure world).
>
> There are other subtle difference, but I don't think they're worth
> mentioning, Gloss is a great library, but Buffy is doing things in a subtly
> different way. Main purpose (as we're using it) - for off-heap storage /
> data structures, and for binary protocol implementations in Clojure
> (right now, we have a sketch of Cassandra binary protocol implemented on
> top of Buffy, although I'm not sure wether it's going to be
> production-ready any time soon).
>
>
> Thanks for props!
>
> On Saturday, November 30, 2013 10:33:31 PM UTC+1, Thomas wrote:
>>
>> Looks really really great and could you please explain how it differs
>> from gloss [1]. Any advantages? Disadvantages?
>>
>> Thanks
>> Thomas
>>
>> [1] 
>> https://github.com/ztellman/gloss
>>
>> On Friday, November 29, 2013 10:15:45 PM UTC, Alex P wrote:
>>>
>>> Buffy [1] is a Clojure library to work with Binary Data, write complete
>>> binary protocol implementations
>>> in clojure, store your complex data structures in an off-heap chache,
>>> read binary files and do
>>> everything you would usually do `ByteBuffer`.
>>>
>>> Main features & motivation to write it
>>>
>>>   * partial deserialization (read and deserialise parts of a byte buffer)
>>>   * named access (access parts of your buffer by names)
>>>   * composing/decomposing from key/value pairs
>>>   * pretty hexdump
>>>   * many useful default types that you can combine and extend easily
>>>
>>> Data types include:
>>>
>>>   * primitives, such as `int32`, `boolean`, `byte`, `short`, `medium`,
>>> `float`, `long`
>>>   * arbitrary-length `string`
>>>   * byte arrays
>>>   * composite types (combine any of primitives together)
>>>   * repeated type (repeat any primitive arbitrary amount of times in
>>> payload)
>>>   * enum type (for mapping between human-readable and binary
>>> representation of constants)
>>>
>>> Buffy has been serving us well for recent time, and no major issues were
>>> revealed. However, until
>>> it reaches GA, we can't guarantee 100% backward compatibility, although
>>> we're thought it through
>>> very well and used our best knowledge to make it right.
>>>
>>> Buffy is a ClojureWerkz project, same as Monger, Elastisch, Cassaforte,
>>> Neocons, Meltdown and
>>> many others.
>>>
>>> [1] https://github.com/clojurewerkz/buffy
>>> [2] http://clojurewerkz.org
>>>
>>> --
>>>
>>> Alex P
>>>
>>> http://clojurewerkz.org
>>>
>>> http://twitter.com/ifesdjeen
>>>
>>  --
> --
> 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.
>

-- 
-- 
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: Am I missing something?

2013-12-03 Thread Alex Baranosky
I dislike all the migration libraries, because they all make migrations
super complex for what I usually want to do.  Wrote my own based of some
code Phil Hagelberg pointed me to months ago:
https://github.com/runa-dev/kits/blob/master/src/kits/db_migrator.clj


On Tue, Dec 3, 2013 at 9:21 PM, Brian Craft  wrote:

> Ah! And you just missed the survey.
>
> ;-)
>
> On Tuesday, December 3, 2013 4:20:52 PM UTC-8, James Laver wrote:
>>
>> Part of the 14 hours has been a learning curve for the libraries
>> involved. I also seem to have spent rather too patching what I perceive to
>> be holes where facilities should be in the libraries I'm using and in
>> writing abstractions to avoid some of the tedium. I didn't really imagine
>> I'd write two data structure handling libraries, two pieces of middleware
>> and a validation layer atop korma just to be able to do a little bit of
>> CRUD.
>>
>> I think I've been spoiled by the libraries available in other languages
>> which seem to me to achieve a better balance between raw power and helping
>> you to get things done more quickly (something I've found Perl achieves
>> particularly well -- it errs on the side of power but the libraries seem
>> more 'complete' if that makes sense).
>>
>  --
> --
> 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.
>

-- 
-- 
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: Am I missing something?

2013-12-03 Thread Brian Craft
Ah! And you just missed the survey.

;-)

On Tuesday, December 3, 2013 4:20:52 PM UTC-8, James Laver wrote:
>
> Part of the 14 hours has been a learning curve for the libraries involved. 
> I also seem to have spent rather too patching what I perceive to be holes 
> where facilities should be in the libraries I'm using and in writing 
> abstractions to avoid some of the tedium. I didn't really imagine I'd write 
> two data structure handling libraries, two pieces of middleware and a 
> validation layer atop korma just to be able to do a little bit of CRUD.
>
> I think I've been spoiled by the libraries available in other languages 
> which seem to me to achieve a better balance between raw power and helping 
> you to get things done more quickly (something I've found Perl achieves 
> particularly well -- it errs on the side of power but the libraries seem 
> more 'complete' if that makes sense).
>

-- 
-- 
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: Am I missing something?

2013-12-03 Thread Brian Craft


On Tuesday, December 3, 2013 8:48:34 PM UTC-8, Korny wrote:
>
> * Compojure for routing, and static resources - the only middleware we had 
> to write was for advanced json parsing 
>

What is advanced json parsing?

-- 
-- 
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: Am I missing something?

2013-12-03 Thread Swaroop C H
On Wed, Dec 4, 2013 at 7:00 AM, Sean Corfield wrote:

>
> As Phil says, rolling your own migrations, native to Postgres, is
> probably the best way to go in that area. At World Singles, we use
> external SQL files with a prefix indicating DB "level" and an
> indicator of dev vs prod migration, and a small Clojure script that
> figures out what needs applying. That's partly because we started out
> with SQL files - sometimes provided by DBAs - before we introduced
> Clojure to the project.
>


Slightly OT, has anyone used http://sqitch.org/ for the same purpose and
found it useful?

-- 
-- 
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: Am I missing something?

2013-12-03 Thread David Nolen
Did you look at Caribou? It seems more like a "complete" solution -
http://let-caribou.in

David


On Tue, Dec 3, 2013 at 6:26 PM, James Laver  wrote:

> Hi all,
>
> I'm fairly new to clojure (a few months), but not new to lisp or indeed
> functional languages in general and I have around 10 years of experience
> programming dynamic languages in general.
>
> I've recently been using luminus to build a RESTful web API and I've been
> honestly surprised by how much code I've had to write to enable me to
> actually get things done while using it. I can't say I was expecting
> something full-stack like Django or Rails, but I wasn't expecting to have
> to write quite so much code to get simple things done. I've now spent
> around 14 hours building a RESTful web service that handles CRUD for a
> single database table because I've had to solve so many things I've come up
> against.
>
> What I'm actually wondering here is what I'm missing. Is it that the
> entire clojurian approach is "here are the pieces, build a framework from
> them" or is it just that I've had terrible luck with libraries?
>
> Some examples:
> 1. The :params key is used by ring.middleware.params, compojure and
> ring.middleware.format so it's impossible to know where a given param is
> coming from
> 2. ring.middleware.params does not provide a convenience map that merges
> :query-params and :form-params, despite being happy to stuff everything
> into :params. At least ring.middleware.format adds :body-params here. I've
> now written a middleware to do this.
> 3. ring.middleware.keyword-params only keywordises the :params map, not
> the other maps. There is no configurable behaviour to ask it to do other
> maps. I've now written a middleware for this
> 4. migratus seems to have the smallest note ever in the documentation
> informing you that version numbers must be 14 digits long (i was using 12
> digits for a timestamp by not having the seconds listed). This seems like a
> really daft requirement in the first place.
> 5. every migrations library i've seen that doesn't work off raw SQL files
> is incapable of representing advanced features of my database of choice
> (postgresql)
> 6. lobos requires varchars to have a length limit applied (postgres does
> not)
> 7. the best way i've found of dealing with a database is korma. While
> korma does reduce some of the pain of SQL for standard things, it has
> limits and it doesn't save all that much pain.
>
> etc.
>
> So, am I missing something? Are there any libraries people can recommend
> that will make my life easier? Am I just looking at this in completely the
> wrong way?
>
> Thanks,
> James
>
> --
> --
> 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.
>

-- 
-- 
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: Am I missing something?

2013-12-03 Thread Korny Sietsma
My 2c on this :
We are doing similar things at my current client - with less pain. I
suspect you've been unlucky in your choice of libraries, and maybe
expecting more than you get in clojure's ecosystem - ruby, python etc have
been around a lot longer, and with a lot more focus on database use.

We use :
* Liberator for REST - it's pretty great, though we had to add some custom
exception handling
* Compojure for routing, and static resources - the only middleware we had
to write was for advanced json parsing
* Flyway for migrations - there's a Clojure wrapper, but we had to
customise it a fair bit. This uses raw sql migrations, but I *like* that.
* Korma for sql, though our database was fairly simple, and we talked about
moving to an alternative like honey sql - I'm not a big fan of Korma myself.
* custom validation - we probably should have looked harder at existing
libraries, but ended up rolling our own validation.

- Korny
On 4 Dec 2013 10:29, "James Laver"  wrote:

> Hi all,
>
> I'm fairly new to clojure (a few months), but not new to lisp or indeed
> functional languages in general and I have around 10 years of experience
> programming dynamic languages in general.
>
> I've recently been using luminus to build a RESTful web API and I've been
> honestly surprised by how much code I've had to write to enable me to
> actually get things done while using it. I can't say I was expecting
> something full-stack like Django or Rails, but I wasn't expecting to have
> to write quite so much code to get simple things done. I've now spent
> around 14 hours building a RESTful web service that handles CRUD for a
> single database table because I've had to solve so many things I've come up
> against.
>
> What I'm actually wondering here is what I'm missing. Is it that the
> entire clojurian approach is "here are the pieces, build a framework from
> them" or is it just that I've had terrible luck with libraries?
>
> Some examples:
> 1. The :params key is used by ring.middleware.params, compojure and
> ring.middleware.format so it's impossible to know where a given param is
> coming from
> 2. ring.middleware.params does not provide a convenience map that merges
> :query-params and :form-params, despite being happy to stuff everything
> into :params. At least ring.middleware.format adds :body-params here. I've
> now written a middleware to do this.
> 3. ring.middleware.keyword-params only keywordises the :params map, not
> the other maps. There is no configurable behaviour to ask it to do other
> maps. I've now written a middleware for this
> 4. migratus seems to have the smallest note ever in the documentation
> informing you that version numbers must be 14 digits long (i was using 12
> digits for a timestamp by not having the seconds listed). This seems like a
> really daft requirement in the first place.
> 5. every migrations library i've seen that doesn't work off raw SQL files
> is incapable of representing advanced features of my database of choice
> (postgresql)
> 6. lobos requires varchars to have a length limit applied (postgres does
> not)
> 7. the best way i've found of dealing with a database is korma. While
> korma does reduce some of the pain of SQL for standard things, it has
> limits and it doesn't save all that much pain.
>
> etc.
>
> So, am I missing something? Are there any libraries people can recommend
> that will make my life easier? Am I just looking at this in completely the
> wrong way?
>
> Thanks,
> James
>
> --
> --
> 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.
>

-- 
-- 
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: Am I missing something?

2013-12-03 Thread Sean Corfield
On Tue, Dec 3, 2013 at 4:20 PM, James Laver  wrote:
> I did have a quick look at liberator earlier but by that time i'd scratched
> most of my itch with compojure. I do intend to look into it in more depth
> though since there's a lot of application left to write.

Yes, there's a lot of detail in REST behavior and Liberator captures
all of that.

> The lisp mindset is rather why I came over to clojure, but I wasn't
> expecting to have to write quite so much code to get on with things.

I'm curious how this experience would have fared in Lisp? (I haven't
done any serious work in Lisp - and haven't used any Lisp systems much
since the mid-80's - so I don't know what sort of web and DB libraries
exist out there for Lisp)

> Part of the 14 hours has been a learning curve for the libraries involved.

Ah, yes, understandable.

As Phil says, rolling your own migrations, native to Postgres, is
probably the best way to go in that area. At World Singles, we use
external SQL files with a prefix indicating DB "level" and an
indicator of dev vs prod migration, and a small Clojure script that
figures out what needs applying. That's partly because we started out
with SQL files - sometimes provided by DBAs - before we introduced
Clojure to the project.

Like Phil, I tend to prefer to avoid SQL abstractions, unless I
specifically need the ability to compose fragments of SQL, so I tend
to work directly with java.jdbc with just a few helpers built on top
of it (find-by-keys, get-by-id, delete-by-id). I ported my own simple,
convention-based MVC framework to Clojure (from CFML) and it's based
on Ring and I just tend to "go with the flow" as far as the standard
middleware is concerned. That framework has simple render-json etc
functions for returning JSON or XML or whatever as a REST response,
and controllers are simple functions (operating on a simple map of
parameters) and views - if returning HTML rather than just data - are
Selmer templates (Django style).
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
-- 
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: Am I missing something?

2013-12-03 Thread Phil Hagelberg
On Tuesday, December 3, 2013 3:26:53 PM UTC-8, James Laver wrote:
> So, am I missing something? Are there any libraries people can recommend
> that will make my life easier? Am I just looking at this in completely 
the wrong way?

It sounds like half of your problems are arising from DB migrations. IMO 
the existing libraries for doing this from Clojure are just not worth the 
bother. This is one place where I think you're better served just by 
writing your own functions; it can be done cleanly with very few lines of 
code and doesn't have to tie you into any crazy db-agnostic abstractions 
that hide the details of Postgres:

https://github.com/technomancy/syme/blob/master/src/syme/db.clj#L68

-Phil

-- 
-- 
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: Am I missing something?

2013-12-03 Thread James Laver
Hi Sean,

On Wednesday, December 4, 2013 12:03:45 AM UTC, Sean Corfield wrote:
>
> Take a look at Liberator, which is specifically designed for building 
> REST APIs


I did have a quick look at liberator earlier but by that time i'd scratched 
most of my itch with compojure. I do intend to look into it in more depth 
though since there's a lot of application left to write.
 

> - but bear in mind the mindset of the Clojure community is 
> generally to compose several libraries to create the specific solution 
> you need, rather than having any "full stack" frameworks.
>

The lisp mindset is rather why I came over to clojure, but I wasn't 
expecting to have to write quite so much code to get on with things. 
 

> That said, 14 hours to create a RESTful web service for CRUD for a 
> single table seems excessive so I'd be curious exactly what you're 
> trying to achieve and why you're finding it so laborious? Perhaps if 
> you explain your requirements a bit more, we can offer better 
> suggestions...? 
>

I'm building a data management service for several other services to hang 
off. The basic problem is solves is to avoid having to either a) share the 
same database across multiple codebases (given that we may want to change 
the structure and then things get tedious) or b) keep several different 
databases (in which case welcome to synchronisation hell).

Part of the 14 hours has been a learning curve for the libraries involved. 
I also seem to have spent rather too patching what I perceive to be holes 
where facilities should be in the libraries I'm using and in writing 
abstractions to avoid some of the tedium. I didn't really imagine I'd write 
two data structure handling libraries, two pieces of middleware and a 
validation layer atop korma just to be able to do a little bit of CRUD.

I think I've been spoiled by the libraries available in other languages 
which seem to me to achieve a better balance between raw power and helping 
you to get things done more quickly (something I've found Perl achieves 
particularly well -- it errs on the side of power but the libraries seem 
more 'complete' if that makes sense).

Oh, I did find one library that I liked a lot, timbre.

James

-- 
-- 
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: Am I missing something?

2013-12-03 Thread Sean Corfield
Take a look at Liberator, which is specifically designed for building
REST APIs - but bear in mind the mindset of the Clojure community is
generally to compose several libraries to create the specific solution
you need, rather than having any "full stack" frameworks.

That said, 14 hours to create a RESTful web service for CRUD for a
single table seems excessive so I'd be curious exactly what you're
trying to achieve and why you're finding it so laborious? Perhaps if
you explain your requirements a bit more, we can offer better
suggestions...?

Sean

On Tue, Dec 3, 2013 at 3:26 PM, James Laver  wrote:
> Hi all,
>
> I'm fairly new to clojure (a few months), but not new to lisp or indeed
> functional languages in general and I have around 10 years of experience
> programming dynamic languages in general.
>
> I've recently been using luminus to build a RESTful web API and I've been
> honestly surprised by how much code I've had to write to enable me to
> actually get things done while using it. I can't say I was expecting
> something full-stack like Django or Rails, but I wasn't expecting to have to
> write quite so much code to get simple things done. I've now spent around 14
> hours building a RESTful web service that handles CRUD for a single database
> table because I've had to solve so many things I've come up against.
>
> What I'm actually wondering here is what I'm missing. Is it that the entire
> clojurian approach is "here are the pieces, build a framework from them" or
> is it just that I've had terrible luck with libraries?
>
> Some examples:
> 1. The :params key is used by ring.middleware.params, compojure and
> ring.middleware.format so it's impossible to know where a given param is
> coming from
> 2. ring.middleware.params does not provide a convenience map that merges
> :query-params and :form-params, despite being happy to stuff everything into
> :params. At least ring.middleware.format adds :body-params here. I've now
> written a middleware to do this.
> 3. ring.middleware.keyword-params only keywordises the :params map, not the
> other maps. There is no configurable behaviour to ask it to do other maps.
> I've now written a middleware for this
> 4. migratus seems to have the smallest note ever in the documentation
> informing you that version numbers must be 14 digits long (i was using 12
> digits for a timestamp by not having the seconds listed). This seems like a
> really daft requirement in the first place.
> 5. every migrations library i've seen that doesn't work off raw SQL files is
> incapable of representing advanced features of my database of choice
> (postgresql)
> 6. lobos requires varchars to have a length limit applied (postgres does
> not)
> 7. the best way i've found of dealing with a database is korma. While korma
> does reduce some of the pain of SQL for standard things, it has limits and
> it doesn't save all that much pain.
>
> etc.
>
> So, am I missing something? Are there any libraries people can recommend
> that will make my life easier? Am I just looking at this in completely the
> wrong way?
>
> Thanks,
> James
>
> --
> --
> 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.



-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
-- 
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: reduce vs fold

2013-12-03 Thread Daniel
Don't you need to supply a combiner for fold?  /no-experience

-- 
-- 
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: Am I missing something?

2013-12-03 Thread Michael Cohen
CRUD against an SQL database is not imo the sweet spot for Clojure, at 
least not if you're comparing it against things like Rails or Django. With 
most of the NoSql stores out there, there's a Clojure client that let's you 
basically say, "Here's a map, upsert it," which is essentially what you can 
say with Rails, Django, etc. (just replace map with class). So for the 
first 80% of cases of db access you long for that effortlessness you had 
with your ORM, but once you get a bit further down the line you don't get 
stuck in the muck of Vietnam on the last 20%.   


On Tuesday, December 3, 2013 3:26:53 PM UTC-8, James Laver wrote:
>
> Hi all,
>
> I'm fairly new to clojure (a few months), but not new to lisp or indeed 
> functional languages in general and I have around 10 years of experience 
> programming dynamic languages in general.
>
> I've recently been using luminus to build a RESTful web API and I've been 
> honestly surprised by how much code I've had to write to enable me to 
> actually get things done while using it. I can't say I was expecting 
> something full-stack like Django or Rails, but I wasn't expecting to have 
> to write quite so much code to get simple things done. I've now spent 
> around 14 hours building a RESTful web service that handles CRUD for a 
> single database table because I've had to solve so many things I've come up 
> against.
>
> What I'm actually wondering here is what I'm missing. Is it that the 
> entire clojurian approach is "here are the pieces, build a framework from 
> them" or is it just that I've had terrible luck with libraries?
>
> Some examples:
> 1. The :params key is used by ring.middleware.params, compojure and 
> ring.middleware.format so it's impossible to know where a given param is 
> coming from
> 2. ring.middleware.params does not provide a convenience map that merges 
> :query-params and :form-params, despite being happy to stuff everything 
> into :params. At least ring.middleware.format adds :body-params here. I've 
> now written a middleware to do this.
> 3. ring.middleware.keyword-params only keywordises the :params map, not 
> the other maps. There is no configurable behaviour to ask it to do other 
> maps. I've now written a middleware for this
> 4. migratus seems to have the smallest note ever in the documentation 
> informing you that version numbers must be 14 digits long (i was using 12 
> digits for a timestamp by not having the seconds listed). This seems like a 
> really daft requirement in the first place.
> 5. every migrations library i've seen that doesn't work off raw SQL files 
> is incapable of representing advanced features of my database of choice 
> (postgresql)
> 6. lobos requires varchars to have a length limit applied (postgres does 
> not)
> 7. the best way i've found of dealing with a database is korma. While 
> korma does reduce some of the pain of SQL for standard things, it has 
> limits and it doesn't save all that much pain.
>
> etc.
>
> So, am I missing something? Are there any libraries people can recommend 
> that will make my life easier? Am I just looking at this in completely the 
> wrong way?
>
> Thanks,
> James
>

-- 
-- 
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.


Am I missing something?

2013-12-03 Thread James Laver
Hi all,

I'm fairly new to clojure (a few months), but not new to lisp or indeed 
functional languages in general and I have around 10 years of experience 
programming dynamic languages in general.

I've recently been using luminus to build a RESTful web API and I've been 
honestly surprised by how much code I've had to write to enable me to 
actually get things done while using it. I can't say I was expecting 
something full-stack like Django or Rails, but I wasn't expecting to have 
to write quite so much code to get simple things done. I've now spent 
around 14 hours building a RESTful web service that handles CRUD for a 
single database table because I've had to solve so many things I've come up 
against.

What I'm actually wondering here is what I'm missing. Is it that the entire 
clojurian approach is "here are the pieces, build a framework from them" or 
is it just that I've had terrible luck with libraries?

Some examples:
1. The :params key is used by ring.middleware.params, compojure and 
ring.middleware.format so it's impossible to know where a given param is 
coming from
2. ring.middleware.params does not provide a convenience map that merges 
:query-params and :form-params, despite being happy to stuff everything 
into :params. At least ring.middleware.format adds :body-params here. I've 
now written a middleware to do this.
3. ring.middleware.keyword-params only keywordises the :params map, not the 
other maps. There is no configurable behaviour to ask it to do other maps. 
I've now written a middleware for this
4. migratus seems to have the smallest note ever in the documentation 
informing you that version numbers must be 14 digits long (i was using 12 
digits for a timestamp by not having the seconds listed). This seems like a 
really daft requirement in the first place.
5. every migrations library i've seen that doesn't work off raw SQL files 
is incapable of representing advanced features of my database of choice 
(postgresql)
6. lobos requires varchars to have a length limit applied (postgres does 
not)
7. the best way i've found of dealing with a database is korma. While korma 
does reduce some of the pain of SQL for standard things, it has limits and 
it doesn't save all that much pain.

etc.

So, am I missing something? Are there any libraries people can recommend 
that will make my life easier? Am I just looking at this in completely the 
wrong way?

Thanks,
James

-- 
-- 
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: Best way to loop a map of maps

2013-12-03 Thread James Ferguson
`update-in` could be helpful, depending on what exactly you're doing.

(doseq [keyA keys, keyB otherkeys]
  (update-in m [keyA keyB] some-function))

On Tuesday, December 3, 2013 6:05:14 PM UTC-5, Ryan wrote:
>
> Hi all,
>
> I am trying to figure out a better way to loop the following map than 
> using nested doseq. The map has the following structure:
>
> (def m
>>   {"outerKeyA" {:innerKeyA {"string id" {:foo 1 :bar 2}}}
>>"outerKeyB" {:innerKeyB {"string id" {:bar 5 :baz 10)
>
>
> So, right now i am doing the following:
>
> (doseq [[outer-keys collections] m]
>>   (doseq [[collection-name collection] collections]
>> (doseq [[string-id data] collection]
>>   ;; do stuff with all the above 
>> )))
>
>
> Is there a more idiomatic/better way to do deeply nested 
> iterations/traversal of map of maps?
>
> Thank you for any replies!
>
> Ryan 
>
>

-- 
-- 
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: Best way to loop a map of maps

2013-12-03 Thread Cedric Greevey
Tree-seq? But then, if the data is structured so each level has a distinct
purpose, that's not really a great fit.

Perhaps we need a for/doseq analog of assoc-in, update-in, etc.?

At the very least I think this might work:

(doseq [[outer-keys collections] m
[collection-name collection] collections
[string-id data] collection]
  ;; do stuff with the above
)



On Tue, Dec 3, 2013 at 6:08 PM, Jay Fields  wrote:

> I was going to type in the example with multiple bindings, but this
> will probably be more helpful:
>
> http://blog.jayfields.com/2013/05/clojure-combining-calls-to-doseq-and-let.html
>
> On Tue, Dec 3, 2013 at 6:05 PM, Ryan  wrote:
> > Hi all,
> >
> > I am trying to figure out a better way to loop the following map than
> using
> > nested doseq. The map has the following structure:
> >
> >> (def m
> >>   {"outerKeyA" {:innerKeyA {"string id" {:foo 1 :bar 2}}}
> >>"outerKeyB" {:innerKeyB {"string id" {:bar 5 :baz 10)
> >
> >
> > So, right now i am doing the following:
> >
> >> (doseq [[outer-keys collections] m]
> >>   (doseq [[collection-name collection] collections]
> >> (doseq [[string-id data] collection]
> >>   ;; do stuff with all the above
> >> )))
> >
> >
> > Is there a more idiomatic/better way to do deeply nested
> > iterations/traversal of map of maps?
> >
> > Thank you for any replies!
> >
> > Ryan
> >
> > --
> > --
> > 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.
>
> --
> --
> 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.
>

-- 
-- 
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: I need a vector not a list?

2013-12-03 Thread Cedric Greevey
Seems to me that you can make a case for "a seq is sort of like an
immutable PersistentIterator would be".

Iterator -> next (get object)
seq -> first (get object)

Iterator -> next (mutate to point to next object)
seq -> next (return new seq whose first is next object)





On Tue, Dec 3, 2013 at 2:49 AM, Andy Smith wrote:

> Great point...
>
> --
> --
> 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.
>

-- 
-- 
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: Best way to loop a map of maps

2013-12-03 Thread Jay Fields
I was going to type in the example with multiple bindings, but this
will probably be more helpful:
http://blog.jayfields.com/2013/05/clojure-combining-calls-to-doseq-and-let.html

On Tue, Dec 3, 2013 at 6:05 PM, Ryan  wrote:
> Hi all,
>
> I am trying to figure out a better way to loop the following map than using
> nested doseq. The map has the following structure:
>
>> (def m
>>   {"outerKeyA" {:innerKeyA {"string id" {:foo 1 :bar 2}}}
>>"outerKeyB" {:innerKeyB {"string id" {:bar 5 :baz 10)
>
>
> So, right now i am doing the following:
>
>> (doseq [[outer-keys collections] m]
>>   (doseq [[collection-name collection] collections]
>> (doseq [[string-id data] collection]
>>   ;; do stuff with all the above
>> )))
>
>
> Is there a more idiomatic/better way to do deeply nested
> iterations/traversal of map of maps?
>
> Thank you for any replies!
>
> Ryan
>
> --
> --
> 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.

-- 
-- 
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.


Best way to loop a map of maps

2013-12-03 Thread Ryan
Hi all,

I am trying to figure out a better way to loop the following map than using 
nested doseq. The map has the following structure:

(def m
>   {"outerKeyA" {:innerKeyA {"string id" {:foo 1 :bar 2}}}
>"outerKeyB" {:innerKeyB {"string id" {:bar 5 :baz 10)


So, right now i am doing the following:

(doseq [[outer-keys collections] m]
>   (doseq [[collection-name collection] collections]
> (doseq [[string-id data] collection]
>   ;; do stuff with all the above 
> )))


Is there a more idiomatic/better way to do deeply nested 
iterations/traversal of map of maps?

Thank you for any replies!

Ryan 

-- 
-- 
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: Import dbpedia data into neo4j using clojure

2013-12-03 Thread Joseph Guhlin
What version of neo4j are you using?

For your swap! you are mixing transients and atoms
(swap! id-map #(assoc! % res id)) 
should be:
(swap! id-map assoc res id)

The swap! fn will apply the value of the atom id-map to the fn as the first 
argument, followed by the remaining arguments, and then set the value of 
the atom to what the fn spits out:
so (swap! id-map assoc res id) is taking the value of (assoc @id-map res 
id) and storing it as the atom's new value.

I'm still not certain why you are having issues with the .createNode 
inserter, if you are on 2.0.0.* you may need to pass a labels array. You 
can use this code to create it and pass it:

(into-array org.neo4j.graphdb.Label labels)

Make sure your import has all of those:
Mine looks like (in the ns declaration):
  (:import (org.neo4j.graphdb NotFoundException
  NotInTransactionException
  RelationshipType
  DynamicLabel
  Label)
(org.neo4j.kernel EmbeddedGraphDatabase
  AbstractGraphDatabase)
   (org.neo4j.unsafe.batchinsert BatchInserter
 BatchInserters
 BatchInserterIndexProvider
 BatchInserterIndex)
   (org.neo4j.index.lucene.unsafe.batchinsert 
LuceneBatchInserterIndexProvider)))


For reference, my create-node fn calls like this:
(.createNode db
(-convert-props node-properties)
(into-array org.neo4j.graphdb.Label labels))

It's part of a larger series of fn's, which return a promise for each 
queued node, and only creates the relationship when all of those promises 
have been fulfilled, or I would post more code. I've been meaning to work 
on a simple tutorial though.

Neocons is a great library, but uses the REST API, which may be too slow or 
may not meet your requirements. 

Let me know how it goes.

Best,
--Joseph

On Monday, December 2, 2013 4:11:53 AM UTC-6, Himakshi Mangal wrote:

> Hi...
>
>
> I am using clojure to import dbpedia data into neo4j.
>
> Here's the code:
> (ns opal.dbpedia
>   (:use [clojure.tools.logging :only [log]])
>   (:require [clojure.java.io :as io])
>   (:import [uk.ac.manchester.cs.owl.owlapi.turtle.parser TurtleParser]
>[org.neo4j.unsafe.batchinsert BatchInserters]
>[org.neo4j.graphdb DynamicRelationshipType]))
>
> ;; PARSING METHODS
>
> (defn get-next-tuple
>   [parser]
>   (let [last-item (atom nil)
> tuple (atom [])]
> (while (and (not= "." @last-item)
> (not= "" @last-item))
>   (reset! last-item
>   (-> parser
> (.getNextToken)
> (.toString)))
>   (swap! tuple conj @last-item))
> (when-not (empty? (first @tuple)) ; .getNextToken returns "" once you 
> are out of data
>   @tuple)))
>
> (defn seq-of-parser
>   [parser]
>   (if-let [next-tuple (get-next-tuple parser)]
> (lazy-cat [next-tuple]
>   (seq-of-parser parser
>
> (defn parse-file
>   [filename]
>   (seq-of-parser
> (TurtleParser.
>   (io/input-stream filename
>
> ;; BATCH UPSERT METHODS
>
> (def id-map (atom nil))
> (defn insert-resource-node!
>   [inserter res]
>   (if-let [id (get @id-map res)]
> ; If the resource has aleady been added, just return the id.
> id
> ; Otherwise, add the node for the node, and remember its id for later.
> (let [id (.createNode inserter {"resource" res})]
>   (swap! id-map #(assoc! % res id))
>   id)))
>
> (defn connect-resource-nodes!
>   [inserter node1 node2 label]
>   (let [relationship (DynamicRelationshipType/withName label)]
> (.createRelationship inserter node1 node2 relationship nil)))
>
> (defn insert-tuple!
>   [inserter tuple]
>   ; Get the resource and label names out of the tuple.
>   (let [[resource-1 label resource-2 & _ ] tuple
> ; Upsert the resource nodes.
> node-1 (insert-resource-node! inserter resource-1)
> node-2 (insert-resource-node! inserter resource-2)]
> ; Connect the nodes with an edge.
> (connect-resource-nodes! inserter node-1 node-2 label)))
>
> (defn -main [graph-path & files]
>   (let [inserter (BatchInserters/inserter graph-path)]
> (doseq [file files]
>   (log :debug (str "Loading file: " file))
>   (let [c (atom 0)]
> (doseq [tuple (parse-file file)]
>   (if (= (mod @c 1) 0)
> (log :debug (str file ": " @c)))
>   (swap! c inc)
>   (insert-tuple! inserter tuple
> (log :debug "Loading complete.")
> (log :debug "Shutting down.")
> (.shutdown inserter)
> (log :debug "Shutdown complete!")))
>
> I am getting the following errors:
>
> IllegalAccessError Transient used by non-owner thread 
>  clojure.lang.PersistentArrayMap$TransientArrayMap.ensureEditable 
> (PersistentArrayMap.java:449) 

Re: reduce vs fold

2013-12-03 Thread James Reeves
Hi Caleb,

This surprised me as well. It seems that if you try to fold a map, the
function has two arguments:

(r/fold + (r/map (fn [k v] v) {:a 1 :b 2}))   ;; works
(r/reduce + (r/map (fn [k v] v) {:a 1 :b 2})) ;; doesn't work

(r/reduce + (r/map (fn [[k v]] v) {:a 1 :b 2}))   ;; works
(r/fold + (r/map (fn [[k v]] v) {:a 1 :b 2})) ;; doesn't work


I suspect this is a bug. I'll ask on the clojure-dev mailing list.

- James



On 2 December 2013 16:25,  wrote:

> Hi everyone,
>
> Let d be some map, says {1 3/5, 2 1/5, 3 1/5}
> why
> (reduce + (map #(% 1) d)) => 1
> while
> (fold + (map #(% 1) d)) => ArityException Wrong number of args (2) passed
> to
>
> The reduce,fold, and map are those in the reducers namespace.
>
> Can someone explain to me? Thanks
> -
> Caleb
>
> --
> --
> 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.
>

-- 
-- 
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: clojure.zip branch? and next behaviour

2013-12-03 Thread martin_clausen
I believe the documentation is imprecise as you point out. The "loc" 
returned by next at the :end, is not a location as it lacks meta data. I 
don't think this is intentional, but clearly I could be wrong.

I don't see any immediate issues in patching next like below so it returns 
a real loc, and this would make your code work.

(defn next
...
(loop [p loc]
 (if (up p)
   (or (right (up p)) (recur (up p)))
   (with-meta [(node p) :end] (meta loc)))

On Monday, December 2, 2013 6:01:06 PM UTC+1, Milton Silva wrote:
>
> I was trying to write a function next-branch.
>
> I wrote somthing like:
> (use 'clojure.zip)
> (def zp (seq-zip '(+ 1 2 (+ 3 4) (+ 5 6
> (defn next-branch [loc] (second (filter branch? (iterate next loc
>
> (next-branch (next-branch (next-branch zp)))
> this results in: NullPointerException   clojure.zip/branch? (zip.clj:73)
>
> Reading the docs of next "returns a distinguished loc", this seams to 
> imply next should always return a loc even when at the end. The docs of 
> branch? "Returns true if the node at loc is a branch" seam to imply any 
> loc will do.
>
> So this would lead me to concluded that next always returns a "loc" and 
> since branch? is supposed to take a "loc" it should work.
>
> Why doesn't next return a loc at the end? Looking at the code I know "why" 
> but is it intended to be this way? If so why?
>

-- 
-- 
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.