CLJS: Working with js-lib calls (?)

2012-10-26 Thread Frank Siebenlist
When you're calling functions of js-libs in clojurescript, you will face a lot 
of boilerplate transformations to native js-objects and/or arrays.

The calls that I make start to look like:


(js-lib-fn (jayq.util/clj->js param1) (jayq.util/clj->js param2) 
(jayq.util/clj->js param3))


where the params are cljs-datatypes, and where I want the {} to be transformed 
into js-objects and the [] to become js-arrays.

I thought I was clever when I came up with the following fn:


(defn jsfn->clj [f] (fn [& params] (apply f (map jayq.util/clj->js 
params

(def cljs-js-lib-fn (jsfn->clj js-lib-fn)


where "jsfn->clj" takes an exisiting js-fn and just calls the clj->js 
transformation function on the parameters.

After that one-time assignment, you would simply use cljs-js-lib-fn… and life 
is good.

This approach works a little bit, but seems to choke on those js-fn that rely 
on "this" for their implementation. I've attached an error-message.

Is there a way to make this work?
I'm aware of the "this-as" macro, but it's unclear to me how to use that one in 
the "jsfn->clj" function definition (?).

Are there other approaches maybe that can ease the "too much boilerplate code" 
issue?

Thanks, FrankS.



Error message:

#
"Error evaluating:" (ext-msg-alert "Hello" "Hoi There!!!") :as 
"cljs.user.ext_msg_alert.call(null,\"Hello\",\"Hoi There!!!\");\n"
#
TypeError: Object function (title, message, fn, scope) {
return this.show({
title   : title,
message : message,
buttons : Ext.MessageBox.OK,
promptConfig: false,
fn  : function() {
if (fn) {
fn.apply(scope, arguments);
}
},
scope: scope
});
} has no method 'show'
at Function.Ext.define.alert 
(http://localhost:8080/js/sencha-touch/sencha-touch-all-debug.js:66782:21)
at apply__2 (http://localhost:8080/js/main-debug.js:9185:16)
at apply (http://localhost:8080/js/main-debug.js:9269:25)
at cljs.core.pr_str.call.cljs.user.jsfn__GT_clj.G__7469__delegate (eval at 
 (http://localhost:8080/js/main-debug.js:29682:147), 
:4:24)
at cljs.core.pr_str.call.cljs.user.jsfn__GT_clj.G__7469 (eval at 
 (http://localhost:8080/js/main-debug.js:29682:147), 
:11:26)
at eval (eval at  
(http://localhost:8080/js/main-debug.js:29682:147), :1:89)
at eval (eval at  
(http://localhost:8080/js/main-debug.js:29682:147), :6:3)
at http://localhost:8080/js/main-debug.js:29682:142
at evaluate_javascript (http://localhost:8080/js/main-debug.js:29695:4)
at Object.callback (http://localhost:8080/js/main-debug.js:29760:132)
nil


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


Re: monads

2012-10-26 Thread Ben Wolfson
On Fri, Oct 26, 2012 at 8:39 PM, Stephen Compall
 wrote:
> On Fri, 2012-10-26 at 09:06 -0700, Brian Craft wrote:
>> First, do monads provide a generic solution, so I can apply
>> f(g(h(x)))?
>
> Yes.  control.algo.monads provides it as m-chain.

Can you expand on this? If the functions are

f :: a -> b
g :: c -> d
h :: e -> j [renamed from "f"]

and "you'd like to chain [them] like f(g(h(x))), but you can't because
b is a different type from c and d is a different type from e.", how
does m-chain help?

I would have expected, given the "b is a different type from c" thing,
that the chaining would go h(g(f(x)), but it's not as if that helps,
unless the types work out like:

b ~ m c
d ~ m e

in which case f >=> g >=> h :: a -> j works fine (assuming j is a
monadic value). But as a general matter I don't see how monadic
composition solves the problem.

-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks,
which may be sweet, aromatic, fermented or spirit-based. ... Family
and social life also offer numerous other occasions to consume drinks
for pleasure." [Larousse, "Drink" entry]

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


core.logic and other types of solvers

2012-10-26 Thread Brandon Bloom
There was a mention of linear programming in this 
threadabout 
core.logic.

I wonder: Is it possible to compose the techniques?

I've only just started digging into core.logic (ie today), but I've messed 
with less-general constraint systems in the past. My prior experience is 
primarily with physics engines in games, but also some linear solvers. In 
particular, I'm thinking about future efforts in GUI applications.

Consider for Adobe's Adam and 
Eve,
 
which are a property model and layout engine respectively. Adam uses a 
specialized solver for resolving multi-way dataflow; Eve uses a linear 
solver for constraining the geometry of UI widgets.

I'd suspect the specialized solvers provide performance 
and predictability tuned to their particular use cases. It's worth noting 
is that both components must provide interactive performance. I wonder if 
there is some way to leverage the infrastructure of core.logic backed by 
different types of solvers.


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

Re: monads

2012-10-26 Thread Stephen Compall
On Fri, 2012-10-26 at 09:06 -0700, Brian Craft wrote:
> First, do monads provide a generic solution, so I can apply
> f(g(h(x)))?

Yes.  control.algo.monads provides it as m-chain.

The closest equivalent to m-chain in Haskell is (foldl' (>=>) return),
but in most situations you would favor f =<< g =<< h x for your example,
or more compositionally (f <=< g <=< h) x.

> Second, is it the whole point of monads to use macros so you don't see
> the glue functions, like s(), in my example? I mean, we can always
> write glue functions so we can compose functions with different
> input/output types without using monads.

We can always write things out explicitly instead of exploiting existing
abstractions.  As for macros, the above samples use ordinary Haskell
function calls.


-- 
Stephen Compall
"^aCollection allSatisfy: [:each | aCondition]": less is better than


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


Re: with-open and line-seq

2012-10-26 Thread Dave Ray
Andy,

That's the "custom seq that closes the file..." I was referring to. I
guess I looking for a magical line-seq that closes the file correctly
even if you consume part of the sequence, is resilient to exceptions,
etc, etc. I realize that it might be impossible, so I asked. :)

Thanks,

Dave

On Fri, Oct 26, 2012 at 7:10 PM, Andy Fingerhut
 wrote:
> Devin, did you mean read-line from the old clojure.contrib.io?
>
> http://clojuredocs.org/clojure_contrib/clojure.contrib.io/read-lines
>
> Click the "+" symbol next to "Source" to see source code, also available here:
>
> https://github.com/richhickey/clojure-contrib/blob/061f3d5b45657a89faa335ffa2bb80819f2e6918/src/main/clojure/clojure/contrib/io.clj#L302
>
> Andy
>
> On Oct 26, 2012, at 5:23 PM, Devin Walters wrote:
>
>> I usually wind up with the line-seq from old contrib. Could you be more 
>> clear about what isn't satisfying about that? For me it usually boils down 
>> to: it's unsatisfying that core line-seq doesn't do that by default.
>>
>> '(Devin Walters)
>>
>> On Oct 26, 2012, at 6:45 PM, Dave Ray  wrote:
>>
>>> Hi,
>>>
>>> At work I've had a few conversations about treating files, especially
>>> large ones, as seqs of lines. In particular, the apparent conflict
>>> between using clojure.core/with-open to ensure a file is closed
>>> appropriately, and clojure.core/line-seq as a generic sequence of
>>> lines which may be consumed by code that has no idea it's coming from
>>> a file. I've been told [1] that C# solves this problem because the
>>> IEnumerator interface is disposable so it's possible to clean up the
>>> underlying file, even if it's been wrapped in several layers of
>>> enumerators... and that since Clojure doesn't do this, it's flawed :)
>>>
>>> Thoughs? I'm aware of the "custom seq that closes the file when the
>>> end is reached" hack, but that doesn't seem very satisfying. How do
>>> others process large files in Clojure? Just make sure that the
>>> sequence is totally consumed within with-open? Just don't worry about
>>> closing files?
>>>
>>> Cheers,
>>>
>>> Dave
>>>
>>>
>>> [1] My C# experience is limited to a few days of writing example code
>>> for the C# bindings of a product's API. :)
>>>
>>> --
>>> 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 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 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 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


Re: with-open and line-seq

2012-10-26 Thread Andy Fingerhut
Devin, did you mean read-line from the old clojure.contrib.io?

http://clojuredocs.org/clojure_contrib/clojure.contrib.io/read-lines

Click the "+" symbol next to "Source" to see source code, also available here:

https://github.com/richhickey/clojure-contrib/blob/061f3d5b45657a89faa335ffa2bb80819f2e6918/src/main/clojure/clojure/contrib/io.clj#L302

Andy

On Oct 26, 2012, at 5:23 PM, Devin Walters wrote:

> I usually wind up with the line-seq from old contrib. Could you be more clear 
> about what isn't satisfying about that? For me it usually boils down to: it's 
> unsatisfying that core line-seq doesn't do that by default.
> 
> '(Devin Walters)
> 
> On Oct 26, 2012, at 6:45 PM, Dave Ray  wrote:
> 
>> Hi,
>> 
>> At work I've had a few conversations about treating files, especially
>> large ones, as seqs of lines. In particular, the apparent conflict
>> between using clojure.core/with-open to ensure a file is closed
>> appropriately, and clojure.core/line-seq as a generic sequence of
>> lines which may be consumed by code that has no idea it's coming from
>> a file. I've been told [1] that C# solves this problem because the
>> IEnumerator interface is disposable so it's possible to clean up the
>> underlying file, even if it's been wrapped in several layers of
>> enumerators... and that since Clojure doesn't do this, it's flawed :)
>> 
>> Thoughs? I'm aware of the "custom seq that closes the file when the
>> end is reached" hack, but that doesn't seem very satisfying. How do
>> others process large files in Clojure? Just make sure that the
>> sequence is totally consumed within with-open? Just don't worry about
>> closing files?
>> 
>> Cheers,
>> 
>> Dave
>> 
>> 
>> [1] My C# experience is limited to a few days of writing example code
>> for the C# bindings of a product's API. :)
>> 
>> -- 
>> 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 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 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


Re: what is the simplest user auth system possible?

2012-10-26 Thread Anthony Grimes
Another +1 for Persona. I'm the author of Refheap which uses Persona, and I 
chose it specifically because of how easy it was to implement and use.

On Friday, October 26, 2012 3:26:16 PM UTC-5, Pierre R wrote:
>
> +1 for Persona. Please give your user a chance to break the cycle of 
> password madness ;-)
>
> On Friday, October 26, 2012 1:10:42 PM UTC+2, Dave Sann wrote:
>>
>> Sorry, I meant to say authentication.
>>
>> On Friday, 26 October 2012 22:06:48 UTC+11, Dave Sann wrote:
>>>
>>> For authorisation, I really like mozilla persona (previously browserid) 
>>> which I discovered from refheap. javascript lib plus an http request from 
>>> the server to validate. really simple.
>>>
>>> https://login.persona.org/
>>>
>>> Dave
>>>
>>>
>>>
>>> On Friday, 26 October 2012 01:35:53 UTC+11, Stephen Compall wrote:

 On Oct 25, 2012 9:04 AM, "larry google groups"  
 wrote:
 > For my next step, I need to come up with a user system. My needs are 
 minimal: I only need to know when someone is logged in, and I need to 
 associate them with some user id (the id will simply be the id from a user 
 table kept in MySql). 
 >
 > I am curious what is the absolutely easiest way to do this?

 The easiest auth system to write is the one that's already written.

 https://github.com/cemerick/friend

 --
 Stephen Compall
 If anyone in the MSA is online, you should watch this flythrough. 

>>>

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

Re: with-open and line-seq

2012-10-26 Thread Devin Walters
I usually wind up with the line-seq from old contrib. Could you be more clear 
about what isn't satisfying about that? For me it usually boils down to: it's 
unsatisfying that core line-seq doesn't do that by default.

'(Devin Walters)

On Oct 26, 2012, at 6:45 PM, Dave Ray  wrote:

> Hi,
> 
> At work I've had a few conversations about treating files, especially
> large ones, as seqs of lines. In particular, the apparent conflict
> between using clojure.core/with-open to ensure a file is closed
> appropriately, and clojure.core/line-seq as a generic sequence of
> lines which may be consumed by code that has no idea it's coming from
> a file. I've been told [1] that C# solves this problem because the
> IEnumerator interface is disposable so it's possible to clean up the
> underlying file, even if it's been wrapped in several layers of
> enumerators... and that since Clojure doesn't do this, it's flawed :)
> 
> Thoughs? I'm aware of the "custom seq that closes the file when the
> end is reached" hack, but that doesn't seem very satisfying. How do
> others process large files in Clojure? Just make sure that the
> sequence is totally consumed within with-open? Just don't worry about
> closing files?
> 
> Cheers,
> 
> Dave
> 
> 
> [1] My C# experience is limited to a few days of writing example code
> for the C# bindings of a product's API. :)
> 
> -- 
> 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 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


Re: let in the middle of thread-first

2012-10-26 Thread Jason Bennett
Appreciate everyone's responses! I'll certainly check out the let-> option.

jason

On Friday, October 26, 2012 6:16:28 AM UTC-7, Jonathan Fischer Friberg 
wrote:
>
> You could also let every function take a map as input/output.
> Then, b could return a map with key :result-b or similar.
> This result would then pass through the rest of the functions and be 
> accessible in e.
>
> Like this:
> a ; => {:result-a ...}
> b ; => {:result-b ... :result-a ...}
> ...
> d ; => {... :result-a ...}
> e ; use :result-a
>
> This technique is brought up in:
> http://www.infoq.com/presentations/Thinking-in-Data
>
> Jonathan
>
> On Fri, Oct 26, 2012 at 4:43 AM, Ben Mabey 
> > wrote:
>
>> On 10/25/12 6:24 PM, Jason Bennett wrote:
>>
>>>
>>> Let's say I have a set of thread-first calls:
>>>
>>> (-> url
>>>  a
>>>  b
>>>  c
>>>  d
>>>  e)
>>>
>>> And let's say that I need to process and save the result of function b 
>>> as a second parameter to function e (function b returns a file, and 
>>> function e needs the extention of that file). How would I drop a let into 
>>> the middle of the thread calls without making a large mess? The only 
>>> suggestion I've gotten so far is to move calls A and B into a let before 
>>> the thread-first so I can process their return values.
>>>
>>> jason
>>>
>>
>> Pallet's thread-exp library has a let-> macro that would do the trick:
>>
>> https://github.com/pallet/**thread-expr/blob/develop/src/**
>> pallet/thread_expr.clj#L100-**106
>>
>> I love the thread-expr library but when I spoke with Hugo Duncan at 
>> Clojure West he said that pallet's use of it was largely being replaced by 
>> monads.
>>
>> -Ben
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@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+u...@**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 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

with-open and line-seq

2012-10-26 Thread Dave Ray
Hi,

At work I've had a few conversations about treating files, especially
large ones, as seqs of lines. In particular, the apparent conflict
between using clojure.core/with-open to ensure a file is closed
appropriately, and clojure.core/line-seq as a generic sequence of
lines which may be consumed by code that has no idea it's coming from
a file. I've been told [1] that C# solves this problem because the
IEnumerator interface is disposable so it's possible to clean up the
underlying file, even if it's been wrapped in several layers of
enumerators... and that since Clojure doesn't do this, it's flawed :)

Thoughs? I'm aware of the "custom seq that closes the file when the
end is reached" hack, but that doesn't seem very satisfying. How do
others process large files in Clojure? Just make sure that the
sequence is totally consumed within with-open? Just don't worry about
closing files?

Cheers,

Dave


[1] My C# experience is limited to a few days of writing example code
for the C# bindings of a product's API. :)

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


ANN: core.logic-0.8.0-beta2

2012-10-26 Thread David Nolen
Enhancements:
- experimental support for Datomic
- eqfd now supports - & /

Fixes:
- distinctfd goal behaved badly if argument wasn't ground
- LOGIC-62: distincto bug reveals much larger issues around how we look up
constraints. because vars can be bound in any order and we use vars to map
to constraints in the store we need a stable root var. constrained vars are
now added as ::unbound in the substitution map. This information is used to
determine if a var is a root.
- partial map unification and easy unification now support in ClojureScript
- LOGIC-61: fix partial map support for CLJS
- LOGIC-63: fix simple unification support for CLJS
- removed deprecated IPrintable from core.logic CLJS, implemented
IPrintWithWriter
distinctfdc only needs to watch ::subst

http://github.com/clojure/core.logic

Feedback welcome,
David

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

Re: Has anyone posted with Clojurescript (XhrIo) to a non Clojure based web framework?

2012-10-26 Thread Jack Moffitt
> (.send goog.net.XhrIo action callback  'POST' serialized )))

You are using the clojure symbol 'POST' not the string "POST". Switch
to double quotes and I bet it works.

jack.

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


Has anyone posted with Clojurescript (XhrIo) to a non Clojure based web framework?

2012-10-26 Thread Sean S
Can't seem to get it to work.  Have tried posting to a .Net Mvc 4 action, 
and a Ruby/Rails action.  Have had no success at all. It attempts and then 
just throws an exception:

"SYNTAX_ERR: DOM Exception 12"
"Error: An invalid or illegal string was specified."

Problem is, that doesn't really help much. I've tried creating an object 
from form data manually. Tried using cloSure to create the needed form 
data. Tried serializing both. ect. Really new to clojurescript and cloSure, 
so I'm hoping it's something really simple. Just can't find any examples 
that work that don't involve a clojure based framework.


(defn get-form-action [formName]
  (let [form (dom/$ formName)]
  form/action))

(defn callback [reply] 
  (js/alert reply))

(defn ajax-json [formName]
  (let [action (str (get-form-action formName) ".json")
formData (.toObject (.getFormDataMap goog.dom.forms (dom/$ 
formName)))
serialized(goog.json.serialize formData)]
(.send goog.net.XhrIo action callback  'POST' serialized )))

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

Re: what is the simplest user auth system possible?

2012-10-26 Thread Pierre R
+1 for Persona. Please give your user a chance to break the cycle of 
password madness ;-)

On Friday, October 26, 2012 1:10:42 PM UTC+2, Dave Sann wrote:
>
> Sorry, I meant to say authentication.
>
> On Friday, 26 October 2012 22:06:48 UTC+11, Dave Sann wrote:
>>
>> For authorisation, I really like mozilla persona (previously browserid) 
>> which I discovered from refheap. javascript lib plus an http request from 
>> the server to validate. really simple.
>>
>> https://login.persona.org/
>>
>> Dave
>>
>>
>>
>> On Friday, 26 October 2012 01:35:53 UTC+11, Stephen Compall wrote:
>>>
>>> On Oct 25, 2012 9:04 AM, "larry google groups"  
>>> wrote:
>>> > For my next step, I need to come up with a user system. My needs are 
>>> minimal: I only need to know when someone is logged in, and I need to 
>>> associate them with some user id (the id will simply be the id from a user 
>>> table kept in MySql). 
>>> >
>>> > I am curious what is the absolutely easiest way to do this?
>>>
>>> The easiest auth system to write is the one that's already written.
>>>
>>> https://github.com/cemerick/friend
>>>
>>> --
>>> Stephen Compall
>>> If anyone in the MSA is online, you should watch this flythrough. 
>>>
>>

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

Re: monads

2012-10-26 Thread Brian Marick
On Oct 26, 2012, at 11:06 AM, Brian Craft wrote:

> I've read about four tutorials on monads so far, but it still escapes me.
> 
> In fact, I'm still not sure what problem it solves. 


Monads are hard to understand, and I too found I wasn't the target audience for 
the explanations I read. I finally had to write my own as a way to force me to 
understand. Advertisement: the explanation is in chapter 10 and the optional 
chapters 15 and 16 of my book. (URL in my signature.) People seem to like mine 
because I start with the implementation, not the abstract ideas. Also, I lie 
when necessary on the way to the complete explanation.

The problem monads solve is twofold:

1. Suppose you have a series of computational steps. The results of those steps 
have to be combined in some way. A monad lets you move the combination rules 
away from the steps, so that you don't have to look at them. You just look at 
the steps and keep the rules in the back of your mind. That reduces code 
clutter.

2. Often, the rules are more general purpose than the steps. For example, it's 
common to want to break out of a series of steps when an error happens. Rather 
than scattering `if`s between some steps, you can point the Error monad at 
them. (When is that better than just using try/catch? -- that's still an open 
question to me.)

That said, the *really* general-purpose monads tend to get written into the 
language as special forms. Clojure's `let` and `for` are both monads, but you 
don't need to know that to use them. 

One thing that's important to realize about monads is that they apply the 
*same* rule to every step. That seems to make them clunky when you're working 
on problems that aren't nicely structured. But for certain structured problems, 
especially ones that lend themselves to combinations of predefined rules that 
apply to every step, monads are just The Right Thing.

Even if you don't use them, I'm inclined to think monads are a useful example 
of how to think about functions in a functional language. It helps you avoid 
just writing C code in Clojure. 

-
Brian Marick, Artisanal Labrador
Contract programming in Ruby and Clojure
Occasional consulting on Agile
Writing /Functional Programming for the Object-Oriented Programmer/: 
https://leanpub.com/fp-oo


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


Re: monads

2012-10-26 Thread Andy Fingerhut
I can't say I grok monads completely yet, but was one of the tutorials you read 
this one?

http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html

I like the style of showing how they solve problems that arise naturally in the 
context of purely functional programming, with several examples of those kinds 
of problems.

Andy

On Oct 26, 2012, at 9:06 AM, Brian Craft wrote:

> I've read about four tutorials on monads so far, but it still escapes me.
> 
> In fact, I'm still not sure what problem it solves. I'm familiar with the 
> problem of having, say, three functions like f(a) -> b, g(c) -> d, h(e) -> f, 
> which you'd like to chain like f(g(h(x))), but you can't because b is a 
> different type from c and d is a different type from e. The monad tutorials 
> all start with a problem like this, but I still can't tell if they're 
> actually providing a solution, because it appears every monad is specific to 
> a particular type. E.g. a sequence monad. So, great, I have something that 
> takes a scalar and returns a sequence. That might solve g(h(x)) if f is a 
> scalar and c is a sequence by letting me write g(s(h(x))), but it doesn't 
> solve the whole problem, since I still have f() to worry about.
> 
> So, two specific questions. First, do monads provide a generic solution, so I 
> can apply f(g(h(x)))? Second, is it the whole point of monads to use macros 
> so you don't see the glue functions, like s(), in my example? I mean, we can 
> always write glue functions so we can compose functions with different 
> input/output types without using monads. What exactly are monads adding?
> 
> Oh, and one more. If I were to actually use a monad in a piece of production 
> code, what are the chances that the next person working on the code would 
> have the faintest idea how it worked? ;-p

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


Re: [core.logic] How to implement "synthetic" answers?

2012-10-26 Thread David Nolen
On Fri, Oct 26, 2012 at 4:16 AM, Tassilo Horn  wrote:

> Any ideas and pointers how to implement that?
>

I don't really see anyway to do this without the graph itself being a
relational data structure. I haven't seen any data structure that fits that
bill beyond lists (which of course can be used to build others).


> I think this should be doable with a deftype with mutable fields.  Then
> my relations would emit a final instance of this type (or modify a given
> instance) with the known properties set (e.g., typeo sets the type
> field, vertexo sets the kind fild to vertex, valueo sets an entry of
> some attributes map, etc).
>

You can't put mutable things into core.logic because of backtracking.

I don't see any obvious way to make this work beyond converting the graph
into a list and running your query on that.

David

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

compare doubles for equality fn

2012-10-26 Thread Michael
Can someone recommend a library that contains a function comparing doubles 
for equality?

This clojure cookbook has a section on comparing floating-point numbers.

http://www.gettingclojure.com/cookbook:numbers

This blog post makes me want to find an implementation by someone who has 
more experience in these matters. Thanks.

http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

There is no silver bullet. You have to choose wisely.

   - If you are comparing against zero, then relative epsilons and ULPs 
   based comparisons are usually meaningless. You’ll need to use an absolute 
   epsilon, whose value might be some small multiple of FLT_EPSILON and the 
   inputs to your calculation. Maybe.
   - If you are comparing against a non-zero number then relative epsilons 
   or ULPs based comparisons are probably what you want. You’ll probably want 
   some small multiple of FLT_EPSILON for your relative epsilon, or some small 
   number of ULPs. An absolute epsilon could be used if you knew exactly what 
   number you were comparing against.
   - If you are comparing two arbitrary numbers that could be zero or 
   non-zero then you need the kitchen sink. Good luck and God speed.

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

monads

2012-10-26 Thread Brian Craft
I've read about four tutorials on monads so far, but it still escapes me.

In fact, I'm still not sure what problem it solves. I'm familiar with the 
problem of having, say, three functions like f(a) -> b, g(c) -> d, h(e) -> 
f, which you'd like to chain like f(g(h(x))), but you can't because b is a 
different type from c and d is a different type from e. The monad tutorials 
all start with a problem like this, but I still can't tell if they're 
actually providing a solution, because it appears every monad is specific 
to a particular type. E.g. a sequence monad. So, great, I have something 
that takes a scalar and returns a sequence. That might solve g(h(x)) if f 
is a scalar and c is a sequence by letting me write g(s(h(x))), but it 
doesn't solve the whole problem, since I still have f() to worry about.

So, two specific questions. First, do monads provide a generic solution, so 
I can apply f(g(h(x)))? Second, is it the whole point of monads to use 
macros so you don't see the glue functions, like s(), in my example? I 
mean, we can always write glue functions so we can compose functions with 
different input/output types without using monads. What exactly are monads 
adding?

Oh, and one more. If I were to actually use a monad in a piece of 
production code, what are the chances that the next person working on the 
code would have the faintest idea how it worked? ;-p

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

[ANN] Typed Clojure 0.1, analyze 0.2

2012-10-26 Thread Ambrose Bonnaire-Sergeant
Hi,

I've cleaned up a release of Typed Clojure to coincide with my dissertation
(also released another version of analyze).

Please try it out. (Clojure 1.5.0-beta1 only)

Typed Clojure 0.1

https://github.com/frenchy64/typed-clojure

[typed "0.1"]


analyze 0.2

https://github.com/frenchy64/analyze

[analyze "0.2"]

Thanks,
Ambrose

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

Re: fastest way to remove nils

2012-10-26 Thread Softaddicts
No problem, however this nuance has broader implications than just this code 
snippet :)
If you pass false and nil values to a library and expect them to be processed
differently, you may end up with a big surprise.

Luc


> The difference between nil and false is really handy in some cases
> and for many people removing nil (or keeping not-nil) values from a seq
> is not removing falsy values.
> 
> I just wanted to point out the issues that may arise from a blind use of 
> (filter identity [...]) ;)
> 
> On Friday, October 26, 2012 4:36:16 PM UTC+2, Luc wrote:
> 
> > I avoid making explicit distinctions between false and nil in my code. 
> > In Clojure a falsy value is either nil or false. 
> >
> > In interop I ensure that null and false when returned in the upper layers 
> > are made consistent (including Boolean objects set to false). 
> >
> > Too much potential trouble in my opinion to let this slip everywhere in 
> > your 
> > code, it's not semantically coherent with Clojure. 
> >
> > Luc P. 
> >
> >
> > > Be careful with the (filter identity ...) which will also remove 
> > "falses" 
> > > from seqs. 
> > > (filter identity [nil 2 3 nil false true 4]) 
> > > => (2 3 true 4) 
> > > Since (identity false) and (identity nil) returns respectively false and 
> > > nil they are BOTH rejected by filter. 
> > > 
> > > This could do the trick: 
> > > (filter (comp not nit?) [nil 2 3 nil false true 4]) 
> > > => (2 3 false true 4) 
> > > 
> > > On Wednesday, November 17, 2010 2:37:16 AM UTC+1, Luc wrote: 
> > > 
> > > > user=> (time (filter identity [ nil 1 2 nil 4])) 
> > > > "Elapsed time: 0.053219 msecs" 
> > > > (1 2 4) 
> > > > 
> > > > user=> (time (remove nil? [ nil 1 2 nil 4])) 
> > > > "Elapsed time: 0.065092 msecs" 
> > > > (1 2 4) 
> > > > 
> > > > Choose the flavor your prefer... 
> > > > 
> > > > Luc P. 
> > > > 
> > > > Glen Rubin > wrote .. 
> > > > > What is the fastest way to remove nils from a sequence? 
> > > > > 
> > > > > I usually use the filter function, but I see there are other 
> > functions 
> > > > > like remove that should also do the trick. 
> > > > > 
> > > > > -- 
> > > > > You received this message because you are subscribed to the Google 
> > > > > Groups "Clojure" group. 
> > > > > To post to this group, send email to 
> > > > > clo...@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+u...@googlegroups.com  
> > > > > For more options, visit this group at 
> > > > > http://groups.google.com/group/clojure?hl=en 
> > > > Luc P. 
> > > > 
> > > >  
> > > > The rabid Muppet 
> > > > 
> > > > 
> > > 
> > > -- 
> > > You received this message because you are subscribed to the Google 
> > > Groups "Clojure" group. 
> > > To post to this group, send email to clo...@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+u...@googlegroups.com  
> > > For more options, visit this group at 
> > > http://groups.google.com/group/clojure?hl=en 
> > -- 
> > Softaddicts> sent by ibisMail from 
> > my ipad! 
> >
> 
> -- 
> 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
--
Softaddicts sent by ibisMail from my ipad!

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


Re: fastest way to remove nils

2012-10-26 Thread kevin roth
The difference between nil and false is really handy in some cases
and for many people removing nil (or keeping not-nil) values from a seq
is not removing falsy values.

I just wanted to point out the issues that may arise from a blind use of 
(filter identity [...]) ;)

On Friday, October 26, 2012 4:36:16 PM UTC+2, Luc wrote:

> I avoid making explicit distinctions between false and nil in my code. 
> In Clojure a falsy value is either nil or false. 
>
> In interop I ensure that null and false when returned in the upper layers 
> are made consistent (including Boolean objects set to false). 
>
> Too much potential trouble in my opinion to let this slip everywhere in 
> your 
> code, it's not semantically coherent with Clojure. 
>
> Luc P. 
>
>
> > Be careful with the (filter identity ...) which will also remove 
> "falses" 
> > from seqs. 
> > (filter identity [nil 2 3 nil false true 4]) 
> > => (2 3 true 4) 
> > Since (identity false) and (identity nil) returns respectively false and 
> > nil they are BOTH rejected by filter. 
> > 
> > This could do the trick: 
> > (filter (comp not nit?) [nil 2 3 nil false true 4]) 
> > => (2 3 false true 4) 
> > 
> > On Wednesday, November 17, 2010 2:37:16 AM UTC+1, Luc wrote: 
> > 
> > > user=> (time (filter identity [ nil 1 2 nil 4])) 
> > > "Elapsed time: 0.053219 msecs" 
> > > (1 2 4) 
> > > 
> > > user=> (time (remove nil? [ nil 1 2 nil 4])) 
> > > "Elapsed time: 0.065092 msecs" 
> > > (1 2 4) 
> > > 
> > > Choose the flavor your prefer... 
> > > 
> > > Luc P. 
> > > 
> > > Glen Rubin > wrote .. 
> > > > What is the fastest way to remove nils from a sequence? 
> > > > 
> > > > I usually use the filter function, but I see there are other 
> functions 
> > > > like remove that should also do the trick. 
> > > > 
> > > > -- 
> > > > You received this message because you are subscribed to the Google 
> > > > Groups "Clojure" group. 
> > > > To post to this group, send email to 
> > > > clo...@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+u...@googlegroups.com  
> > > > For more options, visit this group at 
> > > > http://groups.google.com/group/clojure?hl=en 
> > > Luc P. 
> > > 
> > >  
> > > The rabid Muppet 
> > > 
> > > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Clojure" group. 
> > To post to this group, send email to clo...@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+u...@googlegroups.com  
> > For more options, visit this group at 
> > http://groups.google.com/group/clojure?hl=en 
> -- 
> Softaddicts> sent by ibisMail from 
> my ipad! 
>

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

Re: fastest way to remove nils

2012-10-26 Thread Softaddicts
I avoid making explicit distinctions between false and nil in my code.
In Clojure a falsy value is either nil or false.

In interop I ensure that null and false when returned in the upper layers 
are made consistent (including Boolean objects set to false).

Too much potential trouble in my opinion to let this slip everywhere in your
code, it's not semantically coherent with Clojure.

Luc P.


> Be careful with the (filter identity ...) which will also remove "falses" 
> from seqs.
> (filter identity [nil 2 3 nil false true 4])
> => (2 3 true 4)
> Since (identity false) and (identity nil) returns respectively false and 
> nil they are BOTH rejected by filter.
> 
> This could do the trick:
> (filter (comp not nit?) [nil 2 3 nil false true 4])
> => (2 3 false true 4)
> 
> On Wednesday, November 17, 2010 2:37:16 AM UTC+1, Luc wrote:
> 
> > user=> (time (filter identity [ nil 1 2 nil 4]))
> > "Elapsed time: 0.053219 msecs"
> > (1 2 4)
> >
> > user=> (time (remove nil? [ nil 1 2 nil 4]))
> > "Elapsed time: 0.065092 msecs"
> > (1 2 4)
> >
> > Choose the flavor your prefer...
> >
> > Luc P.
> >
> > Glen Rubin > wrote ..
> > > What is the fastest way to remove nils from a sequence?
> > > 
> > > I usually use the filter function, but I see there are other functions
> > > like remove that should also do the trick.
> > > 
> > > -- 
> > > You received this message because you are subscribed to the Google
> > > Groups "Clojure" group.
> > > To post to this group, send email to clo...@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+u...@googlegroups.com 
> > > For more options, visit this group at
> > > http://groups.google.com/group/clojure?hl=en
> > Luc P.
> >
> > 
> > The rabid Muppet
> >
> >
> 
> -- 
> 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
--
Softaddicts sent by ibisMail from my ipad!

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


Re: Clojurescript externs when using a local file (cljsbuild)

2012-10-26 Thread Sean S
Awesome. Thanks.

On Friday, October 26, 2012 12:30:07 AM UTC-4, Evan Mezeske wrote:
>
> One other thing I ought to mention is that your *.cljs files need to be 
> arranged in an appropriate directory structure (i.e. the directories must 
> match the namespaces):
>
> /src-cljs/live/helper/webTemplate.cljs
> /src/cljs-test/helper/webTemplate/test.cljs
>
> The ClojureScript compiler (sadly) allows files to shirk this convention 
> if they're in the main :source-path (it just grabs ALL *.cljs files 
> recursively).  However, if you're loading *.cljs files from a different 
> directory, they will be loaded as Java resources, and thus need to use the 
> Java directory conventions.
>
> -Evan
>

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

Re: ANN: data.json 0.2.0

2012-10-26 Thread Stuart Sierra
It is done. data.json 0.2.1 coming to a repository near you.

http://build.clojure.org/job/data.json/77/

https://github.com/clojure/data.json/tree/data.json-0.2.1

-S

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

Re: compile fails but stack trace does not mention a line of code in my app

2012-10-26 Thread Stathis Sideris
I've seen this error when putting the function name *after* the docstring 
instead of before in a defn.

Stathis


On Thursday, 25 October 2012 20:05:25 UTC+1, Philip Potter wrote:
>
> Since we're wild mass guessing, I'd say from that stack trace that there's 
> invalid syntax in a defn's signature somewhere.
>
> I'm basing this on the references to clojure.core$defn and 
> clojure.core$sigs shortly above compile and macroexpand. 
>
> Phil 
> On Oct 25, 2012 7:36 PM, "larry google groups" 
> > 
> wrote:
>
>>
>> I am finding the following stack trace unusually devoid of information. 
>> My app is Clojure 1.3. I run "lein compile" and I get the following stack 
>> trace. Am I blind, or does this stack trace fail to tell me what line I 
>> should look at?
>>
>>
>>
>> lein compile
>> Compiling who-is-logged-in.core
>> Exception in thread "main" java.lang.IllegalArgumentException: Don't know 
>> how to create ISeq from: clojure.lang.Symbol
>> at clojure.lang.RT.seqFrom(RT.java:487)
>> at clojure.lang.RT.seq(RT.java:468)
>> at clojure.lang.RT.first(RT.java:560)
>> at clojure.core$first.invoke(core.clj:55)
>> at clojure.core$map$fn__3811.invoke(core.clj:2432)
>> at clojure.lang.LazySeq.sval(LazySeq.java:42)
>> at clojure.lang.LazySeq.seq(LazySeq.java:60)
>> at clojure.lang.RT.seq(RT.java:466)
>> at clojure.core$seq.invoke(core.clj:133)
>> at clojure.core$filter$fn__3830.invoke(core.clj:2468)
>> at clojure.lang.LazySeq.sval(LazySeq.java:42)
>> at clojure.lang.LazySeq.seq(LazySeq.java:60)
>> at clojure.lang.RT.seq(RT.java:466)
>> at clojure.core$seq.invoke(core.clj:133)
>> at clojure.core$assert_valid_fdecl.invoke(core.clj:6464)
>> at clojure.core$sigs.invoke(core.clj:220)
>> at clojure.core$defn.doInvoke(core.clj:293)
>> at clojure.lang.RestFn.invoke(RestFn.java:525)
>> at clojure.lang.Var.invoke(Var.java:421)
>> at clojure.lang.AFn.applyToHelper(AFn.java:185)
>> at clojure.lang.Var.applyTo(Var.java:518)
>> at clojure.lang.Compiler.macroexpand1(Compiler.java:6320)
>> at clojure.lang.Compiler.macroexpand(Compiler.java:6381)
>> at clojure.lang.Compiler.compile1(Compiler.java:6970)
>> at clojure.lang.Compiler.compile(Compiler.java:7046)
>> at clojure.lang.RT.compile(RT.java:385)
>> at clojure.lang.RT.load(RT.java:425)
>> at clojure.lang.RT.load(RT.java:398)
>> at clojure.core$load$fn__4610.invoke(core.clj:5386)
>> at clojure.core$load.doInvoke(core.clj:5385)
>> at clojure.lang.RestFn.invoke(RestFn.java:408)
>> at clojure.core$load_one.invoke(core.clj:5200)
>> at clojure.core$compile$fn__4615.invoke(core.clj:5397)
>> at clojure.core$compile.invoke(core.clj:5396)
>> at user$eval27.invoke(NO_SOURCE_FILE:1)
>> at clojure.lang.Compiler.eval(Compiler.java:6465)
>> at clojure.lang.Compiler.eval(Compiler.java:6455)
>> at clojure.lang.Compiler.eval(Compiler.java:6431)
>> at clojure.core$eval.invoke(core.clj:2795)
>> at clojure.main$eval_opt.invoke(main.clj:296)
>> at clojure.main$initialize.invoke(main.clj:315)
>> at clojure.main$null_opt.invoke(main.clj:348)
>> at clojure.main$main.doInvoke(main.clj:426)
>> at clojure.lang.RestFn.invoke(RestFn.java:421)
>> at clojure.lang.Var.invoke(Var.java:405)
>> at clojure.lang.AFn.applyToHelper(AFn.java:163)
>> at clojure.lang.Var.applyTo(Var.java:518)
>> at clojure.main.main(main.java:37)
>> Compilation failed.
>>
>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@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+u...@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 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

Re: let in the middle of thread-first

2012-10-26 Thread Jonathan Fischer Friberg
You could also let every function take a map as input/output.
Then, b could return a map with key :result-b or similar.
This result would then pass through the rest of the functions and be
accessible in e.

Like this:
a ; => {:result-a ...}
b ; => {:result-b ... :result-a ...}
...
d ; => {... :result-a ...}
e ; use :result-a

This technique is brought up in:
http://www.infoq.com/presentations/Thinking-in-Data

Jonathan

On Fri, Oct 26, 2012 at 4:43 AM, Ben Mabey  wrote:

> On 10/25/12 6:24 PM, Jason Bennett wrote:
>
>>
>> Let's say I have a set of thread-first calls:
>>
>> (-> url
>>  a
>>  b
>>  c
>>  d
>>  e)
>>
>> And let's say that I need to process and save the result of function b as
>> a second parameter to function e (function b returns a file, and function e
>> needs the extention of that file). How would I drop a let into the middle
>> of the thread calls without making a large mess? The only suggestion I've
>> gotten so far is to move calls A and B into a let before the thread-first
>> so I can process their return values.
>>
>> jason
>>
>
> Pallet's thread-exp library has a let-> macro that would do the trick:
>
> https://github.com/pallet/**thread-expr/blob/develop/src/**
> pallet/thread_expr.clj#L100-**106
>
> I love the thread-expr library but when I spoke with Hugo Duncan at
> Clojure West he said that pallet's use of it was largely being replaced by
> monads.
>
> -Ben
>
>
> --
> 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+unsubscribe@**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 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

Re: ANN: Guzheng 1.2.5

2012-10-26 Thread dgrnbrg
Tassilo:
I've incorporated this fix and rereleased as [lein-guzheng 1.4.4] (which 
will automatically pull in the latest guzheng).

Ambrose:
Guzheng works by instrumenting all code just before it's eval'ed, using 
Zach Tellman's sleight library, which is essentially a way to do whole 
program macros. It uses functional programs and logic programs to rewrite 
most conditionals to include instrumentation about whether they were 
executed. When the JVM exits, a hook runs that reports all the un-taken 
branches to stdout. I've pasted some sample output below:

#lein guzheng \* -- test
in ns foo.core: arity [a x] is not covered in "defn goodbye3" on line 21
in ns foo.core: false branch is not covered in "if" on line 31
in ns foo.core: :else is not covered in "cond" on line 50

The statements point out which branch on which line wasn't executed, to 
help you improve test coverage in areas of complex code that you're not 
sure is being testing sufficiently thoroughly. I use guzheng to gain 
confidence in complex fundamental libraries and algorithms that have many, 
many branches, to convince myself that I've sufficiently tested my code.

Thanks,
David

On Friday, October 26, 2012 4:53:42 AM UTC-4, Tassilo Horn wrote:
>
> David Greenberg > writes: 
>
> Hi David, 
>
> > Guzheng is a library for doing branch coverage analysis on Clojure 
> > projects at the command line. 
>
> Hey, that's pretty cool.  But it errors when being applied to my 
> project.  I've found the bug in guzheng and already sent you a pull 
> request. 
>
> Bye, 
> Tassilo 
>

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

Re: fastest way to remove nils

2012-10-26 Thread Moritz Ulrich
(filter (comp not nit?) [nil 2 3 nil false true 4])
->
(remove nil? [...])

On Fri, Oct 26, 2012 at 12:53 PM, kevin roth
 wrote:
> Be careful with the (filter identity ...) which will also remove "falses"
> from seqs.
> (filter identity [nil 2 3 nil false true 4])
> => (2 3 true 4)
> Since (identity false) and (identity nil) returns respectively false and nil
> they are BOTH rejected by filter.
>
> This could do the trick:
> (filter (comp not nit?) [nil 2 3 nil false true 4])
> => (2 3 false true 4)
>
> On Wednesday, November 17, 2010 2:37:16 AM UTC+1, Luc wrote:
>>
>> user=> (time (filter identity [ nil 1 2 nil 4]))
>> "Elapsed time: 0.053219 msecs"
>> (1 2 4)
>>
>> user=> (time (remove nil? [ nil 1 2 nil 4]))
>> "Elapsed time: 0.065092 msecs"
>> (1 2 4)
>>
>> Choose the flavor your prefer...
>>
>> Luc P.
>>
>> Glen Rubin  wrote ..
>> > What is the fastest way to remove nils from a sequence?
>> >
>> > I usually use the filter function, but I see there are other functions
>> > like remove that should also do the trick.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Clojure" group.
>> > To post to this group, send email to clo...@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+u...@googlegroups.com
>> > For more options, visit this group at
>> > http://groups.google.com/group/clojure?hl=en
>> Luc P.
>>
>> 
>> The rabid Muppet
>
> --
> 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 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


Re: fastest way to remove nils

2012-10-26 Thread kevin roth
Be careful with the (filter identity ...) which will also remove "falses" 
from seqs.
(filter identity [nil 2 3 nil false true 4])
=> (2 3 true 4)
Since (identity false) and (identity nil) returns respectively false and 
nil they are BOTH rejected by filter.

This could do the trick:
(filter (comp not nit?) [nil 2 3 nil false true 4])
=> (2 3 false true 4)

On Wednesday, November 17, 2010 2:37:16 AM UTC+1, Luc wrote:

> user=> (time (filter identity [ nil 1 2 nil 4]))
> "Elapsed time: 0.053219 msecs"
> (1 2 4)
>
> user=> (time (remove nil? [ nil 1 2 nil 4]))
> "Elapsed time: 0.065092 msecs"
> (1 2 4)
>
> Choose the flavor your prefer...
>
> Luc P.
>
> Glen Rubin > wrote ..
> > What is the fastest way to remove nils from a sequence?
> > 
> > I usually use the filter function, but I see there are other functions
> > like remove that should also do the trick.
> > 
> > -- 
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clo...@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+u...@googlegroups.com 
> > For more options, visit this group at
> > http://groups.google.com/group/clojure?hl=en
> Luc P.
>
> 
> The rabid Muppet
>
>

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

Re: what is the simplest user auth system possible?

2012-10-26 Thread Dave Sann
Sorry, I meant to say authentication.

On Friday, 26 October 2012 22:06:48 UTC+11, Dave Sann wrote:
>
> For authorisation, I really like mozilla persona (previously browserid) 
> which I discovered from refheap. javascript lib plus an http request from 
> the server to validate. really simple.
>
> https://login.persona.org/
>
> Dave
>
>
>
> On Friday, 26 October 2012 01:35:53 UTC+11, Stephen Compall wrote:
>>
>> On Oct 25, 2012 9:04 AM, "larry google groups"  
>> wrote:
>> > For my next step, I need to come up with a user system. My needs are 
>> minimal: I only need to know when someone is logged in, and I need to 
>> associate them with some user id (the id will simply be the id from a user 
>> table kept in MySql). 
>> >
>> > I am curious what is the absolutely easiest way to do this?
>>
>> The easiest auth system to write is the one that's already written.
>>
>> https://github.com/cemerick/friend
>>
>> --
>> Stephen Compall
>> If anyone in the MSA is online, you should watch this flythrough. 
>>
>

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

Re: what is the simplest user auth system possible?

2012-10-26 Thread Dave Sann
For authorisation, I really like mozilla persona (previously browserid) 
which I discovered from refheap. javascript lib plus an http request from 
the server to validate. really simple.

https://login.persona.org/

Dave



On Friday, 26 October 2012 01:35:53 UTC+11, Stephen Compall wrote:
>
> On Oct 25, 2012 9:04 AM, "larry google groups" 
> > 
> wrote:
> > For my next step, I need to come up with a user system. My needs are 
> minimal: I only need to know when someone is logged in, and I need to 
> associate them with some user id (the id will simply be the id from a user 
> table kept in MySql). 
> >
> > I am curious what is the absolutely easiest way to do this?
>
> The easiest auth system to write is the one that's already written.
>
> https://github.com/cemerick/friend
>
> --
> Stephen Compall
> If anyone in the MSA is online, you should watch this flythrough. 
>

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

Re: ANN: Guzheng 1.2.5

2012-10-26 Thread Tassilo Horn
David Greenberg  writes:

Hi David,

> Guzheng is a library for doing branch coverage analysis on Clojure
> projects at the command line.

Hey, that's pretty cool.  But it errors when being applied to my
project.  I've found the bug in guzheng and already sent you a pull
request.

Bye,
Tassilo

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


[core.logic] How to implement "synthetic" answers?

2012-10-26 Thread Tassilo Horn
Hi all,

I successfully use core.logic to query a custom Java graph structure.
That is, I have these core relations:

,
| (typeo g e t)
| e is a vertex or edge of graph g with type t
| 
| (vertexo g v)
| v is a vertex of graph g
| 
| (edgeo g e s t)
| e is an edge of graph g starting at vertex s and targeting t
| 
| (valueo g e a v)
| e is a vertex or edge of graph g whose a-attribute has the value v
`

The graph arg g always needs to be ground.  That works like a charm, and
I can query like

,
| (let [g (gimme-my-graph)]
|   (run* [q]
| (fresh [v e ov]
|   (typeo g v 'Bar)
|   (vertexo g v)
|   (valueo g v :name "Foo")
|   (typeo g e 'Bar2Baz)
|   (edgeo g e v ov)
|   (valueo c ov :bar 17)
|   (== q [v e ov])))
`

resulting in a seq of triples where v is a Bar-vertex with name Foo, ov
is a vertex with bar set to 17, and e is a Bar2Baz-edge starting at v
and ending at ov.  So far, so good.

Now I'd also like to have some "non-strict" querying mode (enabled by
binding some dynamic var).  Using the example above: Say, the graph g
has vertices v and ov matching the goals above, but there're no Bar2Baz
edges in between, I envision that the query would return triples [v e
ov] where v and ov are matching vertices, and e is some synthetic
deftype-instance (?) that exibits the properties such an edge would need
to posses, e.g., its type must be Bar2Baz, and it needs to start at v
and end at ov.

Any ideas and pointers how to implement that?

I think this should be doable with a deftype with mutable fields.  Then
my relations would emit a final instance of this type (or modify a given
instance) with the known properties set (e.g., typeo sets the type
field, vertexo sets the kind fild to vertex, valueo sets an entry of
some attributes map, etc).

However, that doesn't sound very clean, and it'll probably be overly
complicated, because every relation needs to check every arg for being
ground and synthetical or "real" with tons of distinctions on
handling...

Bye,
Tassilo

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