Re: Transitive spec generation

2018-03-03 Thread James Gatannah
In case anyone was wondering, it looks like this is probably a known issue:

https://dev.clojure.org/jira/browse/CLJ-2079

On Wednesday, February 28, 2018 at 12:05:31 AM UTC-6, James Gatannah wrote:
>
>
>
> On Tuesday, February 27, 2018 at 12:45:26 AM UTC-6, Didier wrote:
>>
>> Don't fully understand what you are doing,
>>
>
> (Slightly) bigger picture, I have a pair of functions that 
> serialize/deserialize maps where the values are mostly fixed-length byte 
> arrays.
>
> I want to verify that they round-trip correctly.
>
> This specific example is about two of those fields which really have the 
> same spec. I'm trying to define this in a way that's similar to a C typedef 
> (or possibly just something like using OOP inheritance for the sake of 
> documentation):
>
> (s/def ::extension ...)
> (s/def ::server-extension ::extension)
> (s/def ::client-extension ::extension)
>
> I'm doing this in an attempt to trying to reduce my nesting levels.
>
> This is what the weird subject is about: I'm trying to take advantage of 
> the transitive property of specs.
>
>  
>
>> but when you run test.check, it seems to not always be generating random 
>> sample, it'll grow the samples. When you run sample, it'll always start 
>> back from the beginning. 
>>
>
>> You can see that by running:
>>
>> (sgen/sample (s/gen ::test) 100)
>>
>> See how the generated samples are getting longer and longer?
>>
>
> Now instead try running this 10 times:
> (sgen/sample (s/gen ::test) 10)
>
> And notice how you always get the same short samples?
>
>  
>
> (I'm sorry about the quote mangling).
>
> Since I have to have a specific length, I'm specifying that as a parameter 
> to sgen/vector.
>
> This part of it works. I can run s/sample on my generator and validate its 
> output against the spec without any trouble.
>
> Actually, if I define the ::extension spec using with-gen, it also looks 
> as though it works (I just ran across this, so haven't tested it 
> thoroughly). But then my library has a runtime dependency on test.check. 
> That's not the end of the world, but it's a definite downside.
>
> I haven't been able to find real documentation covering the arguments to 
> s/gen. But it looks as though I can pass in a map of 0-arity functions to 
> override the different generators. The keys to that map override specs 
> being generated. I can't remember now where I found this, but it can't be 
> totally undocumented. I haven't studied the source code thoroughly enough 
> to have picked out that sort of detail.
>
> So:
>
> (s/gen (s/keys :req [::server-extension
>  ::client-extension])
>{::server-extension #(gen/fmap byte-array (gen/vector (gen/choose 
> -128 127) extension-length))
> ::client-extension #(gen/fmap byte-array (gen/vector (gen/choose 
> -128 127) extension-length))})
>
>
> calls the function in the value associated with each key to override the 
> generator for that spec.
>
> This is the part that seems to only work sometimes.
>
> When I extend this to include all the keys in the full spec, these are the 
> only two that have problems. They're also the only ones that are directly 
> defined as another spec definition. (Which is why I'm pointing my finger at 
> my attempt to use the "transitive" property, though that could totally be a 
> red herring).
>
> When I run this inside deftest, it seems fine. Really, that's all I need. 
> But I'd really like to understand the seemingly non-deterministic failures.
>
> I wrote a function called manual-check that takes that generator and calls 
> sgen/sample on it.
>
> When I call that function directly from the REPL, it very nearly always 
> fails.
>
> When I call it 40 times in a reduce inside deftest, I haven't seen it fail 
> yet.
>
> * While I was writing this, I stumbled across another piece that seems 
> like an interesting clue:
>
> If I override the generator for ::extension rather than the individual 
> specs that I've defined transitively, it seems to start working.
>
> i.e. 
>
> (s/gen (s/keys :req [::server-extension
>  ::client-extension])
>{::extension #(gen/fmap byte-array (gen/vector (gen/choose -128 
> 127) extension-length))})
>  
> seems to work.
>
> It's still less than ideal, in case I ever want to change the underlying 
> spec that's the "base" definition, since I'll have to remember to change 
> the base generator. But I really shouldn't have this sort of thing 
> scattered around everywhere. Especially since it's most interesting inside 
> deftest anyway, where both approaches always seem to work (I haven't tested 
> this out thoroughly yet either).
>
> My current hypothesis is that there's something about the deftest macro 
> that interacts with test.check in a way that makes gen more capable in 
> terms of resolving which spec I actually mean/want to override. I know 
> (based on digging through internals) that it calls something (I think it's 
> named specize) that resolves the spec's 

