Fork me on GitHub
#clojure
<
2015-09-20
>
amacdougall00:09:11

I've been happy with automatic test runners like Quickie and lein-test-refresh, which re-run tests when the files change. However, I'd like to be able to execute a function at the beginning of each test run. Normally you'd wrap something around run-all-tests, but with these test runner plugins, I suspect I'd have to fork and give them the ability to read a pre-test command from project.clj, which seems like a hassle. Is there a workaround?

danielcompton07:09:43

@andrewboltachev: take a look at s3 private wagon. It's a very lightweight Maven repo hosted on S3. It also helps if you want to do CI, as your deps are accessible from The Cloud

danielcompton07:09:50

@amacdougall: Expectations has this feature. You could also look at just using clojure.test fixtures possibly?

danielcompton07:09:45

@andrewboltachev: let me know if you get stuck, I'd like to make the onboarding flow a bit easier.

Pablo Fernandez08:09:38

Is there any way to get a copy of the events in a channel in core.async when that channel is being used for putting and taking already by a library? otherwise I’ll have to fork the library to insert a mult in the middle.

Pablo Fernandez09:09:20

If I make a library called blah and that library can be used with, re-frame but also without, so I don’t want blah to pull re-frame in, should I provide a separate one, called blah-re-frame that depends on blah and re-frame and provides the helpers to use blah with re-frame? or should I use :provided?

thomas10:09:06

morning....

thomas10:09:48

silly question.... I have a map {:a [1 2 3 4]} and I would like to conj something onto the vector in that map... but which function to call?

jamesh10:09:48

(update {:a [1 2 3 4]} :a conj 5)

jamesh10:09:38

update was only added in 1.7

jamesh10:09:43

use update-in otherwise

nooga13:09:44

I get a java.lang.UnsupportedOperationException: count not supported on this type: HeapByteBuffer] exception. How can I implement count for HeapByteBuffer so that it will be globally used across my program?

danielcompton13:09:31

@nooga you’d need to extend the Counted protocol to HeapByteBuffer (or perhaps to one of it’s superclasses?)

tcrayford13:09:40

Counted isn't a protocol though right?

tcrayford13:09:41

it's an interface

danielcompton13:09:34

I meant interface simple_smile

danielcompton13:09:43

It’s 1:30 am 😪

thomas13:09:56

