Re: Tool authors: ClojureScript support in tools.namespace?

2015-07-25 Thread Daniel Compton
Kibit uses a vendored copy of file/clojure-file? and
find/find-clojure-sources-in-dir, to support other possible Clojure
extensions like cljx. Without the ability to add more extensions like cljx
we couldn't switch back, however even if they were added, it's probably not
worth adding the dep for two functions.

--
Daniel Compton
On Sat, 25 Jul 2015 at 2:48 PM Ambrose Bonnaire-Sergeant 
abonnaireserge...@gmail.com wrote:

 In core.typed I use *parse* and *file* to parse Clojure files and
 probably ClojureScript files eventually.

 I resolve the files myself so I don't have strong opinions on 3).

 Thanks,
 Ambrose

 On Sat, Jul 25, 2015 at 5:14 AM, Stuart Sierra 
 the.stuart.sie...@gmail.com wrote:

 Hello to anyone and everyone writing tools for working with Clojure and
 ClojureScript source files …

 I've been looking into adding better support for ClojureScript in
 tools.namespace.

 It's not a trivial problem. Lots of places in tools.namespace assume
 there is only one kind of source file. For Clojure 1.7 it got updated to
 include .cljc files as well, but it's still hard-coded. I've collected some
 of my notes in TNS-35: http://dev.clojure.org/jira/browse/TNS-35

 My question to you: if you maintain a tool or library which uses
 tools.namespace:

1. Do you need/want ClojureScript support?

2. What namespaces (repl, find, dir, file, parse) do you call in
 tools.namespace?

3. How would you like to distinguish between get me Clojure sources
 and get me ClojureScript sources?

 Note: I am **not** proposing a full port of tools.namespace to
 ClojureScript. Something like c.t.n.repl/refresh is too tightly coupled
 to JVM Clojure, and equivalent tools already exist for ClojureScript.

 This is just about using tools.namespace to parse and analyze the
 dependencies of ClojureScript source files, statically, the same way it now
 does for Clojure source files.

 Thanks,
 –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
 ---
 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/d/optout.


  --
 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/d/optout.

-- 
--
Daniel

-- 
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/d/optout.


Re: Paper on Immutable Persistent Data Structures

2015-07-25 Thread Jean Niklas L'orange
On Tuesday, July 21, 2015 at 1:43:54 AM UTC+2, JvJ wrote:

 Does anyone know if there exists a paper/web page describing in detail how 
 each of Clojure's data structures are implemented?


I have a formal analysis and all the core algorithms related to the 
Persistent Vector in Chapter 2 of my thesis: http://hypirion.com/thesis.pdf

Bagwell's original paper on the Array Mapped Trie, which is the basis for 
the Persistent Hash Map implementation, is also a good read and probably 
more approachable 
paper: http://infoscience.epfl.ch/record/64394/files/triesearches.pdf

And, as already mentioned, my informal blogpost series about them is over 
at http://hypirion.com/musings/understanding-persistent-vector-pt-1

I really like Okasaki's book Purely Functional Data Structures, but if 
you're only interested in the Persistent Vector and Persistent Hash Map, 
then I think it would be overkill to read it. Variants of them are first 
described in chapters 9-10. Mohit gave a good link to understand the sorted 
sets and maps.

-- Jean Niklas

-- 
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/d/optout.


Re: What is the best way to pass log configs everywhere without a global var?

2015-07-25 Thread Shantanu Kumar
Logging calls are far too frequent to practically pass config as argument 
everywhere, hence some kind of shared implicit context is required. Which 
logging libraries are you dealing with? If you use Timbre[1], you can pass 
config using dynamic vars or altering global state. If you use Logback[2] 
or Log4j[3], you can set system properties using Java interop ahead of 
dynamically loading (by looking up ns/var entry points in) Clojure code.

[1] Timbre: https://github.com/ptaoussanis/timbre
[2] Logback: http://logback.qos.ch/
[3] Log4j: http://logging.apache.org/log4j/2.x/

Shantanu

On Saturday, 25 July 2015 20:20:55 UTC+5:30, crocket wrote:

 Logging libraries seem to rely on a global config. This looks like a 
 dangerous state that could blow up.
 I researched a little, and there seems to be reader monad and dependency 
 injection, all of which feel awkard.

 Is there not a decent approach to passing log config without a global var?