RE: Any better client then telnet for connecting to a socket repl server?

2018-03-03 Thread Sean Corfield
You can use rlwrap with telnet but it’s a bit of a pain to deal with getting 
back out of the session. I’ve found the following works:

rlwrap -q ^Q telnet 127.0.0.1 

This sets up control-q as a quote character so when you’re ready to exit the 
session you can do ^Q ^] q 

Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood


From: clojure@googlegroups.com  on behalf of Didier 

Sent: Friday, March 2, 2018 5:49:45 PM
To: Clojure
Subject: Any better client then telnet for connecting to a socket repl server?

I want to connect to a Clojure socket repl server, but telnet is a really 
terrible repl experience. Anyway I can have a better client to connect to it 
that would have some better support for history, backspace, maybe even some 
auto-complete, highlight, etc. Whatever I can get over telnet?

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: Any better client then telnet for connecting to a socket repl server?

2018-03-03 Thread Timothy Baldridge
Sadly NREPL isn't a REPL it's a RPC protocol transport for remote
controlling a Clojure instance.

You might look into rebel: although I'm not sure how well that plays with
remote terminals.  https://github.com/bhauman/rebel-readline.

Also look into doing some of this with readline. Perhaps you can pipe
something together via netcat, GPL readline, and socket servers?

Also Emacs provide a lot of this support via inferior lisp. So, like any
lisp you can tell emacs that your inferior lisp command is a telnet command
and it all "just works".

Timothy

On Sat, Mar 3, 2018 at 11:17 AM, Chris Shellenbarger 
wrote:

> Can you use NREPL?  https://github.com/clojure/tools.nrepl
>
> This seems to be what most tools that provide a REPL are built on top of
> (Cursive, CIDER, etc).
>
>
> On Friday, March 2, 2018 at 7:49:45 PM UTC-6, Didier wrote:
>>
>> I want to connect to a Clojure socket repl server, but telnet is a really
>> terrible repl experience. Anyway I can have a better client to connect to
>> it that would have some better support for history, backspace, maybe even
>> some auto-complete, highlight, etc. Whatever I can get over telnet?
>>
>> 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.
>



-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
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] clj 1.9.0.358

2018-03-03 Thread Alex Miller
Those scripts should not be used directly - they depend on two stages of 
variable replacement and other external files before they are packaged. Linux 
installation scripts are found on the getting started page at 
https://clojure.org/guides/getting_started

-- 
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] clj 1.9.0.358

2018-03-03 Thread Rostislav Svoboda
@linux_users_not_using_the_bash_shell:
clj & clojure are bash scripts and are to be found in
https://github.com/clojure/brew-install.git