hi, any idea how I can do something like this with Compojure: (UPDATE "/v1/phonebook/:id{[0-9]+}" [id {body :body}]

thomas13:09:22

this is not quite right... but not sure what to do instead... 😞

thomas14:09:01

ok.... it was PUT ofcourse... and this seems to workL {body :body id :id}

bhauman18:09:11

so in leiningen are "dev-resources" only included for the current project under dev?

danielcompton20:09:12

@bhauman np, btw sorry for all the ridiculous figwheel bugs I’ve been posting

nooga21:09:31

I get null pointer exception somewhere in http://gloss.io/encode and it seems there’s no way to find out what causes it

nooga21:09:33

any gloss users here?

nooga22:09:24

hah I’ve just taken printf debugging to extreme and dumped state + arguments to edn file inside wiiiide exception handler

cfleming22:09:03

@bbloom: I have a fipp question. I’m interested in using it to pprint things in the Cursive REPL. Is it possible to make fipp streaming, i.e. print what it can once it knows the layout for a chunk of the doc?

bbloom22:09:27

@cfleming: fipp is already streaming

cfleming22:09:54

Oh, that was easy. I guess it incrementally processes, nice.

cfleming22:09:22

(disclaimer: That was a lazyweb question, I did dig into the code, but some time ago).

bbloom22:09:12

it’s cool - now i’m aware of your interest. feel free to lazy web some more, if it helps you make cursive pretty print awesome-like

cfleming22:09:18

Thanks, I’ll try it out and ping with questions. I have to change the printing since I’ll be outputting to an IntelliJ document rather than actually printing to stdout, but that should be straightforward.

bbloom22:09:32

oh yeah, that should be a perfect use case

bbloom22:09:52

@cfleming: you should only need to implement the visitor protocol. impl should be tiny: https://github.com/brandonbloom/fipp/blob/master/src/fipp/edn.cljc

bbloom22:09:57

for edn, anyway

bbloom22:09:15

if that’s not good enough, contributions are welcome for ednize.clj[s]

cfleming22:09:32

@bbloom: Thanks, I’ll check it out. I have my own lexer/parser which allows me to “read” unreadable forms containing #<things>

cfleming22:09:54

So I’ll have to build the formatting doc myself, but that looks simple following the EDN example

bbloom22:09:59

oh, for that, you may need something totally custom, yeah

bbloom22:09:24

ednize is for converting jvm/js objects to edn (including the tagged literall form) and then the edn.cljc file prints that closed set of types

cfleming22:09:56

That’s why I asked about it being incremental - hopefully I can make the whole thing totally streaming, which will be nice for users who insist on passing back huge data structures simple_smile

bbloom22:09:46

fipp’s edn and clojure printers are totally streaming - see discussion here: https://github.com/brandonbloom/fipp/issues/21

bbloom22:09:22

in particular, note that pudget’s default config will sort unbounded things before passing them to fipp, so pudget won’t be streaming

cfleming22:09:54

Right, ideally I’d integrate some of Cursive’s formatting smarts, but it’s hard to know when a particular form is code rather than data, and since Cursive has an interactive macroexpander I suspect that it’s nearly all data anyway.

bbloom22:09:39

cfleming: well i’m super interested to see if fipp works out for you - lmk how it goes, i’ll do what i can to help

cfleming22:09:57

IntelliJ also does some nice things like lining up map values, but that’s not a linear-time op I suspect, certainly their impl isn’t.

cfleming22:09:53

@bbloom: Cool, will let you know when I get to it. It’ll be a while, I just saw you were online in #C03S1L9DN and thought I’d ask.

bbloom22:09:20

yeah, non-linear things are OK iif you have support for incremental simple_smile

bbloom22:09:35

like show the first 50 rows + pagination

cfleming22:09:53

Well, the map alignment thing requires you to have the whole map in memory to calculate the width of the keys.

bbloom22:09:20

well all in memory is one thing

cfleming22:09:22

They use an iterative constraint algorithm for their formatting, which is flexible but not great for online use.

bbloom22:09:38

for formatting what exactly?

cfleming22:09:49

Their source code formatting engine, I mean.

bbloom22:09:52

they format source code with a constraint solver?

bbloom22:09:57

isn’t it fixed-width? or no?

bbloom22:09:03

fixed-width text, i mean

bbloom22:09:46

is it the same renderer as used by non-textual languages like MPS?

cfleming22:09:20

Well, consider the map key/value problem. You calculate the key and value widths (need the whole map) and then you figure out that the width of the whole map is way over your allotted width. You then need to break lines in your keys, your values, or both, trying to find the best way to get the total width down.

bbloom22:09:14

ooh you mean they use that approach w/ some abstraction over the code, which they then use to drive where the chars go

bbloom22:09:21

not like flexbox on arbitrary content 😛

bbloom22:09:26

heh yeah ok

bbloom22:09:43

naive pretty printing is O(N^3)

cfleming22:09:00

Yeah, basically you break the code into blocks, and express constraints on those blocks (all these ones must align, etc).

bbloom22:09:20

that’s probably reasonable for code written by humans

cfleming22:09:23

It’s very powerful, but tricky to get the results you want sometimes.

cfleming22:09:33

Yeah, not for REPL data.

bbloom22:09:39

fipp’s aimed at repl data & macro expansions

cfleming22:09:41

I tried it, didn’t work out well for me simple_smile

bbloom22:09:03

although even macro expansions could use a more complex layout algorithm — for small expansions

cfleming22:09:05

I use that engine for macro expansions, that works ok (and will work much better, when I have time to tweak it).

cfleming22:09:36

Even for big ones. I mean I haven’t tried it on core.async, but their engine formats enormous files fine.

bbloom22:09:45

that’s cool

bbloom22:09:49

hurray fast computers simple_smile

bbloom22:09:25

so you’re going to use fipp for repl output but you can’t just generate plain text?

bbloom22:09:35

is that so you can generate colors, selectable stuff, etc?

cfleming22:09:50

Yeah, exactly.

bbloom22:09:59

makes sense - sounds like a perfect fit

cfleming22:09:02

Having the REPL output colourised is really nice.

cfleming22:09:11

Makes it much more readable.

bbloom22:09:19

oh, you know what….

bbloom22:09:35

you may need to hack the printer.cljc file

bbloom22:09:39

b/c that only really outputs text

cfleming22:09:55

Yeah, last time I looked I was going to have to hack the printing part.

cfleming22:09:40

I’ll also have to track the type of the elements since I need to say “style this like a keyword” or whatever.

cfleming22:09:07

But I think that was a reasonably small hack IIRC.

bbloom22:09:41

one thing you can do is to use the passthrough primitive

bbloom22:09:08

that’s how colors are done in the terminal

bbloom22:09:19

[:pass “whatever”] puts that string in the output w/o taking up any width

bbloom22:09:24

so you can do \[[ or whatever it is in ascii

bbloom22:09:00

otherwise, you can just hack the printer to return a seq - the very last step just does (run! print ...)

bbloom22:09:12

you’d just add your own step to the end of the pipeline

bbloom22:09:31

if you get it working w/ a hacked version & have a good idea of how to parameterize the existing impl, lmk

cfleming22:09:22

Ok, will do. Is :pass how the existing things built on top of fipp colourise?

bbloom22:09:47

you could probably just pass a different function rather than print

bbloom22:09:59

hell, you could still use pass if you did that

bbloom22:09:12

i don’t think anything looks at pass, so it could be arbitrary data if the last step wasn’t print

bbloom22:09:01

could just pass a thunk to call simple_smile

cfleming22:09:17

Ok, nice, I’ll use [:pass :keyword] or something similar to print the next thing like a keyword.

cfleming22:09:43

A little stateful, but LL(1) is acceptable simple_smile

bbloom22:09:45

and then i can just add an option to the printer to override the print function & you won’t even need a fork

bbloom22:09:00

stateful is par for the course for linear simple_smile

cfleming22:09:06

That would be great, or I can just hook it.