-- 
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/d/optout.


Re: Tool authors: ClojureScript support in tools.namespace?

2015-07-25 Thread Dylan Butman
I use .repl constantly for namespace reloading. Clojurescript support would 
be a fantastic improvement for reloading cljs component systems.

On Friday, July 24, 2015 at 5:14:04 PM UTC-4, Stuart Sierra wrote:

 Hello to anyone and everyone writing tools for working with Clojure and 
 ClojureScript source files …

 I've been looking into adding better support for ClojureScript in 
 tools.namespace.

 It's not a trivial problem. Lots of places in tools.namespace assume there 
 is only one kind of source file. For Clojure 1.7 it got updated to include 
 .cljc files as well, but it's still hard-coded. I've collected some of my 
 notes in TNS-35: http://dev.clojure.org/jira/browse/TNS-35

 My question to you: if you maintain a tool or library which uses 
 tools.namespace:

1. Do you need/want ClojureScript support?

2. What namespaces (repl, find, dir, file, parse) do you call in 
 tools.namespace?

3. How would you like to distinguish between get me Clojure sources 
 and get me ClojureScript sources?

 Note: I am **not** proposing a full port of tools.namespace to 
 ClojureScript. Something like c.t.n.repl/refresh is too tightly coupled 
 to JVM Clojure, and equivalent tools already exist for ClojureScript.

 This is just about using tools.namespace to parse and analyze the 
 dependencies of ClojureScript source files, statically, the same way it now 
 does for Clojure source files.

 Thanks,
 –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
--- 
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/d/optout.


What is the best way to pass log configs everywhere without a global var?

2015-07-25 Thread crocket
Logging libraries seem to rely on a global config. This looks like a 
dangerous state that could blow up.
I researched a little, and there seems to be reader monad and dependency 
injection, all of which feel awkard.

Is there not a decent approach to passing log config without a global var?

-- 
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/d/optout.


Re: [ANN] Pink 0.2.0, Score 0.3.0

2015-07-25 Thread Steven Yi
Thanks Ruslan and best of luck in your musical work!

On Sat, Jul 25, 2015 at 12:24 AM, Ruslan Prokopchuk fer.ob...@gmail.com wrote:
 Steven, thank you for continuing to develop Pink  Score! I have some music
 projects as my slowly-moving-forward-hobbies, and having pure java, no deps
 like Supercollider, engine for one of them is very precious!

 пятница, 24 июля 2015 г., 23:47:30 UTC+3 пользователь Steven Yi написал:

 Hi All,

 I'd like to announce the release of Pink 0.2.0 and Score 0.3.0:

 [kunstmusik/pink 0.2.0]
 [kunstmusik/score 0.3.0]

 Pink is an audio engine library, and Score is a library for
 higher-level music representations (e.g. notes, phrases, parts,
 scores).

 ChangeLogs are available at:

 https://github.com/kunstmusik/pink/blob/master/CHANGELOG.md
 https://github.com/kunstmusik/score/blob/master/CHANGELOG.md

 The quick version is Pink now has some new effects (ringmod, freeverb,
 chorus) as well as some new filters and delay-based audio functions.
 Score has a new sieves namespace for Xenakis-style sieves. (An example
 of sieves and freeverb is available in the music-examples project
 [1]).

 For any questions, please feel free to email me or post on the
 pink-users list.  For issues and PR's, please use the facilities on
 Github for each of the projects.

 Thanks!
 steven


 [1] -
 https://github.com/kunstmusik/music-examples/blob/master/src/music_examples/sieves.clj

-- 
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/d/optout.


Re: Tool authors: ClojureScript support in tools.namespace?

2015-07-25 Thread Bozhidar Batsov
Stuart mentioned that equivalent tools already exist for cljs, but I'm not
sure what he refers to. CIDER makes use of `c.t.n.repl/refresh` (its
lower-level blocks to be precise) and it'd be great if we could provide the
same functionality for cljs.