2018-03-03 15:27 GMT+01:00 Alex Miller :
> A new version of the Clojure tools (clj, clojure) is now available (see
> https://clojure.org/guides/getting_started).
>
> Just some bug fixes in this version:
>
> * FIX linux-install - use mkdir -p to ensure parent dirs are created
> * FIX brew install - move man page installation from formula to install.sh
> * FIX TDEPS-45 - don't swipe -h flag if main aliases are in effect
> * FIX TDEPS-47 - use classpath cache with -Sdeps
>
> --
> 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: Any better client then telnet for connecting to a socket repl server?

2018-03-03 Thread Chris Shellenbarger
Can you use NREPL?  https://github.com/clojure/tools.nrepl  

This seems to be what most tools that provide a REPL are built on top of 
(Cursive, CIDER, etc).

On Friday, March 2, 2018 at 7:49:45 PM UTC-6, Didier wrote:
>
> I want to connect to a Clojure socket repl server, but telnet is a really 
> terrible repl experience. Anyway I can have a better client to connect to 
> it that would have some better support for history, backspace, maybe even 
> some auto-complete, highlight, etc. Whatever I can get over telnet?
>
> 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.


Re: Why does the `def-` not exist?

2018-03-03 Thread Alex Miller
> ^:private is the stale and sleazy co-conspirator of another blunt instrument, 
> the whole-ns :use.

It’s also useful for anything that uses the var meta to show you only public 
vars in an ns, such as dir, ns-publics, etc. those are all useful and would 
affect your repl experience even if you never :use or :refer :all.

I find people have different relationships with :private depending on what kind 
of work they do. It’s very useful in in libs for delineating public apis, much 
less important in an app context.

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


Developing in Clojure with Emacs: Mastering the Keyboard

2018-03-03 Thread Chris Shellenbarger
I spent the last week learning and using Emacs and CIDER for Clojure 
Development.

I've started to write up a lot of the lessons I've learned from doing so in 
the hopes that it will help some other people who attempt something similar.

Anyway, if you're interested in getting started with Emacs and CIDER, 
you'll have to learn about how to use the keyboard so I wrote a couple of 
key lessons in a Medium post:  Developing in Clojure with Emacs: Mastering 
the Keyboard 

.

My environment was Emacs 24.5.1 with CIDER 0.16.0 on Linux Mint 18.3.

I used the Clojure for the Brave and True  book 
for a basic intro into Emacs  and 
used the provided emacs configuration files as a starting point.  However, 
these only worked with CIDER 0.8.0 and were about four years old.  I made 
some modifications of the files to work with CIDER 0.16.0 and put them up 
for anyone to use on my BitBucket Repository 
.

I have a lot more to share about my Emacs experience, but I found that 
there was so much that I had to split it into multiple posts.   

Hope it helps someone out there!



-- 
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: Why does the `def-` not exist?

2018-03-03 Thread Matching Socks
^:private is the stale and sleazy co-conspirator of another blunt 
instrument, the whole-ns :use.

Besides relegating inner-workings to a separate ns:  You can gracefully 
omit a function from auto-generated docs by putting its description in a 
comment instead of a docstring.  It would, likewise, be within the powers 
of auto-completing editors to disfavor undocumented symbols in other ns.  

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


[ANN] clj 1.9.0.358

2018-03-03 Thread Alex Miller
A new version of the Clojure tools (clj, clojure) is now available 
(see https://clojure.org/guides/getting_started).

Just some bug fixes in this version:

* FIX linux-install - use mkdir -p to ensure parent dirs are created
* FIX brew install - move man page installation from formula to install.sh
* FIX TDEPS-45 - don't swipe -h flag if main aliases are in effect
* FIX TDEPS-47 - use classpath cache with -Sdeps

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


ANN: denisovan 0.1.0 - A core.matrix backend for neanderthal.

2018-03-03 Thread Christian Weilbach
Hi,

I would like to announce the first release of denisovan.

https://github.com/cailuno/denisovan

"This library provides a core.matrix implementation for neanderthal. The
main focus of this library is to map neanderthal's high performance BLAS
routines to core.matrix protocols as closely as possible, while being
compliant with the rest of core.matrix. For documentation please look at
the core.matrix and neanderthal documentation, as this library is mostly
glue code. If you encounter any issues, including surprising performance
behaviour, please open an issue."

Next steps are the Cuda and OpenCL backends of neanderthal. I hope you
find it useful.

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


signature.asc
Description: OpenPGP digital signature


Re: Loop causing OutOfMemoryError: GC overhead limit exceeded ?

2018-03-03 Thread Aditya Athalye
On Saturday, March 3, 2018 at 1:39:23 PM UTC+5:30, Aditya Athalye wrote:
>
> On Friday, March 2, 2018 at 9:58:35 PM UTC+5:30, Rob Nikander wrote:
>>
>>
>>
>> On Friday, March 2, 2018 at 12:48:28 AM UTC-5, Daniel wrote:
>>>
>>> How do you know this code is causing the error? Unless this is all your 
>>> code does, descriptions of the error suggest the memory leak might be 
>>> coming from anywhere. This tight loop might trigger too many successive GCs 
>>> though: have you observed if the error only occurs under load, or under 
>>> large time intervals? Some combination?
>>>
>>
>> Okay, thanks for looking it over. This is a single-threaded, short lived 
>> script, so this is the only thing happening. But it's possible there is an 
>> unexpected large result set. I'll look into that. It may be smarter to use 
>> `limit N` in my SQL, rather than the time range.
>>
>
> Rob, 
>
> While I could see the intent of the original code, I found it hard to 
> reason about where the problem might lie, given the loops in loops in loops.
>
> Assuming the code is causing an error, I feel it will help to separate out 
> the db query, and factor the rest of the logic into a pipeline.
>
> This way one could:
>  - profile the DB query and fix it separately
>  - isolate and check each part of the records transformation pipeline
>  - make more obvious what's going on (aid visual audit)
>
> [snip ...]
>

P.S. Oops, replied to the wrong message. I took a slight departure from 
Gary Johnson's approach and meant to add on top of that.

-- 
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: Loop causing OutOfMemoryError: GC overhead limit exceeded ?

2018-03-03 Thread Aditya Athalye
On Friday, March 2, 2018 at 9:58:35 PM UTC+5:30, Rob Nikander wrote:
>
>
>
> On Friday, March 2, 2018 at 12:48:28 AM UTC-5, Daniel wrote:
>>
>> How do you know this code is causing the error? Unless this is all your 
>> code does, descriptions of the error suggest the memory leak might be 
>> coming from anywhere. This tight loop might trigger too many successive GCs 
>> though: have you observed if the error only occurs under load, or under 
>> large time intervals? Some combination?
>>
>
> Okay, thanks for looking it over. This is a single-threaded, short lived 
> script, so this is the only thing happening. But it's possible there is an 
> unexpected large result set. I'll look into that. It may be smarter to use 
> `limit N` in my SQL, rather than the time range.
>

Rob, 

While I could see the intent of the original code, I found it hard to 
reason about where the problem might lie, given the loops in loops in loops.

Assuming the code is causing an error, I feel it will help to separate out 
the db query, and factor the rest of the logic into a pipeline.

This way one could:
 - profile the DB query and fix it separately
 - isolate and check each part of the records transformation pipeline
 - make more obvious what's going on (aid visual audit)

May I suggest something like this (If I've understood what the original 
code is trying to achieve):

(defn query-recs
  [db min-time max-time]
  (jdbc/query db
  ["select id, a, b, c from sometable where t > ? and t <= ? 
order by t"
   min-time max-time]))


(define intervals
  [min-time max-time]
  (->> (iterate (partial plus-minutes min-t) 30)
   (take-while #(before? max-time %))
   (partition 2 1)))


(defn find-db-records [db min-time max-time]
  (let [group-rows
(fn [min-t max-t]
  (->> (query-recs db min-t max-t)
   (partition-all 200)))

extract-relevant-records
(fn [[rows foo]]
  (filter #(relevant-record? foo (:a %) (:b %))
  rows))

proc-relevant-records
(fn [rows]
  (map #(assoc % :d (computed-d (:a %) (:b %) (:c %)))
   rows))]
(reduce (fn [rxs [min-t max-t]]
  (->> (group-rows min-t max-t)
   (map (juxt identity make-foo))
   (map extract-relevant-records)
   (mapcat proc-relevant-records)
   (into rxs)))
[]
(intervals min-time max-time

 

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