2015-05-30
| 00:02 | randomcharhere | One issue yeh will run into is if you change yer game object you will have change all the fuctions would create an itermediate function that talks to all the other functions that way yeh end only having to modify one fuction? |
| 00:19 | escherize | The best approach I've seen for managing a big-ass-state-map is re-frame, It's a clojurescript library that's got a simple idea that wouldn't be hard to implement in clojure. |
| 00:27 | dumptruckman | escherize: thanks, i'll look into it |
| 00:27 | dumptruckman | escherize: otherwise i basically have to deal with the big-ass-state-map yeah? |
| 00:58 | ambrosebs | where does lein repl call complete.core/completions? |
| 00:59 | ambrosebs | ah I think this is the code that gets injected https://github.com/trptcolin/reply/blob/69c4c6ffe0c8903a193c1e127337832e225335b0/src/clj/reply/reader/jline/completion.clj#L6-L7 |
| 02:32 | escherize | dumptruckman: you might want to take a look at spectre for maintaining a big map if swap reset and update-in feel like not enough |
| 03:26 | elvis4526 | I'm trying to use httpkit and websocket and with-channel isn't working. |
| 03:26 | elvis4526 | within (with-channel req channel), channel is always nil. |
| 07:28 | ionthas_ | dumptruckma: "It's better to have 100 functions operate in one datset insted of having 10 functions operating in 10 differents datasets." You should check atoms, they will allow to change the state of your big object. Maybe there is a better way to do it, but I'm also a principant. |
| 07:34 | irctc | what is the super class of map list String seq ...? |
| 07:37 | oddcully | Object? |
| 09:16 | franklnrs | join #bouncetest |
| 09:20 | gfredericks | irctc: "map list String seq ..." isn't a class? |
| 10:34 | virmundi | hello. Is there anyone active in here? |
| 10:35 | virmundi | I’ll give it a shot. I need to get a File from the tests/ dir of the project. I cannot figure out how to get that without handing a full path. I need a File and not a stream. |
| 10:38 | luxbock | virmundi: might (java.io.File. (.getCanonicalPath (java.io.File. ".")) "/tests/") work? |
| 10:39 | virmundi | let me see. |
| 10:39 | luxbock | (java.io.File. (str (.getCanonicalPath (java.io.File. ".")) "/tests/file.thing")) |
| 10:40 | virmundi | yes, yes it did. now I wonder why (io/file didn’t) |
| 10:41 | luxbock | replacing java.io.File. with io/file should work exactly the same |
| 10:41 | justin_smith | luxbock: isn't that the same as (java.io.File. "./tests/") - it should be |
| 10:41 | virmundi | I added a new resources directory under test and updated the lein profiles.clj to work. |
| 10:42 | luxbock | justin_smith: oh right! |
| 10:42 | virmundi | you’re right. tempfile2 (io/file "./test/resources/20150429_102332.jpg") |
| 10:42 | virmundi | thanks |
| 10:43 | justin_smith | virmundi: here's another neat trick -- |
| 10:43 | justin_smith | ,(java.io.File. "foo" "bar") |
| 10:43 | clojurebot | #object[java.io.File 0x1a442294 "foo/bar"] |
| 10:43 | justin_smith | no need to use str either :) |
| 10:44 | virmundi | :) |
| 10:48 | gfredericks | ,(java.io.File. "foo/bar" "baz/kabling") |
| 10:48 | clojurebot | #object[java.io.File 0x3bd2c1b4 "foo/bar/baz/kabling"] |
| 10:58 | drivercache | Should i learn java before learning clojure? |
| 10:58 | drivercache | I am new. |
| 10:58 | SagiCZ | drivercache: not super necessary i would say |
| 10:58 | virmundi | no. As a guy who literally has a Java ring on as I type this, you don’t need it. |
| 10:58 | virmundi | http://s.hswstatic.com/gif/digital-jewelry-javaring.jpg |
| 10:58 | SagiCZ | drivercache: may help to read up about the very basics.. but you dont need to dive deep into inheritence, oop etc |
| 10:59 | justin_smith | drivercache: it suffices to know just enough so that javadoc is readable - you really don't need to get the syntax, but the semantics are helpful |
| 11:00 | virmundi | drivercache: the viewpoints are different. you can write clean code in java with out concern for much mutation (final for all vars), but clojure makes the same easier. |
| 11:00 | SagiCZ | virmundi: not entirely true.. its not as simple as slapping final on attributes.. clojure goes a long way towards immutability |
| 11:00 | virmundi | I agree. I was just saying. |
| 11:00 | justin_smith | virmundi: well... a final collection is still mutable, even if its field is final - so you do need immutable collections |
| 11:01 | SagiCZ | i think there are some java libraries for immutable collections.. probably not as efficient as in clojure |
| 11:01 | justin_smith | SagiCZ: clojure is a good java lib for immutable collections :) |
| 11:02 | virmundi | justin_smith: I’m saying you can do it in Java, but you’re going to get into some niche corners of Java development. Heck, using final is so odd for most developer I’ve been actually told to remove them because they make the code harder to read. |
| 11:02 | SagiCZ | justin_smith: interesting point! maybe some java coders could only use that part of clojure |
| 11:02 | SagiCZ | virmundi: seriously? thats just non-sensical, who told you that? final is appropriate in many cases and it may make the code way faster |
| 11:03 | virmundi | sagicz: a very poor programmer during a code review. I ignored her and then had a 20 minute conversation about code quality with the project manager. |
| 11:04 | SagiCZ | virmundi: i see! |
| 11:04 | SagiCZ | anyways whats up with clojure lately? is it still being developed? where is 1.7.0? is clojure losing momentum? |
| 11:04 | virmundi | sagicz: in the end, I got to keep the finals. |
| 11:05 | justin_smith | SagiCZ: 1.7 has a release cantidate, and might be the most feature rich addition we've had in a long while |
| 11:05 | justin_smith | might be comparable to the 1.2 -> 1.3 update |
| 11:06 | SagiCZ | justin_smith: and would you call clojure's future bright? i understand it will never become mainstream engine, but it needs to have a solid community so it wont die out. I hate to start a big project only to find that the tools I use get deprecated in the next year |
| 11:06 | SagiCZ | s/engine/language |
| 11:06 | justin_smith | I don't see any signs of that myself |
| 11:07 | SagiCZ | this is interesting though https://www.google.cz/trends/explore#q=clojure%2C%20golang&cmpt=q&tz= |
| 11:07 | SagiCZ | keyword trend comparison |
| 11:08 | SagiCZ | justin_smith: anyways, thanks.. thats mostly what i wanted to hear |
| 11:08 | justin_smith | clearly, if we want it to succeed, cognitect has to hand clojure over to bing |
| 11:09 | justin_smith | SagiCZ: I think the mailing list (available on google groups) gives a good idea of the state of development (both for the language and libs) - things tend to get announced or decided there |
| 11:10 | SagiCZ | justin_smith: i see.. well being quite young and from a Windows background I always found mailing-list bizzare and unproductive communication of the past.. almost like using mailing pidgeons.. so I guess thats why I didnt catch the latest development. thanks |
| 11:11 | justin_smith | SagiCZ: the UI on google groups makes it more like a web forum |
| 11:11 | SagiCZ | btw cognitect? is clojure developed by private company now< |
| 11:11 | SagiCZ | ? |
| 11:11 | justin_smith | SagiCZ: always has been |
| 11:11 | justin_smith | it accepts contributions |
| 11:12 | SagiCZ | didn't know that |
| 11:12 | justin_smith | that's why you have to sign the super official agreement and use jira if you want to submit code for clojure |
| 11:13 | SagiCZ | well I don't think it's a bad idea at all.. |
| 11:13 | SagiCZ | seems like clojure's development is fueled by Datomic and other cognitect products |
| 11:13 | justin_smith | they also offer clojure consulting |
| 11:20 | drivercache | SagiCZ: I have working knowledge of python, will it be enough to begin? |
| 11:21 | SagiCZ | drivercache: nothing is enough to begin |
| 11:21 | SagiCZ | if you learned python, you can learn clojure |
| 11:21 | SagiCZ | just note that functional programming is very different from imperative (python) and the transition might be difficult at first |
| 11:25 | gfredericks | hello |
| 11:30 | virmundi | hi |
| 11:31 | luxbock | I have a debug-printing helper library that currently just formats text nicely and prints it to the REPL |
| 11:32 | luxbock | I thought it might be a good idea to offer alternative output targets |
| 11:32 | justin_smith | luxbock: you should check out aviso/pretty and aviso/tracker |
| 11:32 | justin_smith | for prior art |
| 11:32 | luxbock | i.e. you could print to a file, create a HTML page or an org document |
| 11:32 | luxbock | justin_smith: this is mine: https://github.com/luxbock/pr-foobar |
| 11:32 | luxbock | I think they do different things |
| 11:33 | justin_smith | pretty is for things like column alignment and colors |
| 11:33 | justin_smith | tracker is for being able to show a context for errors that makes sense for clojure code |
| 11:33 | luxbock | my goal is that switching from the core-function to the pr-equivalent should be as painless as possible |
| 11:33 | justin_smith | OK |
| 11:34 | luxbock | so to switch the output function, I was thinking of making a dynamic variable that holds it |
| 11:34 | luxbock | and then just use alter-var-root to change it |
| 11:34 | luxbock | is this a good idea? |
| 11:34 | justin_smith | if you are using alter-var-root, why make the var dynamic? |
| 11:34 | luxbock | ah yeah I guess I wouldn't need to |
| 11:43 | virmundi | what am I doing wrong here: (io/copy (:tempfile file) dest-file) |
| 11:43 | virmundi | (:tempfile is a valid file). dest-file is a new file. |
| 11:44 | SagiCZ | :tempfile cant be a valid file, it is a keyword |
| 11:44 | virmundi | file is a map |
| 11:44 | virmundi | (:key m) == value? |
| 11:44 | SagiCZ | yes that is correct |
| 11:45 | virmundi | dest-file is new. But I’m getting a error actual: java.io.FileNotFoundException: /Users/jdavenpo/Pictures/tours/usa/fl/palatak/uuid/newfile.jpg |
| 11:46 | SagiCZ | well.. seems like the fild is not on that path |
| 11:49 | virmundi | (is (.exists tempfile)) |
| 11:49 | virmundi | where tempfile is the value in the map :tempfile |
| 11:49 | SagiCZ | that returns true? |
| 11:49 | virmundi | yep |
| 11:49 | SagiCZ | you can lose the "is" btw |
| 11:50 | virmundi | the temp file is classpath relative. |
| 11:50 | virmundi | I can in a test? |
| 11:50 | SagiCZ | no no.. not in a test |
| 11:50 | SagiCZ | sorry |
| 11:50 | virmundi | np. |
| 11:50 | SagiCZ | tahts really weird.. because the jvm can access the file but then says its not found? strange |
| 11:50 | virmundi | The error is the new file. |
| 11:51 | SagiCZ | oh.. |
| 11:51 | virmundi | (defmethod move :tour-list [file] |
| 11:51 | virmundi | (let [dest (create-dest file) |
| 11:51 | virmundi | dest-file (io/file dest)] |
| 11:51 | virmundi | (io/copy (:tempfile file) |
| 11:51 | virmundi | (io/file dest)) |
| 11:51 | virmundi | dest)) |
| 11:51 | SagiCZ | then maybe then you dont have write acces on the path |
| 11:51 | justin_smith | virmundi: don't do that please |
| 11:51 | virmundi | sorry, best way to do that? |
| 11:51 | SagiCZ | www.refheap.com |
| 11:51 | justin_smith | use a site like refheap |
| 11:51 | justin_smith | yeah |
| 11:51 | virmundi | https://www.refheap.com/101885 |
| 11:53 | virmundi | the blow out is on line 5, as per the refheap |
| 11:53 | virmundi | the declaration at line 3 is for debugging. |
| 11:53 | SagiCZ | virmundi: would like to help you but i rly dont know whats wrong there |
| 11:54 | Chousuke | does the directory structure exist+ |
| 11:54 | Chousuke | ? |
| 11:54 | virmundi | :( |
| 11:54 | Chousuke | File won't automatically create you directories. |
| 11:54 | SagiCZ | yeah all the folders must exist before creating a new file |
| 11:55 | justin_smith | there's a method that creates all the nested folders you need for a given path though iirc |
| 11:56 | virmundi | .mkdir executes without creating the paths. |
| 11:56 | justin_smith | .mkdirs |
| 11:57 | justin_smith | "Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories." |
| 11:57 | justin_smith | you were missing the plural s |
| 11:57 | justin_smith | .mkdir only creates a single directory, where the parent must already exist |
| 11:58 | justin_smith | .mkdirs creates all the directories needed fora given file |
| 11:58 | virmundi | :O |
| 12:04 | virmundi | so then maybe a bit of Java is required for Clojure? |
| 12:04 | justin_smith | virmundi: like I said, you should at least know how to read the javadoc |
| 12:05 | justin_smith | but that's not java - you're not using java syntax. But we use the same vm and the same methods, so that ends up being something you should at least know how to look up. |
| 12:06 | virmundi | ;) |
| 12:06 | virmundi | That was it. |
| 12:06 | virmundi | I had to get the parent dir of the new file, but worked fine. |
| 12:06 | virmundi | thanks |
| 12:07 | justin_smith | virmundi: I find the "javadoc search pane" browser plugin really useful |
| 12:08 | justin_smith | it detects when you are looking at a javadoc page, and makes a pane with real-time completion and search |
| 12:08 | SagiCZ | i would rather see the javadoc in my IDE than having to switch to browser |
| 12:09 | justin_smith | SagiCZ: I don't want to read javadoc in emacs myself |
| 12:09 | SagiCZ | i understand.. |
| 12:10 | SagiCZ | i am very sensitive to my tool chain and i understand others may be as well so that can be left for personal preference |
| 13:13 | luxbock | one thing I've started doing lately with destructuring is to always use :as even when it's not strictly needed |
| 13:13 | luxbock | but I think it makes it easier to read the code, because the name can give a hint to what the argument/local is supposed to do |
| 13:13 | luxbock | anyone else do this? |
| 13:21 | gfredericks | I don't because it looks like a mistake |
| 13:22 | gfredericks | but I appreciate the desire for documentation |
| 13:22 | gfredericks | clojure currently conflates the local names of args with documentation for the args |
| 13:22 | justin_smith | see also using prismatic/schema but not running the checks |
| 13:22 | justin_smith | but using the declarations as a form of docs |
| 13:23 | gfredericks | I wish there were a standard way to add arg documentation |
| 13:23 | justin_smith | yeah, exactly |
| 13:23 | justin_smith | metadata on args? |
| 13:23 | gfredericks | the drawback is |
| 13:23 | luxbock | gfredericks: ditto |
| 13:23 | gfredericks | you sometimes have multiple arglists |
| 13:23 | gfredericks | which might be irrelevant to the documentation |
| 13:23 | gfredericks | ,(doc +) |
| 13:23 | clojurebot | "([] [x] [x y] [x y & more]); Returns the sum of nums. (+) returns 0. Does not auto-promote longs, will throw on overflow. See also: +'" |
| 13:24 | justin_smith | gfredericks: first class code accessible arglist objects, with first class code accessible arg objects |
| 13:24 | gfredericks | what |
| 13:24 | justin_smith | so you could do like (-> #'+ :arglists first :args first :doc) |
| 13:24 | justin_smith | never mind that's crazy |
| 13:25 | gfredericks | I would suggest :doc/args metadata on the var |
| 13:25 | gfredericks | related, you could also add examples as metadata |
| 13:25 | gfredericks | i.e., as first-class code rather than in a docstring |
| 13:25 | gfredericks | which could additionally be subject to automatic validation |
| 13:25 | justin_smith | tests can already be specified this way |
| 13:26 | gfredericks | yeah |
| 13:26 | gfredericks | well |
| 13:26 | gfredericks | sort of |
| 13:26 | gfredericks | ,(doc test) |
| 13:26 | clojurebot | "([v]); test [v] finds fn at key :test in var metadata and calls it, presuming failure will throw exception" |
| 13:26 | gfredericks | ^ it looks for a fn, not a form |
| 13:26 | justin_smith | ahh |
| 13:26 | justin_smith | yeah that is different |
| 13:27 | gfredericks | and you have to throw exceptions :/ |
| 14:11 | gfredericks | does anybody know an elisp way to check if the current buffer is a file that is in the project that the default cider connection is a part of? |
| 14:11 | gfredericks | I assume any solution has to be super hacky |
| 14:12 | clojer | I have a (let .... form containing 2 non-nested (for ... comprehensions. Only the last one seems to execute even if I wrap them both in a (do ... block which shouldn't be necessary in a (let ... form. |
| 14:17 | justin_smith | ~for |
| 14:17 | clojurebot | for is a beautiful person |
| 14:18 | justin_smith | clojer: sorry, I wanted a different factoid. for is lazy |
| 14:18 | justin_smith | use doseq if you are not consuming the result |
| 14:18 | justin_smith | it's almost identical, but returns nil and is not lazy |
| 14:18 | justin_smith | ,(do (for [a (range 10)] (println a)) nil) |
| 14:18 | clojurebot | nil |
| 14:19 | clojer | justin_smith: Why does only the last for comp execute? |
| 14:19 | justin_smith | ,(do (doseq [a (range 10)] (println a)) nil) |
| 14:19 | clojurebot | 0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n |
| 14:19 | justin_smith | clojer: laziness |
| 14:19 | justin_smith | notice the difference between what for and doseq did above |
| 16:05 | fourq | I'm reading up on persistent vectors and their inner workings. If someone could speak to this image, specifically what it means when it says "path copying". The way I interpret this is that the new vec, the blue one, created 3 new internal nodes, 1 new leaf node, and then pointed the left internal node to the existing, old, vector. Where does "path copying" come into play here? http://screencast.com/t/ZG4igyaPHS7 |
| 16:25 | bmorphism | Is output-stream with lazy-seq the solution if I want to output the results of a computation into a file and not keep them in memory? |
| 17:21 | underplank | So I have this (def scripts-path (str (io/resource "test/scripts") "/")) |
| 17:21 | underplank | which gives me "file:/Users/mlakewood/Projects/orochi/resources/test/scripts/" |
| 17:21 | underplank | hoe do I get just the string representation without the file: on there |
| 17:22 | underplank | *how |
| 17:28 | justin_smith | underplank: (.getPath (io/resource "test/scripts")) |
| 17:28 | justin_smith | you don't need to add the / yourself |
| 17:29 | underplank | Oh great! I’d worked out that I needed to get a java url and then do getPath on it.. but didnt realise that I could just call getPath on the return. Makes sens. |
| 17:29 | underplank | thanks justin_smith helpful as always! |
| 17:42 | jtmarmon | hey guys |
| 17:43 | jtmarmon | i have a fairly large threaded macro that fails macro expansion whenever I add "..." to one of the forms...if i remove it it succeeds. the compilation error is "CompilerException java.lang.StringIndexOutOfBoundsException: String index out of range: 0" |
| 17:43 | jtmarmon | just having ... anywhere in the macro makes it fail with that error. it's quoted just fine as far as i can tell. super weird |
| 17:44 | justin_smith | wait, what does 'add "..." to one of the forms' mean exactly? |
| 17:44 | justin_smith | like one of the forms has "..." in it? |
| 17:44 | justin_smith | the string? |
| 17:44 | jtmarmon | yep |
| 17:44 | jtmarmon | no |
| 17:44 | jtmarmon | the characters ... |
| 17:44 | jtmarmon | not in a string |
| 17:44 | jtmarmon | the form is quoted |
| 17:45 | justin_smith | even if quoted, I don't think ... is valid - it's not a valid symbol or symbol constituent. There may be contexts where it works accidentally. |
| 17:45 | justin_smith | ,'... |
| 17:45 | clojurebot | ... |
| 17:46 | jtmarmon | it's for a datomic collection binding |
| 17:46 | justin_smith | OK |
| 17:46 | justin_smith | funny, ... actually works as a symbol, but I didn't expect it to |
| 17:47 | jtmarmon | http://puu.sh/i6pA9/97aa45aa3f.png |
| 17:50 | TEttinger | ,(let [... "wat"] ...) |
| 17:50 | clojurebot | #error {\n :cause "Illegal field name \"...\" in class sandbox$eval49"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.ClassFormatError: Illegal field name \"...\" in class sandbox$eval49, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]}\n {:type java.lang.ClassFormatError\n :message "Illegal field name \"...\" in ... |
| 17:50 | TEttinger | hm |
| 17:50 | justin_smith | ,(def ... "this works") |
| 17:50 | clojurebot | #'sandbox/... |
| 17:51 | justin_smith | ,... |
| 17:51 | clojurebot | "this works" |
| 17:51 | TEttinger | whaaaaat |
| 17:51 | justin_smith | TEttinger: yeah, I know, right? |
| 17:51 | justin_smith | that's why my first instinct was that it only worked accidentally |
| 17:51 | TEttinger | (inc wat) |
| 17:51 | lazybot | ⇒ 3 |
| 17:51 | TEttinger | how doe sthat have 3 |
| 17:51 | justin_smith | TEttinger: I think it's because vars are not used as method or field names |
| 17:52 | justin_smith | TEttinger: if only our incs left metadata we could look up on the karma :) |
| 17:52 | TEttinger | haha |
| 17:52 | TEttinger | lazybot could even dump to refheap |
| 17:56 | justin_smith | ,(def watset (hash-set Double/NaN Double/NaN Double/NaN)) |
| 17:56 | clojurebot | #'sandbox/watset |
| 17:56 | justin_smith | ,watset |
| 17:56 | clojurebot | #{NaN NaN NaN} |
| 17:56 | justin_smith | ,(get watset Double/NaN) |
| 17:56 | clojurebot | nil |
| 17:56 | justin_smith | ,(get watset (first watset)) |
| 17:56 | clojurebot | NaN |
| 17:56 | justin_smith | roflmao |
| 18:02 | justin_smith | ,(= watset (hash-set Double/NaN Double/NaN Double/NaN)) |
| 18:02 | clojurebot | false |
| 18:02 | justin_smith | ,(= watset (apply hash-set watset)) |
| 18:02 | clojurebot | true |
| 18:02 | TEttinger | haha |
| 18:02 | TEttinger | ,(count watset) |
| 18:02 | clojurebot | 3 |
| 18:03 | TEttinger | ,(distinct watset) |
| 18:03 | clojurebot | #<UnsupportedOperationException java.lang.UnsupportedOperationException: nth not supported on this type: PersistentHashSet> |
| 18:03 | TEttinger | oh? |
| 18:03 | justin_smith | ,(distinct (seq watset)) |
| 18:03 | clojurebot | (NaN NaN NaN) |
| 18:03 | TEttinger | ,(distinct (seq watset)) |
| 18:03 | clojurebot | (NaN NaN NaN) |
| 18:03 | TEttinger | haha |
| 18:03 | justin_smith | TEttinger: it's like we found the weirdest insect ever under a rock, and now we just can't stop poking it |
| 18:03 | TEttinger | haha |
| 18:04 | justin_smith | let's see what it does if we put it in a jar with a spider |
| 18:04 | TEttinger | I was going to link to a solifugid, but oh god those things are terrifying |
| 18:05 | justin_smith | is that the same as a camel spider? |
| 18:05 | TEttinger | here's a better weird bug, it's nice https://flic.kr/p/cu62MQ |
| 18:05 | TEttinger | not sure |
| 18:06 | TEttinger | I think sun spiders |
| 18:06 | justin_smith | $google solifugid |
| 18:06 | TEttinger | I don't like house centipedes for totally different reasons |
| 18:06 | lazybot | [Solifugae - Wikipedia, the free encyclopedia] http://en.wikipedia.org/wiki/Solifugae |
| 18:06 | justin_smith | "known variously as camel spiders, wind scorpions, sun spiders, or solifuges" |
| 18:06 | TEttinger | (as in, if you hit a house centipede with, say, your shoe, its legs fly off and KEEP MOVING) |
| 18:06 | justin_smith | heh |
| 18:07 | justin_smith | very similar in nature to a set full of multiple NaNs |
| 18:07 | TEttinger | yes |
| 18:07 | TEttinger | it is what should not be |
| 18:55 | sdegutis | Is there anything Clojure can't do that Haskell can, aside from the restrictions and type-checking errors Haskell provides? |
| 18:56 | gfredericks | it's probably easier to call C code in haskell? |
| 18:57 | sdegutis | Okay but any algorithmic type things? |
| 18:57 | sdegutis | Like, can Clojure implement monads? |
| 19:01 | justin_smith | there are monadic libraries for clojure, but since we don't have easy type inference or strong type requirements they usually don't end up being especially useful |
| 19:05 | sdegutis | Ah I see. |
| 19:06 | sdegutis | Thanks guys. |
| 19:06 | sdegutis | Welp, back to cleaning up the mess I made in our codebase at work. |
| 19:06 | gfredericks | sdegutis: actually yeah monads are a good point -- you can't straightforwardly write polymorphic 0-arg functions that monads in haskell depend on |
| 19:07 | gfredericks | I think this is the main reason why trying to write a monad library in clojure is pretty awkward |
| 19:08 | justin_smith | gfredericks: even using one is a bit weird |
| 19:08 | gfredericks | I've never tried |
| 19:09 | sdegutis | gfredericks: Oooh, that explains it. |
| 19:09 | sdegutis | Because in Clojure, polymorphism requires at least one argument. |
| 19:09 | gfredericks | yep |
| 19:09 | sdegutis | In Haskell, it can be based on type, which is like an implicit argument almost. |
| 19:09 | gfredericks | can't write (return x) or (pure x) or whatever |
| 19:09 | sdegutis | Got it. |
| 19:09 | gfredericks | so you could A) require everybody to pass "the monad" around, in which case nobody will want to use your library |
| 19:10 | gfredericks | B) do something magical with macros or dynamic vars or something, in which case nobody will want to use your library |
| 19:10 | gfredericks | C) don't bother writing a monads library, in which case nobody will want to use your library |
| 19:11 | gfredericks | if bbloom were here he would argue that monads aren't very useful anyhow |
| 19:11 | bbloom | just use a lazy seq and write an interpreter for that seq w/ reduce |
| 19:12 | sdegutis | Oooh, of course! |
| 19:12 | sdegutis | bbloom: why not transducers? |
| 19:12 | gfredericks | he didn't say not transducers |
| 19:12 | sdegutis | bbloom: I was under the impression that transdocers completely obsolete your solution. |
| 19:12 | sdegutis | gfredericks: I thought transducers and lazy seqs were incompatible? |
| 19:13 | gfredericks | not at all |
| 19:13 | bbloom | s/lazy seq/whatever-ducable/ |
| 19:13 | gfredericks | ,(doc sequence) |
| 19:13 | clojurebot | "([coll] [xform coll] [xform coll & colls]); Coerces coll to a (possibly empty) sequence, if it is not already one. Will not force a lazy seq. (sequence nil) yields (), When a transducer is supplied, returns a lazy sequence of applications of the transform to the items in coll(s), i.e. to the set of first items of each coll, followed by the set of second items in each coll, until any one of the co... |
| 19:14 | gfredericks | hmm |
| 19:14 | gfredericks | ,(sequence (map inc) [1 2 3]) |
| 19:14 | clojurebot | (2 3 4) |
| 19:14 | gfredericks | ,(type (sequence (map inc) [1 2 3])) |
| 19:14 | clojurebot | clojure.lang.LazySeq |
| 19:14 | gfredericks | ,(sequence (map inc) (range 5)) |
| 19:14 | clojurebot | (1 2 3 4 5) |
| 19:14 | gfredericks | ^ lazy seq in, lazy seq out, w/ transducers |
| 19:15 | gfredericks | did refinements ever make it to ruby 2? |
| 19:20 | sdegutis | I think I prefer objects, classes, and dot-notation. |
| 19:20 | gfredericks | you've been saying that for weeks now I think |
| 19:20 | sdegutis | I have? I thought this was the first time. |
| 19:20 | gfredericks | okay I'll stop conversing I guess |
| 19:21 | sdegutis | wat |
| 19:22 | sdegutis | I don't see the connection from everything before that to that. |
| 19:23 | gfredericks | I assumed you were trolling because most of your conversation lately has been about OOP |
| 19:28 | gfredericks | I was tripped up by the difficulty of telling intentions via text; my apologies |
| 19:29 | sdegutis | :| |
| 19:34 | sdegutis | I guess I'm just coming to this same conclusion over and over because I've made a mess of my codebase by trying to design our system with just pure functions, which has a lot of drawbacks. |
| 19:39 | gfredericks | how much legacy ruby have you dealt with? |
| 19:40 | sdegutis | gfredericks: plenty |
| 19:40 | sdegutis | gfredericks: I'd say this is worse. |
| 19:43 | sdegutis | Neat how in Datomic a bool value can be true false or nil. |
| 19:44 | sdegutis | I am taking advantage of that right now in my code. |
| 23:35 | dumptruckman | how do i join together lists into one list? |
| 23:35 | justin_smith | dumptruckman: concat |
| 23:35 | dumptruckman | ah, thanks |
| 23:36 | justin_smith | ,(concat (range 3) (range 3)) |
| 23:36 | clojurebot | (0 1 2 0 1 ...) |
| 23:38 | dumptruckman | is there some way to do this with destructuring? |
| 23:38 | dumptruckman | (concat (for [player (:players entites)] (:segments player))) |
| 23:38 | justin_smith | no |
| 23:39 | justin_smith | I mean there is apply concat |
| 23:39 | dumptruckman | actually i'm not even sure that's right >.> |
| 23:39 | justin_smith | or mapcat |
| 23:39 | justin_smith | ,(apply concat (for [a {:a [0 1]} {:a [:b :c]}] (:a a))) |
| 23:39 | clojurebot | #error {\n :cause "for requires an even number of forms in binding vector in sandbox:"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: for requires an even number of forms in binding vector in sandbox:, compiling:(NO_SOURCE_FILE:0:0)"\n :at [clojure.lang.Compiler macroexpand1 "Compiler.java" 6644]}\n {:type java.lang.IllegalArgumentExce... |
| 23:39 | justin_smith | err |
| 23:39 | clojurebot | I don't understand. |
| 23:40 | justin_smith | ,(apply concat (for [a [{:a [0 1]} {:a [:b :c]}]] (:a a))) |
| 23:40 | clojurebot | (0 1 :b :c) |
| 23:40 | justin_smith | (mapcat :a [{:a [0 1]} {:a [:a :b]}]) |
| 23:40 | justin_smith | ,(mapcat :a [{:a [0 1]} {:a [:a :b]}]) |
| 23:40 | clojurebot | (0 1 :a :b) |
| 23:40 | dumptruckman | wait |
| 23:40 | dumptruckman | apply concat? |
| 23:40 | justin_smith | mapcat is likely the one you want |
| 23:40 | dumptruckman | i see |
| 23:41 | justin_smith | but apply concat works too |
| 23:41 | justin_smith | mapcat is just apply concat map ... |
| 23:41 | justin_smith | $source mapcat |
| 23:41 | lazybot | mapcat is http://is.gd/HgriSd |
| 23:41 | dumptruckman | i see |
| 23:45 | dumptruckman | when i'm defining a map is it possible to refer to the values i've defined ahead of another? |
| 23:46 | justin_smith | sounds like something where a let block plus a few calls to assoc would help |
| 23:46 | TEttinger | dumptruckman: you can use ##(declare) |
| 23:46 | lazybot | ⇒ nil |
| 23:46 | TEttinger | dumptruckman: you can use ##(doc declare) |
| 23:46 | lazybot | ⇒ "Macro ([& names]); defs the supplied var names with no bindings, useful for making forward declarations." |
| 23:46 | dumptruckman | O.o |
| 23:46 | dumptruckman | for instance |
| 23:46 | TEttinger | ,(declare foo) |
| 23:46 | clojurebot | #'sandbox/foo |
| 23:47 | TEttinger | ,{:bar foo :a 1} |
| 23:47 | clojurebot | {:bar #object[clojure.lang.Var$Unbound 0x7c02c5a4 "Unbound: #'sandbox/foo"], :a 1} |
| 23:47 | TEttinger | ,(def mapperz {:bar foo :a 1}) |
| 23:47 | clojurebot | #'sandbox/mapperz |
| 23:47 | TEttinger | ,(def foo "yay") |
| 23:47 | clojurebot | #'sandbox/foo |
| 23:47 | TEttinger | ,mapperz |
| 23:47 | clojurebot | {:bar #object[clojure.lang.Var$Unbound 0x7c02c5a4 "Unbound: #'sandbox/foo"], :a 1} |
| 23:47 | TEttinger | hm |
| 23:47 | dumptruckman | {:a a :b b :c :a} where the value for c is the value for :a |
| 23:47 | TEttinger | oh |
| 23:47 | justin_smith | yeah, use assoc for that |
| 23:48 | justin_smith | ,((fn [m] (assoc m :c (:a m))) {:a 0}) |
| 23:48 | clojurebot | {:a 0, :c 0} |
| 23:49 | dumptruckman | meh |
| 23:49 | dumptruckman | i think that's probably more complicated than juts putting the value again |
| 23:49 | justin_smith | dumptruckman: if you already knew the value, do that |
| 23:49 | TEttinger | or you could have it be a key into a different table |
| 23:49 | justin_smith | I thought you were talking about a situation where the caller could specify any :a they please, and you need to map :c to that too |
| 23:50 | dumptruckman | nah |
| 23:50 | dumptruckman | i'm defining a player object which has a color key |
| 23:50 | dumptruckman | and also needs to define a shape in the same map using that color |
| 23:50 | dumptruckman | it might be useful later |
| 23:50 | dumptruckman | when i get to having more than 1 player |
| 23:50 | TEttinger | ,(let [inner {:a 10 :b 20} outer {:a :a :b :b :c :a}] (inner (outer :c))) |
| 23:50 | clojurebot | 10 |
| 23:51 | dumptruckman | wat |
| 23:54 | dumptruckman | i can't wrap my mind around that |
| 23:56 | dumptruckman | hmm |
| 23:56 | dumptruckman | this doesn't seem to be doing what i'm going for |
| 23:56 | dumptruckman | (apply concat (for [player (:players entities)] (:segments player))) |
| 23:57 | justin_smith | dumptruckman: equivalent is (mapcat :segments (:players entities)) |
| 23:57 | justin_smith | and I think that version is a bit nicer |
| 23:57 | dumptruckman | well |
| 23:57 | dumptruckman | it produces an empty lits |
| 23:57 | dumptruckman | but there's definitely something in the segments part that i'm trying to retrieve |
| 23:58 | dumptruckman | so entities is a map that has a seq of :players and each element of that seq has a seq of :segments |
| 23:59 | justin_smith | so (-> entities :players first :segments) will always give you a seq |
| 23:59 | justin_smith | if so, that for comprehension should work |