2013-02-23
| 00:10 | Raynes | alandipert: That's like a two hour drive. |
| 00:30 | alandipert | Raynes: yeahbutlike dude you're there :-) |
| 00:30 | Raynes | lol |
| 01:29 | Raynes | Man, antares_ thinks that Clojure documentation is ba |
| 01:29 | Raynes | d |
| 01:29 | Raynes | https://github.com/mozilla-servo/rust-http-client doesn't even have a readme. |
| 02:10 | frozenlock | Raynes: *troll* the code IS the documentation! |
| 02:10 | Raynes | It's also a bit of a buggy mess, sadly. |
| 02:10 | Raynes | Guess I'm setting Rust aside for now. |
| 02:11 | Raynes | Darn. I'm running out of fun languages to write refheap-related stuff in. |
| 02:11 | Raynes | I guess I could do OCaml just to appease technomancy, but meh. |
| 02:11 | frozenlock | Guile? |
| 02:12 | frozenlock | Hmmm.. I wonder if I could my webserver as a NAT traversal third party. |
| 02:13 | frozenlock | Dealing with customers network config is a pain. |
| 02:14 | Raynes | frozenlock: If I did Scheme it'd be racket |
| 02:15 | frozenlock | Yeah DrRacket seems to be a nice environment. |
| 02:16 | frozenlock | Especially with scribble that looks like a sane latex. |
| 02:17 | pppaul | wake |
| 02:18 | pppaul | sleep |
| 02:34 | MacCoaster | Can I forward declare something in another namespace? Trying to figure out how to be able to (load-file) something and refer to definitons found within the .clj i'm loading? |
| 03:36 | nonuby | in compojure I submit a search with several variables, i need to coerve the values of params from strings to bool for (checkboxes), jodas for datepickers, int for number of rooms etc. whats the best approach for this? |
| 04:31 | borkdude | yesterday I read about emacs muse… darn, another option to explore. has anyone used it and good experiences with it? |
| 05:42 | Pure_loulou | hello room :) do you know any macro tutorial with examples? |
| 06:39 | svedubois | I would like to write a simple 3d viewer (hide/unhide objects, shaders, import wavefront obj ...). I think http://www.jpct.net/ or http://jmonkeyengine.com/ are good options. Can you recommend me any 3d library? |
| 06:44 | borkdude | I'm strugling with this elisp |
| 06:44 | borkdude | https://www.refheap.com/paste/11716 |
| 06:45 | borkdude | define-counter gets called with the symbol counter, but I want to call it with the string represented by counter |
| 06:45 | borkdude | how do I do it... |
| 08:55 | meegofl | Hi, can anyone help me with why (union [1 2] [3 4]) - works and (difference [1 2] [2 3]) throws the following error? |
| 08:55 | meegofl | ClassCastException clojure.lang.PersistentVector cannot be cast to clojure.lang.IPersistentSet clojure.core/disj (core.clj:1419) |
| 08:56 | meegofl | i've applied (use 'clojure.set) as needed |
| 08:58 | danieroux | meegofl: Because [] creates vectors, not sets |
| 08:59 | meegofl | danieroux: Thanks, is there any way to apply union/intersection/difference to list of vecs? |
| 09:02 | danieroux | ,(set [1 2]) |
| 09:02 | clojurebot | #{1 2} |
| 09:02 | danieroux | meegofl: No, it operates on sets. But you can convert to sets |
| 09:03 | meegofl | danieroux: Thanks i saw the answer (set [1 2]) and it works! |
| 09:41 | meegofl | if i have a ref to set of refs to sets - any short way to deref all inner refs to a list? |
| 09:42 | meegofl | for ex: #<Ref@65fe28a7: #{#<Ref@2f26f304: #{2 4}> #<Ref@4eb0a518: #{2 3}> #<Ref@3f6ff2d9: #{1 2}>}> -> { {1 2} {2 3} {2 4} } |
| 10:48 | TimMc | (dosync (map deref @top-thing)) |
| 10:49 | TimMc | meegofl: ^ |
| 10:55 | sturner | Getting started with clojure here -- is there a good current guide for getting going with emacs, slime, nrepl etc? Counterclockwise seems OK but after watching some experts in emacs… I was amazed. |
| 10:58 | kryft | sturner: Where did you watch experts in emacs? |
| 11:01 | bbloom | sturner: http://clojure-doc.org/articles/content.html#emacs_for_clojure_development |
| 11:03 | sturner | I went to a clojure group.. and was amazed by the presenter(s) fluid movements in code/repl |
| 11:03 | gillies | i have redis.clj and core.clj. in core.clj, redis.clj is required as r. how do i get to a method like r/car/ping |
| 11:03 | gillies | where car is carmine required in redis.clj |
| 12:17 | clojure-newb | hey guys… I'm hitting some performance issues in my code using vectors, specifically 'mapv' in one area, and 'into []' in another… can anyone explain why this may be happening ? |
| 12:19 | mpenet | clojure-newb: put the code on refheap or some other pastebin |
| 12:20 | clojure-newb | mpenet: ok, I will put sample code up, thx |
| 12:35 | gfredericks | does subvec give you an efficiently conj-able vector? |
| 12:37 | tomoj | yes |
| 12:38 | gfredericks | I do not understand how that works. |
| 12:38 | tomoj | it just assoc's or conj's onto the original vector |
| 12:38 | tomoj | APersistentVector$SubVector |
| 12:38 | gfredericks | oh. |
| 12:38 | gfredericks | that makes crazy sense. |
| 12:39 | gfredericks | I knew it kept a reference to the original vector but it didn't occur to me it could update it |
| 12:49 | gillies | is there a way to tell if the current code is being evaluated by repl? |
| 12:49 | gillies | i want to have a message output if in repl |
| 12:54 | ivan | gillies: why not just write another function or add an argument? |
| 12:54 | gillies | ivan: i could do that, was just curious if its possible |
| 12:55 | ivan | throw an exception and check if the stack contains a "repl" but do not ever do this |
| 12:56 | gillies | heh ok |
| 12:56 | ivan | there might be a binding that is different in REPL too, I don't know |
| 12:56 | gillies | thnx |
| 12:56 | clojure-newb | mpenet: hi, I put together a samples of my problems with performance (vector related I think) : https://www.refheap.com/paste/11721 |
| 12:59 | tomoj | conkeror+refheap'ers: https://www.refheap.com/paste/f2f3afe8c98bc786983f899ad |
| 13:20 | clojure-newb | just wondering if transients… type hints or something else entirely would help me out with the performance problem I have tried to document at : https://www.refheap.com/paste/11721 |
| 13:24 | gfredericks | clojure-newb: that should get you a vector of lazy seqs; should be fast. |
| 13:25 | clojure-newb | gfredericks: 'mapv' ? |
| 13:25 | gfredericks | clojure-newb: do the reported times include printing the datastructure at the repl? |
| 13:26 | clojure-newb | gfredericks: no… I've seen ~ 1000 take ~ 25 seconds no printing |
| 13:26 | clojure-newb | and the 'into []' comparable |
| 13:26 | gfredericks | ,(time (into [] (repeat 10000 {}))) |
| 13:26 | clojurebot | "Elapsed time: 33.102355 msecs"\n[{} {} {} {} {} ...] |
| 13:26 | clojure-newb | more commonly I am dealing with ~ 40,000-50,000 items and it is unusable |
| 13:27 | gfredericks | are you obtaining the data via some sort of I/O? |
| 13:28 | clojure-newb | gfredericks: yes, I have already read it in via a 'tsv' file into a vector |
| 13:29 | gfredericks | fyi, into already uses transients |
| 13:29 | clojure-newb | gfredericks: oh |
| 13:30 | gfredericks | I don't have any ideas just looking at this. I'd try to bisect the difference between the code you're running and the code I plugged into clojurebot above |
| 13:33 | clojure-newb | gfredericks: you mean figure out what my data structure is like compared to your '(repeat x {})' ? |
| 13:34 | gfredericks | yeah; figure out the essential difference that makes yours slow and mine fast. Both the data and the transformation. |
| 13:34 | clojure-newb | gfredericks: I'll dig deeper, thx |
| 13:38 | holo | hu |
| 13:42 | clojure-newb | gfredericks: how do I get and debug/print the first item of a LazySeq ? |
| 13:42 | luxbock | how do I use Incanter from Emacs' nrepl? I installed Incanter with git clone and then downloaded all the dependencies with 'lein deps', and I can get it working if I run 'lein repl' from the folder to which Incanter was cloned to |
| 13:43 | luxbock | but if I try to run it from Emacs or a repl started from some other directory then (use '[incanter]) doesn't find it |
| 13:44 | holo | with a multiple arity function definition, i want to use a let after the function name and before declaring the arguments and expressions so that i can alias code that i need to use in multiple expressions. is this possible? i don't want to write a defn- for that alias |
| 13:45 | clojure-newb | I think my data structure is a sequence of maps, but it is lazy (probably why I was calling 'into [] my-data' |
| 13:45 | nightfly | holo: You can do the function definition inside of a let |
| 13:45 | holo | clojure-newb, first doesn't work? |
| 13:46 | holo | nightfly but the function input arguments have to come before, afaik. i want them to go after |
| 13:48 | holo | nightfly, here's a sample of what i want. obviously this doesn't work https://gist.github.com/ccfontes/5020842 |
| 13:48 | clojure-newb | holo: yes thx |
| 13:48 | gfredericks | holo: you can put the let around the defn |
| 13:49 | nightfly | https://gist.github.com/nightfly19/5020848 |
| 13:49 | holo | gfredericks, genious! thanks |
| 13:50 | holo | nightfly, thanks |
| 13:51 | gfredericks | nightfly is a faster genius |
| 13:55 | clojure-newb | gfredericks: I'm starting to suspect something else is going on here… if I shunt eval'ing the LazySeq to some other operations, the bottleneck is suddenly there… so 'into []' is probably not to blame… my map has elements retrieved from diatomic… including refs etc…. and is taking ~ 25 seconds for ~ 1000 items |
| 13:57 | clojure-newb | if I take 'first my-data' from my program…. move it into an editor and reapply it outside the program environment with your 'repeat 1000 x' example it is quick enough |
| 13:57 | gfredericks | datomic being slow maybe? |
| 13:58 | clojure-newb | gfredericks: I've already got the results out of datomic I thought… but wondering if refs are hanging on to some execution thread…. or I've not got results in the right way... |
| 13:58 | clojure-newb | think I will try getting my results out a different way,,, see how I do |
| 13:59 | clojure-newb | gfredericks: sorry for vagueness, thx for helping me think my way out of this deadend |
| 14:03 | gfredericks | sure |
| 14:11 | pepijndevos | clojurescript one is quite outdated, right? |
| 14:16 | gfredericks | probably |
| 14:19 | frozenlock | We should update it to add an outdated warning. |
| 14:21 | gfredericks | or upgrade it and rename it "clojurescript two" |
| 14:21 | frozenlock | Aren't we funny |
| 14:22 | gfredericks | soooo funny |
| 14:29 | gfredericks | oh man I have a (doseq [... :let [... (for [... :let [...]])]]) |
| 14:30 | pepijndevos | grm, this browserscript repl is not easy to get going :( |
| 14:31 | pepijndevos | I'm using cljsbuild, and a simple file that is supposed to connect tot he localhost |
| 14:31 | pepijndevos | the local repl is listening, but the browser is just spewing errors. |
| 14:32 | pepijndevos | http://localhost:9000/repl?xpc=%7B%22cn%22%3A%22Sz2qth0Pns%22%2C%22tp%22%3Anull%2C%22osh%22%3Anull%2C%22ppu%22%3A%22file%3A%2Frobots.txt%22%2C%22lpu%22%3A%22http%3A%2F%2Flocalhost%3A9000%2Frobots.txt%22%7DFailed to load resource: Could not connect to the server. |
| 14:32 | pepijndevos | Before that it gave some dom error, so I found out you had to wrap it in a callback when the dom is ready. This stuff is hard without jquery. |
| 14:41 | pepijndevos | In all examples it doesn't show this onload crap. I must be doing something terribly wrong |
| 14:44 | pepijndevos | I removed the onload and moved the script to the bottom of the page, which has the same effect as before: Failed to load resource: Could not connect to the server. |
| 14:48 | pepijndevos | "REPL will not work with mixed protocols" ahhhh, so I will have to set up a web server to serve this piece of html. |
| 14:49 | tomoj | what's the lamina operator for setting up siphon-like closing between two channels? |
| 14:50 | tomoj | well I guess (l/on-closed ch #(l/close ch')) works |
| 14:52 | tomoj | ..or rather (l/on-closed ch' #(l/close ch)) |
| 14:54 | actsasgeek | is anyone using emacs + evil and nrepl and re-bound the keys to something more like slimv's (which I think are swank's) bindings? |
| 15:08 | augustl | when I use logback + clojure.tools.logging, is there a way other than having "logback.xml" in classpath to configure it? |
| 15:22 | pepijndevos | doh, all this trouble of setting up a http server for my silly js file. ragequit |
| 15:30 | pepijndevos | The problem is clearly that it's just not listening on port 9000. curl also thinks it can't connect. |
| 15:31 | augustl | what's the easy mode way of writing clojure data/EDN to a file? |
| 15:31 | gfredericks | spit with pr-str? |
| 15:31 | pepijndevos | augustl: spit? |
| 15:31 | pepijndevos | sounds about right |
| 15:32 | rhg135 | Hello, how's a good way to structure, say, an irc bot? I'm quite new to functional programming, although I want to great at object oriented design lol. |
| 15:33 | rhg135 | S/want /wasn't / |
| 15:33 | augustl | gfredericks, pepijndevos thanks :) |
| 15:33 | pepijndevos | rhg135: maybe have a look at the source code for lazybot. |
| 15:33 | xeqi | rhg135: you could look at lazybot or clojurebot |
| 15:33 | antares_ | rhg135: take a look at https://github.com/hiredman/clojurebot, although it's not exactly the smallest or simplest project |
| 15:33 | rhg135 | It's a lesson in design for me |
| 15:37 | rhg135 | I still would like to know some design patterns |
| 15:38 | hcumberd` | rhg135: design patterns? |
| 15:38 | gfredericks | https://strange-loop-2012-notes.readthedocs.org/en/latest/monday/functional-design-patterns.html |
| 15:38 | gfredericks | rhg135: ^ |
| 15:39 | rhg135 | Thank you. |
| 15:39 | clojurebot | excusez-moi |
| 15:42 | rhg135 | Sorry to ask more, how do you manage mutable java objects, say java sockets, in a multiple threads? |
| 15:43 | michaelr525 | hello |
| 15:44 | bbloom | rhg135: you manage mutable java objects using java's normal concurrency primitives |
| 15:44 | bbloom | rhg135: but only if you have to. if you can help it, you should prefer to use immutable data structures & clojure's concurrency primitives |
| 15:45 | rhg135 | I'm not a Java programmer, can you elaborate. |
| 15:49 | gfredericks | using enlive like it's hiccup is a terrible idea :( |
| 15:52 | dimovich | hello ppl |
| 15:53 | dimovich | I'm trying to do this tutorial on core.logic: http://jrheard.tumblr.com/post/43575891007/explorations-in-clojures-core-logic |
| 15:53 | dimovich | but seems featurec function is missing from core.logic |
| 15:53 | dimovich | has it been replaced, or am I missing some steps? |
| 15:53 | gfredericks | dimovich: what version of core.logic are you using? |
| 15:53 | dimovich | 0.7.5 |
| 15:53 | gfredericks | I think that one's old |
| 15:58 | dimovich | gfredericks: indeed, latest dev version works fine |
| 15:58 | dimovich | thanks |
| 15:58 | gfredericks | yep |
| 15:59 | gfredericks | core.logic has had a _lot_ of work since the last stable release |
| 15:59 | gfredericks | every week dnolen invents a totally new kind of logic and makes it run faster on clojurescript than equivalent assembly code impls |
| 15:59 | gfredericks | then he has breakfast |
| 15:59 | ChongLi | hopefully that stuff will find its way into a new release :) |
| 16:14 | aib | I'm simply doing (:use [clojure.tools.logging]) - but debug and trace messages are not displayed by default. how can I enable them? do I have to do this? : http://www.paullegato.com/blog/setting-clojure-log-level/ |
| 16:22 | tmciver | Can someone explain to me how clojure.java.io/resource is supposed to work? When I run 'lein uberjar' on my web app, I can see the resource file of interest has been copied from my resource dir to the root of the jar, but c.j.io/resource does not seem to find it. Any ideas? |
| 16:23 | gfredericks | tmciver: for the file /resources/foo.txt, (resource "foo.txt") should find it |
| 16:25 | tmciver | In the interest of full disclosure this is a .clj file of a data structure that has been prn'd. It is originally in a /data directory and I've set :resources-path to "data". In any case the file seems to make it into the root of the jar. |
| 16:26 | tmciver | But (resource ...) does not seem to find it. |
| 16:26 | tmciver | I'm probably doing something studid. |
| 16:26 | tmciver | s/studid/stupid ! |
| 16:27 | gfredericks | I have no ideas. all that sounds reasonable. |
| 16:28 | tmciver | gfredericks: you let me down, man. |
| 16:28 | gfredericks | (dec gfredericks) |
| 16:28 | lazybot | You can't adjust your own karma. |
| 16:29 | tmciver | No! I won't hear of it. |
| 16:29 | tmciver | (inc gfredericks) |
| 16:29 | lazybot | ⇒ 15 |
| 16:29 | gfredericks | from one semiprime to another |
| 16:30 | jeremyheiler | tmciver, Are doing (resource "/foo.clj") or (resource "foo.clj")? |
| 16:30 | tmciver | jeremyheiler: the latter, I believe. |
| 16:30 | tmciver | Let me be sure. |
| 16:31 | jeremyheiler | The latter is the correct way. |
| 16:33 | zackzackzack | Any idea why a clojure process wouldn't be able to max out CPU on an aws box? |
| 16:33 | gfredericks | is it IO bound? |
| 16:33 | gfredericks | lots of random memory access? |
| 16:34 | zackzackzack | Probably IO bound. |
| 16:34 | zackzackzack | h/o |
| 16:35 | zackzackzack | https://github.com/zmaril/bumi/blob/master/src/bumi/core.clj#L79 |
| 16:35 | zackzackzack | Loading in a git repo into a graph database via pmap |
| 16:46 | Bronsa | gogit |
| 16:46 | Bronsa | but irc is not my firefox windows. |
| 16:46 | Bronsa | sorry. |
| 17:15 | modulus | So guys, a question about hiccup. on other template systems i can override common elements like a title from another view, in a sort of inheritance way. is this possible to do with hiccup and how? |
| 17:16 | bbloom | modulus: create a function |
| 17:16 | bbloom | modulus: pass it arguments, it's that simple |
| 17:16 | bbloom | (defhtml header [title] [:h1 title]) |
| 17:19 | modulus | hmm ok, i think i probably didn't convey what i mean very well. i'm using noir and there's this common view that comes by default with a defpartial |
| 17:20 | modulus | so this view has a set [:title "bla"] element. is there a clean awy to make it so that this title is overridden from another view which uses this, but only if there's a different title to set? or should i maybe instead of pass content pass some kind of map with potential overridings, or what's the sane way to do this? |
| 17:21 | frozenlock | I would go with functions and argument too on this one... |
| 17:21 | bbloom | modulus: yeah, you can pass a map of overrides and just merge in the defaults at some point |
| 17:21 | bbloom | either via (merge defaults overrides) |
| 17:21 | bbloom | or use (get overrides :title default) |
| 17:21 | frozenlock | (defn my-fn [x] (html [:title (or "blah" x)])) |
| 17:21 | frozenlock | (or x "blah") rather |
| 17:22 | bbloom | or do what frozenlock suggests if you want positional arguments |
| 17:22 | modulus | positional arguments are the evil, i don't want to remember every bit of the page that may be overridable |
| 17:22 | modulus | thanks, i think that's doable like you say, bbloom |
| 17:22 | bbloom | modulus: agreed, prefer an override map |
| 17:23 | bbloom | and even consider using namespaced keys! |
| 17:23 | modulus | what would (get overrides :title default) return? default if there's no :title on overrides? |
| 17:23 | bbloom | modulus: however, positional arguments are useful in many cases here. consider if you had exactly one argument that you *always* wanted to override. like say a header partial that always takes a title argument |
| 17:24 | bbloom | ,(let [overrides {:foo :overridden}] (get overrides :foo :default)) |
| 17:24 | clojurebot | :overridden |
| 17:24 | bbloom | ,(let [overrides {:foo :overridden}] (get overrides :bar :default)) |
| 17:24 | clojurebot | :default |
| 17:24 | bbloom | alternatively, call the keyword directly: |
| 17:24 | bbloom | ,(let [overrides {:foo :overridden}] (:bar overrides :default)) |
| 17:24 | clojurebot | :default |
| 17:24 | bbloom | ,(let [overrides {:foo :overridden}] (:foo overrides :default)) |
| 17:24 | clojurebot | :overridden |
| 17:25 | bbloom | "layouts" and fill-in-the-blank content_for templating are exceedingly complex |
| 17:25 | bbloom | you can, however, achieve very similar behavior using a dynamic variable: (def ^:dynamic regions {}) |
| 17:26 | bbloom | (defn content_for [region] (get regions region)) |
| 17:26 | modulus | that use of maps is pretty shiney, hadn't seen it before. |
| 17:26 | bbloom | (binding [regions (assoc regions :title "foo")] ...) |
| 17:27 | modulus | it's pity that there's no simple way to do hierarchical templating, that's a really good part in django imo |
| 17:28 | bbloom | modulus: no, it's a pity that python and ruby lack the necessary abstractions such that a hierarchical templating system must be created |
| 17:28 | bbloom | :-P |
| 17:28 | bbloom | you can trivially implement everything django's templating does with maps, dynamic variables, function calls, macros, etc |
| 17:28 | bbloom | it's so simple that hiccup et al don't provide tools to do that |
| 17:29 | bbloom | b/c it would be a waste |
| 17:29 | modulus | oh, i agree; but i'd have expected to have been implemented already |
| 17:29 | bbloom | it *is* implemented already. in clojure |
| 17:29 | bbloom | clojure itself, i mean |
| 17:29 | bbloom | clojure has a powerful namespace system with flexible scoping, binding, resolution, etc |
| 17:29 | modulus | let clojure be, and there was light ;-) i agree the language is well suited to adding this, but it's still something one must do on top. |
| 17:30 | modulus | anyway this stuff with maps is really neat, i think i'll probably do something like that. |
| 17:31 | bbloom | modulus: not really.... templates are just functions tuned for a different syntax. there's nothing to build "on top" |
| 17:31 | bbloom | if you find yourself writing a complex templating system, you're likely recreating a feature clojure already has |
| 17:33 | modulus | well, imagine i have v1 that has title "my title". on view v2, i want to add ": my user page" and view v3 which calls v2, i want to add ": profile". while i'm sure i can do this with care, it seems the sort of place a DSL would do considerable good, no? |
| 17:34 | modulus | so v3 would produce [:title "my title: my user page: profile"] |
| 17:35 | bbloom | modulus: hiccup will stitch together seqs of neighboring strings and will omit nils, so just do (defhtml [title-parts] [:title title-parts]) |
| 17:35 | bbloom | and you can abstract over it: |
| 17:35 | bbloom | er that needed a name: |
| 17:35 | bbloom | (defhtml v0 [title-parts] [:title title-parts]) |
| 17:36 | bbloom | (defhtml v1 [title-parts] (v0 (cons "my title" title-parts))) |
| 17:36 | bbloom | or whatever |
| 17:36 | modulus | right, i will look into this, so far i have only see html produced with (html5) function |
| 17:56 | tcsc | what's the rationale for clojure having separate types for symbols and keywords? |
| 18:00 | katox | hi, I've been trying to up some clojurescript running |
| 18:00 | katox | for starter I tried to use M0003 of clojurescriptone |
| 18:00 | katox | the dev-server is up, the app is alive but I have trouble running repls |
| 18:01 | bbloom | tcsc: there are several |
| 18:01 | bbloom | tcsc: keywords are just symbols that are guarented to resolve to themselves |
| 18:01 | katox | nrepl is fine, but cljs-repl writes "ClojureScript:cljs.user> java.io.IOException: Write end dead" indefinitely |
| 18:01 | bbloom | tcsc: that's convenient for a lot of use cases, but it also means that keywords can be interned for fast equality comparisons using `identical? instead of using `= |
| 18:02 | tcsc | bbloom: thats not that different than quoting them though, is it? |
| 18:02 | bbloom | tcsc: it is *subtly* different |
| 18:02 | bbloom | quoting it is what you'd do in common lisp, generally |
| 18:03 | bbloom | however, it's like quoting it AND also defining it to itself: |
| 18:03 | bbloom | (def foo 'foo) ....... 'foo |
| 18:03 | bbloom | this way if you ever resolve 'foo, you get 'foo |
| 18:03 | bbloom | but since it's a different type, you can skip the resolve-to-self step and just not do anything |
| 18:03 | katox | something in the settings or should I disregard clojurescriptone project for now and start elsewhere? (and where if so?) |
| 18:04 | bbloom | additionally, symbols have metadata, but keywords do not, since keywords with a particular qualified name are only ever instantiated once |
| 18:04 | bbloom | tcsc: does that all make sense? |
| 18:05 | tcsc | yes, but i guess i'm fuzzy on the why of it |
| 18:05 | bbloom | ,(= 'foo 'foo) |
| 18:05 | clojurebot | true |
| 18:05 | bbloom | ,(= :foo :foo) |
| 18:05 | clojurebot | true |
| 18:05 | bbloom | ,(identical? 'foo 'foo) |
| 18:05 | clojurebot | false |
| 18:05 | bbloom | ,(identical? :foo :foo) |
| 18:05 | clojurebot | true |
| 18:05 | tcsc | oh, that's surprising |
| 18:05 | bbloom | it's not surprising when you consider: |
| 18:05 | bbloom | ,(meta ^:foo 'bar) |
| 18:05 | clojurebot | nil |
| 18:05 | bbloom | er rather: |
| 18:06 | bbloom | ,(meta (with-meta 'bar {:foo true})) |
| 18:06 | clojurebot | {:foo true} |
| 18:06 | bbloom | ,(= (with-meta 'foo {:x true}) (with-meta 'foo {:x false})) |
| 18:06 | clojurebot | true |
| 18:06 | bbloom | ,(= (meta (with-meta 'foo {:x true})) (meta (with-meta 'foo {:x false}))) |
| 18:06 | clojurebot | false |
| 18:07 | bbloom | however: |
| 18:07 | bbloom | ,(istance? clojure.lang.IMeta :foo) |
| 18:07 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: istance? in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 18:07 | bbloom | ,(instance? clojure.lang.IMeta :foo) |
| 18:07 | clojurebot | false |
| 18:07 | bbloom | compared to: |
| 18:07 | bbloom | ,(instance? clojure.lang.IMeta 'foo) |
| 18:07 | clojurebot | true |
| 18:07 | bbloom | that should cover all the important differences :-) |
| 18:08 | bbloom | Raynes: someday soon, there will be a decent GUI toolkit library... i promise :-) |
| 18:08 | Raynes | bbloom: Seesaw is very nice though. |
| 18:09 | Raynes | I just don't know how to use it is all. |
| 18:09 | bbloom | s/soon/in the medium to distant future/ |
| 18:09 | Raynes | I'm learning. |
| 18:17 | rhg135 | Hello again, i'm trying to composes two functions with comp, but the first might return nil, Is there is a simpler way to not throw an exception similar to -?> or haskell's >>= |
| 18:18 | bbloom | (doc fnil) |
| 18:18 | clojurebot | "([f x] [f x y] [f x y z]); Takes a function f, and returns a function that calls f, replacing a nil first argument to f with the supplied value x. Higher arity versions can replace arguments in the second and third positions (y, z). Note that the function f can take any number of arguments, not just the one(s) being nil-patched." |
| 18:19 | bbloom | probably doesn't help you tho |
| 18:19 | bbloom | maybe it does |
| 18:19 | bbloom | you can probably define a comp-maybe pretty easily |
| 18:20 | rhg135 | No, I'm looking for -?> composition |
| 18:20 | bbloom | do you want a macro or a function? |
| 18:20 | bbloom | presumably a function |
| 18:20 | rhg135 | Okay I could write a macro. |
| 18:21 | bbloom | well -?> is already a "maybe" macro |
| 18:22 | rhg135 | Yeah just thought they're might be a composition function. |
| 18:22 | bbloom | rhg135: not one in core, but it's really easy to make one |
| 18:23 | rhg135 | I'll write one based on -?> |
| 18:23 | bbloom | (defn propegate-nil [f] (fn [x] (when-not (nil? x) (f x))) |
| 18:24 | bbloom | (defn comp-maybe [f g] ((propegate-nil f) (g f))) |
| 18:24 | bbloom | and you can make a variadic version of comp-maybe quite trivially |
| 18:24 | bbloom | should do the trick |
| 18:25 | bbloom | although, most of the operations that normally require maybe-style logic, tend to do it automatically... like lookups: |
| 18:25 | bbloom | ,(-> {} :foo :bar :baz) |
| 18:25 | clojurebot | nil |
| 19:00 | shriphani | hi everyone. I am new to clojure, lein and the jvm in general. I am trying to find out what the best way to search for repos is. Is there something like python's pip or easy_install for clojure ? |
| 19:01 | bbloom | shriphani: https://clojars.org/ |
| 19:01 | bbloom | shriphani: and http://www.clojuresphere.com/ |
| 19:01 | bbloom | probably some others |
| 19:02 | bbloom | see also: http://clojure-doc.org/ for ecosystem & tools info |
| 19:04 | shriphani | bbloom: so those sites don't do java .jars I am guessing ? |
| 19:05 | bbloom | clojure libs are just jars |
| 19:06 | shriphani | bbloom: but if there's a java jar you add it to your lib directory yourself ? |
| 19:07 | bbloom | you just add to your project.clj a dependency and, if necessary, a repository |
| 19:07 | bbloom | see the lein docs |
| 19:07 | bbloom | wiki on github |
| 19:10 | rhg135 | quick question again, is there an easy way to namespace keywords? Say I have bot.message required as msg, is there something like :msg/msg or do I have to type it out each time as :bot.message/msg? |
| 19:10 | bbloom | rhg135: if you have an "alias" in your 'ns form, then you can use :: like this: |
| 19:10 | bbloom | ,::foo |
| 19:10 | clojurebot | :sandbox/foo |
| 19:11 | rhg135 | ? |
| 19:11 | bbloom | if you had (ns (:require [some.long.name :as short])) |
| 19:11 | bbloom | you can do ::short/foo |
| 19:11 | bbloom | and that is the same as :some.long.name/foo |
| 19:12 | rhg135 | oh, use :: not : Thank you. i'm such a noob sometimes |
| 19:12 | bbloom | rhg135: nah, i didn't know about how :: worked for MONTHS |
| 19:12 | bbloom | rhg135: dnolen had to set me straight :- |
| 19:12 | bbloom | )) |
| 19:13 | rhg135 | yeah I'm writing an IRC message parsing code for my IRC bot |
| 19:17 | gfredericks | can somebody who understands encodings better than me explain what is wrong with http://upload.gfredericks.com/apostrophe.html ? |
| 19:17 | gfredericks | it displays incorrectly in the browser |
| 19:17 | gfredericks | despite the header having utf8 |
| 19:18 | nightfly | it displays fine for me |
| 19:18 | gfredericks | O_O |
| 19:18 | gfredericks | consarnit. |
| 19:18 | gfredericks | what browser? |
| 19:19 | gfredericks | the file displays fine in emacs for me, but in chrome it's garbled |
| 19:19 | nightfly | Chrome on linux |
| 19:30 | gfredericks | hexl-mode and `od -x` disagree about the contents of the file !?! |
| 19:32 | gfredericks | oh they have different endianness :( |
| 20:00 | ryanf | is there good idiom in clojure for saying, "if this thing is a seq, do nothing, but if it's not a seq, make it into a seq of one element"? |
| 20:00 | ryanf | +a |
| 20:00 | ryanf | actually maybe wanting something like that is a sign of disordered thinking :) |
| 20:24 | yedi_ | what non blocking database solutions exist in clojure? |
| 20:28 | gfredericks | ryanf: yeah it's a bit weird |
| 20:28 | gfredericks | ryanf: easy to implement though |
| 20:32 | arrdem | so after looking at some of my code I realized that I was faking a type system by performing implicitly typed operations on maps which were equivalent to an object from any other language. Is this expected and normal? 'cause I consider it fairly strange while workable. |
| 20:32 | gfredericks | what are implicitly typed operations? |
| 20:33 | arrdem | (foo x) where x is expected to be a map with some keys of types due to stuff like (update-in x [:foo :bar] assoc :x 1) |
| 20:34 | arrdem | I'm assuming that the argument X is a map following the form of my pseudo-type |
| 20:38 | shriphani | Hello everyone. I am possibly not thinking right here. Clojure complains that it can't see warc-file-stats: https://www.refheap.com/paste/11724 |
| 20:38 | TimMc | arrdem: Quite common. |
| 20:41 | arrdem | TimMc: why is this the common pattern tho? seperation of transformations from state? |
| 20:41 | shriphani | I can do def foo(): foo1(); \n\n def foo1() in Python. Is this not allowed in clojure ? |
| 20:42 | arrdem | shriphani: your syntax is all wrong but something like that is possible. |
| 20:42 | arrdem | shriphani: (declare foo foo1) (defn foo [] (foo1)) (defn foo1 [] .... ) |
| 20:43 | shriphani | oh I need the declare at the top ? |
| 20:44 | arrdem | shriphani: so declare is weird. |
| 20:44 | arrdem | ordinarily you will never (declare) anything if avoidable |
| 20:44 | arrdem | however you can only use symbols which have been defined or declared |
| 20:44 | TimMc | arrdem: I'd like to see a helper fn that makes pre-/post-conditions easy to write for testing pseudo-types. |
| 20:45 | arrdem | so you can ether (defn foo1 [] ... ) (defn foo [] ... (foo1)) which is common |
| 20:45 | shriphani | arrdem: so you put main at the bottom of the file ? |
| 20:45 | arrdem | usuallu |
| 20:45 | arrdem | *usually |
| 20:45 | arrdem | the hope is that you read from top to bottom building context |
| 20:45 | TimMc | arrdem: As for why, it's more dynamic. Formal types are restrictive, even if they do have some big benefits. |
| 20:46 | arrdem | TimMc: so would I... I have a blog post on its third or fourth draft revision about this |
| 20:46 | arrdem | and just wanted to test the waters here as it were |
| 20:46 | TimMc | arrdem: I'd like to be able to say "This is an object (or pseudotype) that *must* have such and such keys and *may* have such and such keys." |
| 20:46 | arrdem | TimMc: sold./ |
| 20:47 | TimMc | I think the real value (besides catching the occasional bug) would be the documentation possibilities. :-) |
| 20:48 | arrdem | or more "the code is the documentation" and here's the specification for the arguments |
| 20:48 | arrdem | herm.. (defpseudotype)? |
| 20:48 | arrdem | ew. |
| 20:49 | TimMc | (def ( |
| 20:51 | TimMc | (def a-foo (soft-type :needs #{a b c} :allows #{d e})) |
| 20:52 | TimMc | and then {:pre [(a-foo x)]} or maybe a more explicit predicate |
| 20:53 | TimMc | I haven't looked into the opt-in typing work that some folks have done with Clojure, so my suggestions are uninformed by prior work. |
| 20:53 | arrdem | (def foo (typedfn [a a-foo b b-bar] (or (:foo a) (:bar b)))) |
| 20:53 | TimMc | And that would expand to have the appropriate pre-/post-conditions? |
| 20:54 | arrdem | that'd just give you preconditions on the type(s) of the arguments using let-ish semantics |
| 20:54 | arrdem | [name, predicate]+ |
| 20:54 | arrdem | postconditions... |
| 20:54 | arrdem | herumph |
| 20:57 | TimMc | You'd want a form that expanded to defn, by the way -- defn is unfortunately not simply a convenience macro. The Clojure compiler uses it to arrange some optimizations. |
| 20:57 | gillies | i have a vector of maps like [{:foo "bar" :biz "baz"} {:foo "sds" :biz "sdasdasd"}]. How do i map over the vector and return the values of whos key is :foo? |
| 20:57 | TimMc | gillies: for |
| 20:57 | gillies | TimMc: thanks |
| 20:58 | TimMc | gillies: Wait, I misunderstood. |
| 20:58 | TimMc | The output here would be ("bar" "sds")? Just (map :foo ...) |
| 20:58 | gillies | TimMc: the keys are strings |
| 20:59 | gillies | i guess i could convert them to keywords |
| 20:59 | arrdem | TimMc: yeah understood, I just hated the name (deftypedfn <identical usage> ) so I tried to do the (def) thang |
| 20:59 | TimMc | gillies: I don't understand. What would the output be for the input you listed? |
| 20:59 | gillies | TimMc: i made a typo in my example |
| 20:59 | gillies | keys are "foo" not :foo my bad |
| 21:00 | gillies | output is what you said it was |
| 21:00 | gillies | but mapping over string map keys is evading me |
| 21:01 | TimMc | You could do it the boring way... (map #(get % "foo") ...) |
| 21:01 | TimMc | ...or the fun way, with juxt. |
| 21:02 | TimMc | &(let [my-maps [{:foo "bar" :biz "baz"} {:foo "sds" :biz "sdasdasd"}]] ((apply juxt my-maps) :foo)) |
| 21:02 | lazybot | ⇒ ["bar" "sds"] |
| 21:02 | TimMc | (I used :foo instead of "foo", but it would still work.) |
| 21:03 | gillies | i ended up using (map :foo (keywordize-keys the-hash-map)) |
| 21:04 | gillies | what &(...) syntax? |
| 21:04 | gillies | not familiar with that |
| 21:05 | arrdem | gillies: it's so that the #clojure bots will eval the code |
| 21:05 | arrdem | gillies: &(println "Lazybot here") |
| 21:05 | arrdem | &(println "Lazybot here") |
| 21:05 | lazybot | ⇒ Lazybot here nil |
| 21:05 | arrdem | ,(println "Clojurebot here") |
| 21:05 | clojurebot | Clojurebot here\n |
| 21:06 | gillies | &(doc map) |
| 21:06 | lazybot | ⇒ "([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhaust... https://www.refheap.com/paste/11725 |
| 21:06 | gillies | heh |
| 21:06 | gillies | never seen juxt before |
| 21:07 | gillies | oh juxtaposition is an actual functional term |
| 21:09 | TimMc | ~juxt |
| 21:09 | clojurebot | juxt is the bestest option though if it doesn't weird you out |
| 21:10 | arrdem | ,(doc juxt) |
| 21:10 | clojurebot | "([f] [f g] [f g h] [f g h & fs]); Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, and returns a vector containing the result of applying each fn to the args (left-to-right). ((juxt a b c) x) => [(a x) (b x) (c x)]" |
| 21:11 | arrdem | oh baller |
| 22:21 | ryanf | any obvious suggestions for making this code more idiomatic? https://gist.github.com/rf-/7bdbc47e54ab17188513 |
| 22:21 | ryanf | it feels super procedural :( |
| 22:21 | ryanf | it's probably partly because the stuff I've implemented so far is just state manipulation |
| 22:25 | gfredericks | ryanf: curious why players is a ref rather than an atom |
| 22:25 | ryanf | hmm |
| 22:26 | arrdem | ,(doc fmap) |
| 22:26 | clojurebot | Cool story bro. |
| 22:26 | arrdem | wat |
| 22:26 | ryanf | well earlier I was recording the last message (because I will need to do stuff with it later) |
| 22:26 | ryanf | so I kind of felt like it was a good idea to make the player list and last message both be refs and update them in a transaction |
| 22:26 | ryanf | but that turned out to be pretty awkward with the message-sending anyway, so I just dropped it for now |
| 22:27 | arrdem | ,(doc map) |
| 22:27 | clojurebot | "([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & ...]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments." |
| 22:30 | arrdem | ,(doc comp) |
| 22:30 | clojurebot | "([] [f] [f g] [f g h] [f1 f2 f3 & fs]); Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc." |
| 22:30 | ryanf | I guess maybe a more functional way to do this would be to build up a list of pending messages and send them after returning from the message handler? |
| 22:30 | ryanf | maybe that's overkill |
| 22:30 | ryanf | I'm just flailing around really :) |
| 22:32 | arrdem | TimMc: predicates on :allows ? or just existance for a draft... |
| 22:38 | arrdem | ,(doc and) |
| 22:38 | clojurebot | "([] [x] [x & next]); Evaluates exprs one at a time, from left to right. If a form returns logical false (nil or false), and returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last expr. (and) returns true." |
| 22:39 | arrdem | does clojure protect against recursive macros? |
| 22:39 | gfredericks | protect against? |
| 22:40 | arrdem | ,(defmacro a [] `(b)) (defmacro b [] `(a)) (b) |
| 22:40 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 22:40 | gfredericks | what's wrong with that? |
| 22:40 | arrdem | depending on how clojure does macro expansion it could mutually recur ad infinitum |
| 22:41 | gfredericks | it will |
| 22:41 | arrdem | good! |
| 22:41 | arrdem | what I'm writing will work! |
| 22:41 | gfredericks | :) |
| 22:42 | arrdem | X-P the time I failed at writing a recursive OR in C macros because it's not a real macro system |
| 22:46 | TimMc | arrdem: Just existence of a predetermined set of keys. |
| 22:47 | TimMc | arrdem: There's already an infinite macroexpand you can do with core, due to a bug. |
| 22:48 | arrdem | TimMc: I just found a really cute syntax which'll let you specify predicate tests (optinally) for the keys |
| 22:48 | arrdem | except for the :needs and :allows keys |
| 22:54 | TimMc | &(macroexpand '(->> a b (->> c d))) |
| 22:54 | lazybot | java.lang.StackOverflowError |
| 22:55 | Raynes | Oh my. |
| 22:55 | Raynes | That's cool. |
| 22:55 | Raynes | ,(macroexpand '(->> a b (->> c d))) |
| 22:55 | clojurebot | #<StackOverflowError java.lang.StackOverflowError> |
| 22:55 | TimMc | It's a 4-cycle loop. |
| 22:55 | gfredericks | that's much nicer than the original one you found |
| 22:56 | TimMc | yeah |
| 22:56 | gfredericks | doesn't look nearly as contrived |
| 22:56 | TimMc | It's just a simplification of that one. |
| 22:56 | gfredericks | well I guess nested ->> shouldn't ever be necessary like that |
| 22:56 | gfredericks | so still contrived |
| 22:57 | Raynes | TimMc: Oh man, I just realized how that works. I love you Tim. |
| 22:59 | TimMc | Raynes: gfredericks submitted a patch that fixes it. |
| 22:59 | TimMc | It's *really* not supposed to do that. |
| 22:59 | gfredericks | be careful with your recursive macros kids |
| 23:00 | TimMc | CLJ-1121 if anyone cares. |
| 23:00 | arrdem | very cute tho |
| 23:02 | TimMc | Raynes: The amazing thing is that I stumbled onto it by accident, IIRC. |
| 23:02 | preyalone | I'm teaching myself Clojure... FizzBuzz isn't printing correctly :( https://gist.github.com/mcandre/5022526 |
| 23:02 | TimMc | I was doing some horribly nasty things in the name of swearjure. |
| 23:03 | arrdem | ,(doc ident |
| 23:03 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 23:03 | arrdem | ,(doc ident) |
| 23:03 | clojurebot | Gabh mo leithscéal? |
| 23:04 | arrdem | ,(map identity {:foo 1 :bar 2}) |
| 23:04 | clojurebot | ([:foo 1] [:bar 2]) |
| 23:05 | gfredericks | preyalone: it's not printing at all, correct? |
| 23:05 | muhoo | ,(map type {:foo 1 :bar 2}) |
| 23:05 | clojurebot | (clojure.lang.MapEntry clojure.lang.MapEntry) |
| 23:06 | muhoo | interesting. they look like vectors, but they ain't. |
| 23:06 | gfredericks | like how seqs look like lists |
| 23:06 | ivan | gfredericks: it's printing the nils from the map output as well as the right stuff |
| 23:06 | gfredericks | and finger trees look like fingers |
| 23:07 | gfredericks | ivan: oh is that a `lein run` thing? |
| 23:07 | ivan | nope |
| 23:07 | preyalone | gfredericks: correct |
| 23:07 | ivan | huh |
| 23:08 | gfredericks | ivan: I would expect the return value from main to be ignored |
| 23:08 | ivan | yeah, I'm a dummy, trying this in my nREPL |
| 23:08 | gfredericks | preyalone: you should look at doseq instead of map; laziness is thwarting you here |
| 23:08 | preyalone | gfredericks: I thought so! Thanks! |
| 23:11 | preyalone | gfredericks: If I want to continue using lazy (range), should I be using something like (take) / (drop) ? |
| 23:12 | gfredericks | no your use of range is fine |
| 23:12 | gfredericks | the problem is using map when the function has side effects |
| 23:12 | gfredericks | you can use doseq with range |
| 23:13 | arrdem | what was the quote-dequote trick for symbols in macros? |
| 23:13 | arrdem | ,`~foo |
| 23:13 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 23:14 | preyalone | gfredericks: Wow, I feel like I'm doing mapM_ from Haskell. |
| 23:15 | gfredericks | arrdem: ##`~'foo |
| 23:15 | lazybot | ⇒ foo |
| 23:15 | gfredericks | preyalone: maybe you are; I wish I could remember :( |
| 23:15 | preyalone | Thanks, it works now! |
| 23:16 | preyalone | gfredericks: I <3 Haskell, so I find Clojure interesting for its selective laziness. |
| 23:16 | preyalone | Does Clojure have anything like Haskell GADTs? |
| 23:19 | preyalone | Why do Clojure function arguments use vectors rather than lists? |
| 23:20 | arrdem | gfredericks: isn't ~'foo equivalent? |
| 23:20 | Sgeo | vectors in syntax have the connotation of none of the elements being in a "special" position |
| 23:20 | arrdem | ,(= ~'foo ##`~'foo) |
| 23:20 | lazybot | ⇒ foo |
| 23:20 | clojurebot | #<RuntimeException java.lang.RuntimeException: Reader tag must be a symbol> |
| 23:21 | TimMc | arrdem: ## is a lazybot inline eval trigger |
| 23:21 | muhoo | i'm still puzzling out the difference between ~'foo and '~foo |
| 23:21 | gfredericks | ,~'foo |
| 23:21 | clojurebot | #<IllegalStateException java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.core/unquote> |
| 23:22 | Sgeo | preyalone, whereas, in function/macro application, the first element is "special", it names the function or macro |
| 23:22 | gfredericks | muhoo: '~foo is going te evaluate foo |
| 23:22 | Sgeo | Well, not "names" in the case of functions, Clojure does have first-class functions |
| 23:23 | gfredericks | preyalone: no GADTs, I don't think they make as much sense with dynamic types |
| 23:23 | preyalone | Thanks |
| 23:23 | arrdem | TimMc: Ah thanks. |
| 23:23 | muhoo | gfredericks: but ##(= '~foo foo) |
| 23:23 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: foo in this context |
| 23:23 | muhoo | fine |
| 23:23 | preyalone | Are Clojure trees specified with ((a . b) . (c . d)) as in Common Lisp? |
| 23:23 | muhoo | gfredericks: but ##(let [foo "bar"] (= '~foo foo)) |
| 23:23 | lazybot | ⇒ false |
| 23:23 | arrdem | I don't think we even have cons cells.. |
| 23:23 | Sgeo | preyalone, I know some Haskell and am trying to get back into it |
| 23:24 | arrdem | ,(a . b) |
| 23:24 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 23:24 | Sgeo | (And have ranted about Haskell stuff in here in the past) |
| 23:24 | arrdem | preyalone: evidently not |
| 23:24 | Sgeo | arrdem, failure of that syntax only implies that the reader doesn't recognize that syntax, not that lists aren't made of cons cells |
| 23:24 | arrdem | [['a 'b] ['c 'd]] |
| 23:24 | preyalone | arrdem: If no cons, how does a Clojurer prepend an element to a list? |
| 23:24 | Sgeo | ,(cons 1 (list 2 3 4)) |
| 23:24 | clojurebot | (1 2 3 4) |
| 23:25 | Sgeo | But conj is preferred, it will append to the "fast" place to append for the data structure |
| 23:25 | Sgeo | ,(conj (list 1 2 3) 4) |
| 23:25 | clojurebot | (4 1 2 3) |
| 23:25 | Sgeo | ,(conj [1 2 3] 4) |
| 23:25 | clojurebot | [1 2 3 4] |
| 23:25 | TimMc | preyalone: We have a fn called "cons", it's just that seqs and lists aren't always made of cons cells. |
| 23:26 | TimMc | preyalone: What we *don't* have is pairs -- the cdr is always nil or a seq. |
| 23:26 | Sgeo | ,(cons 1 2) |
| 23:26 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long> |
| 23:27 | preyalone | ,(head [1 2 3]) |
| 23:27 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: head in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 23:27 | arrdem | TimMc: is there any value in a (to-<pseudotype>) which just selects those keys? |
| 23:27 | Sgeo | ,([1 2 3] 0) |
| 23:27 | clojurebot | 1 |
| 23:27 | preyalone | No (head) / (tail) either? |
| 23:27 | arrdem | (first) and (last) |
| 23:27 | muhoo | preyalone: ##(first [1 2 3]) |
| 23:27 | Sgeo | Although I think there is a function for head |
| 23:27 | lazybot | ⇒ 1 |
| 23:27 | Sgeo | Oh right |
| 23:27 | TimMc | arrdem: I can't think of any. |
| 23:27 | Sgeo | ,(rest [1 2 3]) |
| 23:27 | clojurebot | (2 3) |
| 23:28 | preyalone | (first) and (rest) are much appreciated. |
| 23:28 | TimMc | arrdem: Such transformations belong in application logic, not in pseudo-type-checking. |
| 23:28 | muhoo | IIRC, first and rest are the basic building blocks of the whole seq abstraction |
| 23:28 | Sgeo | preyalone, do keep in mind that Clojure doesn't do TCO. For self-recursion, use recur/loop if it's a tail-call recursion |
| 23:29 | arrdem | TimMc: I agree, I'm just saying that the pseudotypedef could generate such transforming code for the application to use |
| 23:29 | Raynes | Man. |
| 23:29 | Raynes | Trying to debug a Haskell program while slightly intoxicated. |
| 23:30 | arrdem | Raynes: you sir are a brave man and I wish you well |
| 23:30 | muhoo | Raynes: hey, you're not of drinking age in california :-) |
| 23:30 | Sgeo | Raynes, hey, I recall you using Aeson, have you ever used the Template Haskell stuff for it? |
| 23:30 | Raynes | muhoo: This is a fact. |
| 23:30 | TimMc | Perhaps you are insufficiently intoxicated. |
| 23:30 | TimMc | muhoo: Maybe it's not alcohol. |
| 23:30 | Raynes | Sgeo: Nope, Chris Done made me decide against that. |
| 23:30 | preyalone | Sgeo: As, replace the literal recursive call (my-func-again arg arg arg) with (recur my-func-again arg arg arg) ? |
| 23:30 | Raynes | TimMc, muhoo: Pretty sure drugs are illegal at any age. |
| 23:30 | preyalone | Raynes: Gist it and I'll take a look |
| 23:30 | Sgeo | preyalone, don't mention my-func-again in the recur usage, but yes |
| 23:30 | TimMc | Raynes: Chocolate. |
| 23:31 | Raynes | preyalone: It's on Github. https://github.com/Raynes/refh |
| 23:31 | muhoo | Raynes: not in california :-) |
| 23:31 | TimMc | Medical marijuana, perhaps. |
| 23:31 | Sgeo | Raynes, hmm, what was wrong with it? |
| 23:31 | muhoo | especially the farther north you go. |
| 23:31 | Sgeo | As in, what did Chris Done say against it? |
| 23:31 | Raynes | Sgeo: I don't remember. |
| 23:31 | TimMc | Also, there are all sorts of exemptions with alcohol, such as serving a drink with dinner. (Varies by state.) |
| 23:32 | muhoo | i lived in texas for a while. dry counties were a trip. |
| 23:32 | preyalone | Raynes: I'd remove the prompt information in README. Just "$" is much clearer to people. |
| 23:32 | Raynes | Sure. That was a copypasta. |
| 23:33 | Sgeo | Raynes, I tried GHC under WINE once, seemed to work |
| 23:33 | Raynes | Anyways, cat foo.clj | refh is not working. |
| 23:33 | preyalone | Raynes: As to Windows binaries, have you considered running Windows in a VM? |
| 23:33 | Raynes | I'm figuring out why. |
| 23:33 | Raynes | I have a Windows partition now, just haven't bothered to compile yet. |
| 23:33 | Raynes | Also, don't give me the answer. |
| 23:33 | Raynes | I need this. :p |
| 23:33 | muhoo | you need to debug windows? |
| 23:34 | Raynes | Nope. |
| 23:34 | gfredericks | muhoo: did you figure out the ~' thing? I was away for a bit |
| 23:35 | Sgeo | Within `, ~'foo takes 'foo and pastes it in directly, so to speak. Whereas a bare symbol may get a namespace attached to it |
| 23:35 | muhoo | gfredericks: naw, i probably need to re-read a bunch of stuff. this is one where i should sit down with the book i am reading and the ones i have already read, and my notes, and try to reconcile it all. |
| 23:35 | Sgeo | ,`(1 ~(+ 2 3) 4) |
| 23:35 | clojurebot | (1 5 4) |
| 23:35 | Sgeo | ,`(1 ~'foo 4) |
| 23:35 | clojurebot | (1 foo 4) |
| 23:35 | Raynes | preyalone: Found the issue. Thanks for the help. |
| 23:36 | Sgeo | preyalone, are you a rubber duck? |
| 23:36 | preyalone | Daw, and I was just `cabal install`ing my new git fork of refh... |
| 23:36 | Raynes | Yikes. |
| 23:36 | gfredericks | muhoo: everything unquoted gets eval'd |
| 23:36 | gfredericks | so ~foo evals foo |
| 23:36 | Raynes | I thought I was still in paredit in this Haskell file so I did the C-u backspace trick to delete a bunch of shit. |
| 23:37 | gfredericks | putting the ' in front doesn't change that |
| 23:37 | Raynes | preyalone: Ouch. cabal sandbox-install! |
| 23:37 | preyalone | What's the difference? |
| 23:37 | Raynes | I actually built cabal from master for this. |
| 23:37 | Raynes | I can't install anything without breaking my Haskell installation. |
| 23:37 | preyalone | Well yeah |
| 23:37 | preyalone | Cabal is the worst part of Haskell. |
| 23:37 | Raynes | Not anymore. |
| 23:37 | Sgeo | I am officially a pizzavore |
| 23:38 | Raynes | They've added a sandbox mechanism to get you per-project package repositories. |
| 23:38 | preyalone | I can't install MissingH and Random-Fu (or MissingH and GraphViz) at the same time :( |
| 23:38 | Raynes | So you don't have to install things globally anymore. |
| 23:38 | muhoo | gfredericks: i have to look at where fogus/chouser were doing '~foo then, and figure out why |
| 23:38 | preyalone | Sweet! Like npm then. |
| 23:38 | gfredericks | muhoo: it's useful somethings |
| 23:38 | gfredericks | like if you want to embed forms |
| 23:39 | Raynes | Unfortunately it isn't released yet but I've been using it for a few days now from master and it is working well. |
| 23:39 | gfredericks | (defmacro spy [expr] `(let [v# ~expr] (println '~expr "is" v#) v#)) |
| 23:39 | gfredericks | muhoo: ^ |
| 23:40 | muhoo | cool |
| 23:41 | Raynes | preyalone: Just pushed my fix if you're curious. |
| 23:41 | preyalone | Sure! |
| 23:42 | preyalone | I like the POSIX support. cat | refh is cool. |
| 23:43 | muhoo | wat? did you guys do a bash/curl implementation of refheap client? |
| 23:43 | muhoo | gfredericks: that makes a lot more sense now, thanks |
| 23:43 | gfredericks | phew |
| 23:44 | gfredericks | TimMc: https://github.com/strangeloop/clojurewest2013/wiki/LightningSubmissions |
| 23:44 | gfredericks | hyPiRion: ^ |
| 23:45 | Sgeo | Raynes, putStrLn $ show parsedArgs = (putStrLn . show) parsedArgs = print parsedArgs |
| 23:45 | preyalone | Raynes: So this: https://www.refheap.com/paste/11731 |
| 23:45 | Raynes | Oops. |
| 23:45 | Raynes | I didn't even mean to commit that, Sgeo. |
| 23:45 | Raynes | That was for debugging. |
| 23:46 | Sgeo | Incidentally, I know that that's in the IO monad, but for printf-debugging outside the IO monad, you know about Debug.Trace, right? |
| 23:46 | preyalone | I've never had a chance to use the Mozilla Profiles SSO before. I think I'm in love. |
| 23:47 | Raynes | preyalone: No idea. |
| 23:47 | Raynes | preyalone: What version of GHC? |
| 23:48 | TimMc | preyalone: They're still working on getting it to work with Firefox's password manager. Once it does that it might be OK. :-) |
| 23:48 | Raynes | preyalone: I built it in a sandbox a couple of days ago with 7.4.2 |
| 23:49 | Raynes | preyalone: Nice. I like it to, hence why I used it. |
| 23:49 | preyalone | GHC 7.4.1 |
| 23:49 | Raynes | Your version obviously broke it. |
| 23:50 | Raynes | muhoo: You should drive down to LA and visit me, you know. We could jam together. |
| 23:51 | muhoo | i will be heading down that way this summer probably |
| 23:52 | preyalone | Freakin yak shaving. I wrote a RubyGem devoted to grepping arbitrary software version information, and it's broken as well. More complete Haskell version info to follow. |
| 23:53 | muhoo | Raynes: and i'm sure you will find your way up here for some reason or another too. if so, look me up for sure. |
| 23:53 | Raynes | muhoo: I might go up to SF for recreation way late this year. You'll be here before I'm there. |
| 23:53 | Raynes | When you come down and you have time let me know and we'll have dinner or something. |
| 23:54 | preyalone | There! https://www.refheap.com/paste/11732 |
| 23:54 | muhoo | Raynes: absolutely. |
| 23:56 | Raynes | muhoo: But you've got to bring a guitar. |
| 23:56 | Raynes | Or whatever you play. |
| 23:56 | Raynes | And learn Imagine Dragons songs for the occasion. |
| 23:58 | preyalone | Thanks all! As a Clojure newbie, I'm glad to see the #clojure community is as helpful as #lisp, but much nicer. |
| 23:58 | Raynes | Aw, now he is gone and I miss him. |
| 23:59 | frozenlock | eh, he was lucky some weren't here... I'm not sure he would have found us 'nicer' than #lisp :p |