#clojure logs

2016-05-23

00:03tolstoyIf you use plumatic/schema s/defrecord to apply schemas to the data in the record, why doesn't it break when you supply bad values?
00:04tolstoyOh, there it is in the doc string.
00:17tolstoyThe record itself is the schema.
00:30jasonmasonfeminist put in her place. https://www.youtube.com/watch?v=R3HvI5dJuzo
00:35dysfun...
00:43tolstoyHm. roomkey/annotate doesn't support map->Record constructor type checking.
00:45will_smIs EDN used outside of clojure/clojurescript?
00:46dysfunnot really, but there are libraries for other langs
01:16tolstoyIf you had a table (entity, attribute, value, time) and never deleted stuff, how would you query for all the attributes for a given entity, limiting to the latest time?
01:17tolstoyI mean, you know, for a dirt poor man's hacky misunderstood semblance of a kind of datomic like thing?
01:17dysfunwhat is it in?
01:17tolstoypostgres
01:18dysfunhaha. building datomic-like on postgres atm
01:18tolstoyOr, well, h2, actually. But I'm just kinda wondering.
01:18dysfungimme a minute to write a postgres query
01:18tolstoyFirst thought is just punt, load all the stuff into memory, then filter out. ;)
01:18dysfunlol
01:19tolstoyNormally, I just start writing a query and let the failure drive google searcher until I know how to ask the right question.
01:21dysfunselect eavt.a from eavt where eavt.e = ? group by eavt.a order by max(eavt.t)
01:21dysfunhave not tested!
01:21dysfunorder by eavt.t desc, probably
01:21dysfuni haven't been up long, sorry, but i hope it helps
01:22tolstoyThat looks surprisingly simple. Pays to work with a DB more than for a few weeks every couple of years.
01:23dysfunhah
01:23dysfunyeah, i think postgres actually probably is quite alright for a datomic-like
01:24tolstoyI've never used group by without a count(*) or similar. Interesting.
01:24dysfunwell the next trick that comes to mind is DISTINCT ON
01:24dysfunso many ways to drive a db
01:24tolstoyYeah.
01:26tolstoy"Find all the latest attribute versions of an entity." But also need some way to register retractions, I guess. Huh.
01:26dysfunyou may wish to just postfilter
01:26dysfunbut actually that query may not return it all
01:26dysfunyeah, fun fun
01:32tolstoyCaptain Hindsight: A project I helped maintain for a bit could have used an EAV (at least) db.
01:32tolstoyLots of "variant" data types: a thing, a subclass of a thing with extra attrs, etc, etc.
01:32dysfunthere is an EAV database for pg, just not an EAVT one
01:33tolstoyThey modeled it using different tables to add on extra bits, tied together with a reference table and custom OIDs, etc.
01:33tolstoySuper had to piece together as a DB in and of itself.
01:33dysfunoh yes, seen lots of those
01:33tolstoys/had/hard/
01:36dysfunwow, it's been ages since i checked out an svn repo
01:36dysfuni am of course using git-svn...
01:36tolstoyMy little toy project replaces entities, so I can't really test this history stuff.
01:36dysfunmaybe you should just wait for me to finish my project then? ;)
01:37tolstoyYep.
01:37dysfunwow. this sourceforge project has way more revisions than i thought it would
01:37dysfunit's a test library written in C that something i want uses
07:16pythysHi everyone. I'm having some difficulty understanding the REPL integration with projects. If I do something like "lein repl" inside a project, what is the difference from doing it outside the project?
07:18pythysDoes anything get loaded by default?
07:25dysfunif you've set a nems
07:25dysfunnamespace in your project.clj that will be loaded
07:26dysfunin :repl-options
07:26dysfunotherwise it's just all your dependencies will be on the classpath
07:47pythyshi dysfun, so when I open a certain file in a project, how can I experiment with it in the repl?
07:47pythysdo I have to (use thefile)?
07:49dysfuni prefer require, but basically yes
07:49dysfunand you'll need to quote thefile: 'thefile
07:59pythysdysfun: ok great
07:59pythysAnother question, what is the fastest way to understand where a function came from
08:00dysfunif you use :as in require, it should be pretty clear
08:00dysfunotherwise see if it's in clojure.core (doc clojure.core/name), otherwise look through the (:use) in the ns form
08:01dysfunyou can use the same trick with doc for each namespace
08:01pythysI see
08:01dysfunand if your repl supports autocomplete (like the lein one), you can hit tab to get completion and eliminate names quickly
08:01pythysand exploring packages? I see for example that (all-ns) does not help much
08:01dysfundefine 'package'
08:01pythys(dir package) lists them which is nice
08:02pythysoh I mean just namespaces I guess
08:02dysfunok
08:02dysfunwell tbh i mostly read the README.md or the docs
08:02pythysso (dir clojure.core)
08:02pythysdysfun: so you're always in some website checking the API docs? right?
08:02dysfunyes, the clojure cheatsheet
08:02dysfunhttp://clojure.org/api/cheatsheet
08:03dysfuni also keep a repl open so i can answer questions even when i'm not writing clojure :)
08:04pythysdysfun: ok, so the REPL is always relative to your current directory
08:04pythysand the way you explor files is with (use,,,) or (require,,,)
08:04dysfunwith lein, yes
08:04pythysand I assume you should always be in the lein project's root directory
08:04dysfunand i tend to require with :as and use the tab key in the repl to check them
08:05pythysok, good tip
08:05pythystab completion really helps
08:05dysfunyup
08:05pythysif you have 10 files calling each other or requiring each other somehow
08:05pythysand I just (require oneofthem)
08:06dysfunall of them will be required as you'd expect
08:06pythysdoes it automatically pull the rest in?
08:06pythysok I see
08:06dysfunhowever, caveat!
08:06pythysyeah, shoot?
08:06dysfunif you need to *reload* a namespace, you do e.g. (require '[foo.bar as fb] :reload)
08:06dysfunotherwise, it will silently do nothing
08:06pythyswhen should you reload?
08:06dysfun:reload will *not* reload all the dependent modules
08:06dysfun:reload-all will
08:07dysfunwhen you know that you have changed some code and want to play in the repl to see if it's fixed
08:07pythysI thought clojure is dynamic, why would I reload upon changing code?
08:07pythysdoes the repl cache in stuff?
08:08dysfunokay, this is for the situation where you are editing one of your lein project's clj files
08:08dysfunjust editing them in a text editor does not make them changed in the repl
08:08pythysso either reload or restart the repl
08:08dysfun:reload-all is more useful
08:08pythyserrrr, reload-all
08:09pythysokay, got it
08:09dysfunand realistically you may just want to use it by default, because then you can just find the last time you did it in the history
08:09dysfunbut some modules don't play entirely nicely, so caveat emptor :)
08:10dysfun(and you will know when you have hit one)
08:11pythysYeah, not too worried about that. I haven't been in a mind-bending journey in any new language the way I've been here. I'm staying in "exploration" mode for at least 3-4 months
08:12dysfunhah. i'm currently in the process of rewriting everything i wrote in my first 2 years
08:12dysfun(of clojure)
08:15pythysI see! clojure is definitely not short-term then
08:15dysfuni wouldn't say it's all bad code, but i like to improve old things periodically because i'm always learning
08:16dysfunand part of it has been necessitated by supporting clojurescript
08:18pythysdysfun: is it true that TDD is rendered unnecessary because of the nature of clojure programs and immutable state? that most tests are integration that grab more stuff from your system?
08:18dysfunno
08:19dysfunwriting tests is a good way of reminding yourself that human beings weren't mean to write code
08:19dysfunbecause you will find bugs in things that you're absolutely certain are correct
08:19pythysdysfun: I was talking specifically about TDD, red-green refactor?
08:19dysfuni don't buy into all that
08:20dysfunit's just a strategy you give to mediocre developers to enable them to do a passable job
08:22pythysok, so you test, but you don't have test code for every single line of production
08:22pythysthe 100% coverage rule or whatnot
08:23dysfuni didn't say i was against testing
08:23dysfunjust red-green-refactor and "write tests upfront"
08:23pythysI see
08:23dysfunit's alright for simple things, but i do a lot of research work and things evolve in a way that make it tedious
08:28Keksikehow can I check if something is a set or not?
08:28ridcully_,(doc set?)
08:28clojurebot"([x]); Returns true if x implements IPersistentSet"
08:29Keksikeno sorry, I meant map
08:29Keksike,(doc map?)
08:29clojurebot"([x]); Return true if x implements IPersistentMap"
08:29faxmodem^^
08:29Keksikethanks :)
08:29Keksike,(doc hash-map?)
08:29clojurebotExcuse me?
08:30faxmodem,(doc dwim)
08:30clojurebotexcusez-moi
10:30sdegutisWhat?
10:30clojurebotWhat is sampling a random integers betwen 2, 12 s..t. P(X = i) = (7-|i-7|)/36
10:30sdegutisClojure.spec!?
10:30sdegutisclojurebot: you're the most useless bot ever, stfu
10:30clojurebotI don't understand.
10:30sdegutisI vote we petition hiredman to turn off all clojurebot features except the REPL.
10:31ridcully_~sdegutis
10:31clojurebotNo entiendo
10:32hodappclojure.spec, man
10:35dysfunwhat are people using to develop webgl games in cljs?
10:36sdegutishttp://clojure.org/about/spec
10:36sdegutisThis looks handy!
10:42sdegutisdysfun: that wasn't in response to you btw
10:42sdegutissorry for temporal ambiguity
10:42dysfuni'll live
11:27sdegutisHello. What do you think of Clojure.spec ?
12:31tolstoyReminds me a of schema attributes in datomic.
12:31tolstoyI should really pay attention to time stamps.
13:06jsselmandysfun: I plan on using pixijs, but to be fair i haven't tried it yet
13:14dysfunheh, i used to drink beer with the guy behind pixijs
13:17jsselmandysfun: you could check this out https://github.com/alexkehayias/chocolatier
13:18jsselmanit has a giant WIP on the front page though
13:24dysfuninteresting
13:34jsselmandysfun: the author had a talk at clojure conj 2016 about it: https://www.youtube.com/watch?v=TW1ie0pIO_E
13:34dysfuncool, thanks
14:03irctchello there
15:36sdegutisIs there some way to mix comp with map without defining anonymous function? Like ((comp (map :order/id) :user/orders) users)
15:37dysfuner, what should that do?
15:38sdegutisThe same as #(map :order/id %)
15:38dysfun(partial map :order/id)
15:38sdegutisBlargh.