On 25 July 2015 at 17:37, Dylan Butman dbut...@gmail.com wrote:

 I use .repl constantly for namespace reloading. Clojurescript support
 would be a fantastic improvement for reloading cljs component systems.


 On Friday, July 24, 2015 at 5:14:04 PM UTC-4, Stuart Sierra wrote:

 Hello to anyone and everyone writing tools for working with Clojure and
 ClojureScript source files …

 I've been looking into adding better support for ClojureScript in
 tools.namespace.

 It's not a trivial problem. Lots of places in tools.namespace assume
 there is only one kind of source file. For Clojure 1.7 it got updated to
 include .cljc files as well, but it's still hard-coded. I've collected some
 of my notes in TNS-35: http://dev.clojure.org/jira/browse/TNS-35

 My question to you: if you maintain a tool or library which uses
 tools.namespace:

1. Do you need/want ClojureScript support?

2. What namespaces (repl, find, dir, file, parse) do you call in
 tools.namespace?

3. How would you like to distinguish between get me Clojure sources
 and get me ClojureScript sources?

 Note: I am **not** proposing a full port of tools.namespace to
 ClojureScript. Something like c.t.n.repl/refresh is too tightly coupled
 to JVM Clojure, and equivalent tools already exist for ClojureScript.

 This is just about using tools.namespace to parse and analyze the
 dependencies of ClojureScript source files, statically, the same way it now
 does for Clojure source files.

 Thanks,
 –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
 ---
 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/d/optout.


-- 
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/d/optout.


Re: Tool authors: ClojureScript support in tools.namespace?

2015-07-25 Thread Stuart Sierra
On Sat, Jul 25, 2015 at 10:37 AM, Dylan Butman dbut...@gmail.com wrote:

 Clojurescript support would be a fantastic improvement for reloading cljs
 component systems.


As I said, I am not planning a complete port of the reloading functionality
of clojure.tools.namespace.repl to work in ClojureScript. The mechanics of
reloading code are completely different in ClojureScript.

The ClojureScript compiler itself now has some auto-compiling
functionality, and tools like lein-figwheel are filling in the rest.

–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
--- 
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/d/optout.


Re: Tool authors: ClojureScript support in tools.namespace?

2015-07-25 Thread Stuart Sierra
On Sat, Jul 25, 2015 at 11:15 AM, Bozhidar Batsov wrote:

 it'd be great if we could provide the same functionality for cljs.


I'd like to say I know how to do that, but I just don't think it's possible
right now. The way tools.namespace does reloading in Clojure(JVM) depends
on implementation details of the Clojure runtime, including the function
remove-ns which doesn't exist in ClojureScript.

–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
--- 
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/d/optout.


Re: Tool authors: ClojureScript support in tools.namespace?

2015-07-25 Thread Brian Marick

Midje

Stuart Sierra wrote:

1. Do you need/want ClojureScript support?


Eventually, but not soon.



2. What namespaces (repl, find, dir, file, parse) do you call in
tools.namespace?


repl, dir, track, reload



3. How would you like to distinguish between get me Clojure
sources and get me ClojureScript sources?


I don't have an opinion.

--
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/d/optout.


Re: Generating varying sized map using test.check

2015-07-25 Thread Carlo Zancanaro
Hey Mayank!

What you've done here might appear to work, but it will get you into
trouble when test.check starts to shrink your inputs. When test.check runs
your generators it relies you you using it as your only source of
randomness, and so your use of `rand-int` will cause some problems.

The trick is to use the `bind` function to make a generator which depends
on the value of another generator (in this case, to capture the generated
map so you can call rand-subset with the correct set of keys):

