Fork me on GitHub
#funcool
<
2015-12-04
>
lizzie09:12:53

Hello. I'm newbie to Clojure, and trying to use https://github.com/funcool/cats So I create a new project with lein, then add [funcool/cats "1.1.0"] as dependency in project.clj, and my core.cljgets as simple as: (ns core-clojure.core (:require [cats.core :as m]) (:gen-class)) (defn -main "Main" [& args] (m/mappend [1 2 3] [4 5 6]) (println "Hello, World!")) which gives following error when running like lein run from command line: Exception in thread "main" java.lang.IllegalArgumentException: No context is set and it can not be automatically resolved., compiling:(/tmp/form-init1960448665477151794.clj:1:73) Any ideas?

jaen09:12:57

@lizzie: IIRC by default core datatypes have no protocols implemented for them, so they can't act like monoids and whatnot.

jaen09:12:23

If you want that behaviour you have to explicitly require cats.builtin

jaen09:12:52

Which has some default implementation of those protocols.

jaen09:12:37

If you want to see how they behave here are the implementations - https://github.com/funcool/cats/blob/master/src/cats/builtin.cljc

jaen09:12:22

I guess it's done this way because someone might want them to behave differently - for example the monoid implementation of map does shallow merging, someone might want recursive merging for example.

lizzie09:12:54

Thank you for the explanation. I will take a look into the implementation.

jaen09:12:55

For example if you modify the map monoid for recursive merging you can get pretty nice validators with maps and sets with the validation applicative in only a few tens of lines of code.

jaen09:12:30

So that's probably why the default implementation is something you have to knowingly require - if they suit you, require them and use them, otherwise write your own.

jaen09:12:47

@niwinz: as I understand there's no way to require only some default implementations right now, yes?

niwinz09:12:36

At this moment it is not possible

niwinz09:12:55

but I think you can overwrite it with own impl without problem...

niwinz09:12:42

Maybe in a future we can think modularize that part, but at this moment we found the current solution a good start point and it works pretty well

jaen09:12:07

Yeah, I agree, I was just curious, really.

niwinz09:12:02

nice, in any case its really great suggestion, we haven't though about...

niwinz21:12:02

[ann]: promesa 0.6.0 is released yesterday, now is cross-platform (clj and cljs) and can be used in almost the same way in the both platforms

niwinz21:12:17

promissum should now be considered deprecated in favor of promesa

kenny21:12:52

@niwinz: I believe your pre-condition for repeat in beicon is incorrect. It should be on n, not v.

(defn repeat
  "Generates an observable sequence that repeats the
  given element."
  ([v]
   (repeat v -1))
  ([v n]
   {:pre [(number? v)]}
   (js/Rx.Observable.repeat v n)))

niwinz21:12:15

You are completly right!

niwinz21:12:22

I'll fix it ASAP

niwinz21:12:04

0.3.0-SNAPSHOT is just released with the fix

niwinz21:12:03

Thanks for report it!