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.clj
gets 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?
@lizzie: IIRC by default core datatypes have no protocols implemented for them, so they can't act like monoids and whatnot.
If you want that behaviour you have to explicitly require cats.builtin
Which has some default implementation of those protocols.
If you want to see how they behave here are the implementations - https://github.com/funcool/cats/blob/master/src/cats/builtin.cljc
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.
+1 @jaen
Thank you for the explanation. I will take a look into the implementation.
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.
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.
@niwinz: as I understand there's no way to require only some default implementations right now, yes?
At this moment it is not possible
but I think you can overwrite it with own impl without problem...
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
Yeah, I agree, I was just curious, really.
nice, in any case its really great suggestion, we haven't though about...
[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
promissum should now be considered deprecated in favor of promesa
@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)))
You are completly right!
I'll fix it ASAP
Thanks :simple_smile:
0.3.0-SNAPSHOT
is just released with the fix
Thanks for report it!
👍