(defn rand-subset
  Given a collection coll
   it'll generate a random subset.
  [coll]
  (gen/fmap (fn [i] (combo/nth-subset coll i))
(gen/choose 0 (dec (combo/count-subsets coll)

(defn gen-varying-map
  Given a generator which generates a map,
   it'll randomly select keys from it thus making it
   varying-sized map.
   Note: It can return empty maps as well.
  [map-gen]
  (gen/bind map-gen
(fn [map]
  (gen/fmap (fn [keyseq]
  (select-keys map keyseq))
(rand-subset (keys map))

(gen/sample (gen-varying-map (gen/hash-map
  user (gen/such-that not-empty
gen/string-alpha-numeric)
  level gen/nat
  timezone gen/pos-int)))
=
({user e, level 0}
 {level 1}
 {user M1}
 {timezone 2}
 {user 2, level 2, timezone 0}
 {timezone 3}
 {user W, level 5, timezone 0}
 {timezone 5}
 {}
 {})

This output appears the same as yours, but it will produce predictable
shrink trees, and thus will shrink more effectively.

Carlo

On 26 July 2015 at 07:10, Mayank Jain firesof...@gmail.com wrote:

 Hi,

 I would like to generate variable sized map using test.check i.e.
 given any generator which generates a map, it should randomly select-keys
 from it.

 Here's what I've come up with so far:


 (ns proj.util
   (:require [clojure.test.check.generators :as gen]
 [clojure.math.combinatorics :as combo]))

 (defn rand-subset
   Given a collection coll,
it'll generate a random subset.
   [coll]
   (- coll
combo/count-subsets
rand-int
(combo/nth-subset coll)))

 (defn gen-varying-map
   Given a generator which generates a map,
it'll randomly select keys from it thus making it
varying-sized map.
Note: It can return empty maps as well.
   [map-gen]
   (gen/fmap (fn [m]
   (let [ks (rand-subset (keys m))]
 (select-keys m ks)))
 map-gen))

 Here's an example output,
 (gen/sample (gen-varying-map (gen/hash-map
   user (gen/such-that not-empty

 gen/string-alphanumeric)
   level gen/nat
   timezone gen/pos-int)))
 =
 ({user 1}
  {user l8, level 0, timezone 1}
  {level 1}
  {user oA, timezone 0}
  {level 2, timezone 1}
  {level 5}
  {user 8aP, level 5, timezone 6}
  {user 035rqi, level 7}
  {timezone 4}
  {timezone 2})

 My question is, is this the right way? Or is there a better way to do it?

 Thanks :)

 --
 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/d/optout.


-- 
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/d/optout.


Re: pr-str and safe serialization

2015-07-25 Thread xavi
Hello,

I also stumbled on this bug.

Here's a simple example showing the problem...

(def a (pr-str (map (fn [i] (println hi) i) [1])))

After executing that code I was expecting the value of `a` to be `(1)`, 
but instead the actual value is `(hi\n1)`.

Xavi


On Thursday, June 25, 2015 at 2:32:42 AM UTC+2, Matching Socks wrote:

 There are currently no votes for either Jira issue!

  - No.1532, pr-str captures stdout from printing side-effects of lazily 
 evaluated expressions

  - No.1611, clojure.java.io/pushback-reader



-- 
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/d/optout.


Re: Generating varying sized map using test.check

2015-07-25 Thread Gary Fredericks
It also might be helpful to know that there is already a subset generator 
available in this library 
https://github.com/gfredericks/test.chuck#generators.

Gary

On Saturday, July 25, 2015 at 6:54:59 PM UTC-5, Carlo wrote:

 Hey Mayank!

 What you've done here might appear to work, but it will get you into 
 trouble when test.check starts to shrink your inputs. When test.check runs 
 your generators it relies you you using it as your only source of 
 randomness, and so your use of `rand-int` will cause some problems.

 The trick is to use the `bind` function to make a generator which depends 
 on the value of another generator (in this case, to capture the generated 
 map so you can call rand-subset with the correct set of keys):

 (defn rand-subset
   Given a collection coll
it'll generate a random subset.
   [coll]
   (gen/fmap (fn [i] (combo/nth-subset coll i))
 (gen/choose 0 (dec (combo/count-subsets coll)

 (defn gen-varying-map
   Given a generator which generates a map,
it'll randomly select keys from it thus making it
varying-sized map.
Note: It can return empty maps as well.
   [map-gen]
   (gen/bind map-gen
 (fn [map]
   (gen/fmap (fn [keyseq]
   (select-keys map keyseq))
 (rand-subset (keys map))

 (gen/sample (gen-varying-map (gen/hash-map
   user (gen/such-that not-empty 
 gen/string-alpha-numeric)
   level gen/nat
   timezone gen/pos-int)))
 =
 ({user e, level 0}
  {level 1}
  {user M1}
  {timezone 2}
  {user 2, level 2, timezone 0}
  {timezone 3}
  {user W, level 5, timezone 0}
  {timezone 5}
  {}
  {})

 This output appears the same as yours, but it will produce predictable 
 shrink trees, and thus will shrink more effectively.

 Carlo

 On 26 July 2015 at 07:10, Mayank Jain fires...@gmail.com javascript: 
 wrote:

 Hi,

 I would like to generate variable sized map using test.check i.e.
 given any generator which generates a map, it should randomly select-keys 
 from it.

 Here's what I've come up with so far:
  

 (ns proj.util
   (:require [clojure.test.check.generators :as gen]
 [clojure.math.combinatorics :as combo]))

 (defn rand-subset
   Given a collection coll,
it'll generate a random subset.
   [coll]
   (- coll
combo/count-subsets
rand-int
(combo/nth-subset coll)))

 (defn gen-varying-map
   Given a generator which generates a map,
it'll randomly select keys from it thus making it
varying-sized map.
Note: It can return empty maps as well.
   [map-gen]
   (gen/fmap (fn [m]
   (let [ks (rand-subset (keys m))]
 (select-keys m ks)))
 map-gen))

 Here's an example output,
 (gen/sample (gen-varying-map (gen/hash-map
   user (gen/such-that not-empty
 
 gen/string-alphanumeric)
   level gen/nat
   timezone gen/pos-int)))
 = 
 ({user 1}
  {user l8, level 0, timezone 1}
  {level 1}
  {user oA, timezone 0}
  {level 2, timezone 1}
  {level 5}
  {user 8aP, level 5, timezone 6}
  {user 035rqi, level 7}
  {timezone 4}
  {timezone 2})

 My question is, is this the right way? Or is there a better way to do it?

 Thanks :)

 -- 
 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 
 javascript:
 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 javascript:
 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+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/d/optout.




-- 
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/d/optout.


Re: Tool authors: ClojureScript support in tools.namespace?

2015-07-25 Thread Lars Andersen
refactor-nrepl, which is the brain behind refactoring libraries like 
clj-refactor and clj-light-refactor uses:

1. find/find-namespaces-in-jarfile
2. file/clojure-file?
3. find/find-clojure-sources-in-dir
4. parse/read-ns-decl

And finally, dependency, file and track are used together to get a list of 
dependent namespaces, e.g. to find out which files are affected when a file 
or dir of files has been moved.

As we add refactoring support for cljs, tools.namespace is one of the 
libraries we're going to lean on.  Since refactor-nrepl is a side project, 
support for cljs in libraries like tools.namespace often end up being a 
deciding factor when debating which feature to build next.

I don't have a strong opinion on 3, but get-me-all-source-files with 
predicate functions for filtering might be nice, because the predicate 
functions themselves are somewhat useful.

Thanks for working on tools.namespace, it's been a joy to use when writing 
tooling!

Lars

On Friday, July 24, 2015 at 11:14:04 PM UTC+2, Stuart Sierra wrote:

 Hello to anyone and everyone writing tools for working with Clojure and 
 ClojureScript source files …

 I've been looking into adding better support for ClojureScript in 
 tools.namespace.

 It's not a trivial problem. Lots of places in tools.namespace assume there 
 is only one kind of source file. For Clojure 1.7 it got updated to include 
 .cljc files as well, but it's still hard-coded. I've collected some of my 
 notes in TNS-35: http://dev.clojure.org/jira/browse/TNS-35

 My question to you: if you maintain a tool or library which uses 
 tools.namespace:

1. Do you need/want ClojureScript support?

2. What namespaces (repl, find, dir, file, parse) do you call in 
 tools.namespace?

3. How would you like to distinguish between get me Clojure sources 
 and get me ClojureScript sources?

 Note: I am **not** proposing a full port of tools.namespace to 
 ClojureScript. Something like c.t.n.repl/refresh is too tightly coupled 
 to JVM Clojure, and equivalent tools already exist for ClojureScript.

 This is just about using tools.namespace to parse and analyze the 
 dependencies of ClojureScript source files, statically, the same way it now 
 does for Clojure source files.

 Thanks,
 –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
--- 
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/d/optout.