This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-08
Channels
- # adventofcode (240)
- # beginners (87)
- # boot (4)
- # cider (27)
- # cljs-dev (20)
- # cljsrn (24)
- # clojure (365)
- # clojure-argentina (1)
- # clojure-brasil (4)
- # clojure-dev (12)
- # clojure-greece (65)
- # clojure-india (1)
- # clojure-italy (15)
- # clojure-japan (1)
- # clojure-losangeles (1)
- # clojure-madison (4)
- # clojure-poland (3)
- # clojure-russia (5)
- # clojure-spec (3)
- # clojure-uk (105)
- # clojurescript (27)
- # core-async (1)
- # core-logic (3)
- # cursive (61)
- # datomic (68)
- # devcards (4)
- # docs (27)
- # duct (67)
- # emacs (15)
- # events (1)
- # fulcro (8)
- # graphql (50)
- # lein-figwheel (1)
- # lumo (15)
- # numerical-computing (1)
- # off-topic (77)
- # om (3)
- # onyx (5)
- # parinfer (3)
- # planck (2)
- # portkey (5)
- # re-frame (4)
- # reagent (16)
- # ring (14)
- # rum (3)
- # shadow-cljs (17)
- # vim (1)
@snichme You might be able to do {:body #duct/resource "index"}
following the new todo CRUD docs, adding the create-entries with migration results in No implementation of method exception :duct.migrator/ragtime {:migrations [#ig/ref :todo.migration/create-entries]} [:duct.migrator.ragtime/sql :todo.migration/create-entries] {:up ["CREATE TABLE entries (id INTEGER PRIMARY KEY, description TEXT)"] :down ["DROP TABLE entries"]} dev=> (go) :duct.migrator.ragtime/rolling-back :todo.migration/create-entries#ff5e14f4 IllegalArgumentException No implementation of method: :run-down! of protocol: #' ragtime.protocols/Migration found for class: nil clojure.core/-cache-protocol-f n (core_deftype.clj:583)
Only thing that I hade to add is a dependency [duct/handler.sql "0.3.1"]
to project.clj, ping @weavejester
Have you tried lein clean
before starting it? I have had that error before (some time ago) but after getting fresh new versions it went away
odd, I did exactly the same, still seeing the same exception after applying your snippet, @snichme
Dont know if it matters but I got [org.clojure/java.jdbc "0.5.8"]
and as a dep for duct/handler.sql and not under duct/module.sql. But dont know if that might be the issue
Hmm, had another project with the same project.clj that you got (without the sql handler) and that worked. So really no idea, sorry
thank you my friend, it's ok, after deleting my local repo of duct lib, appeared that I'm having proxy issue downloading duct/handler "0.3.1"... not sure what happened, anyway at least it's getting clear. appreciate your help š
strange, @snichme the lib got renamed to handler.sql https://clojars.org/repo/duct/handler.sql/0.3.1/
uh... typo in docs ... :dependencies [[org.clojure/clojure "1.9.0-RC1"] [duct/core "0.6.1"] [duct/handler "0.3.1"]
I had to in fact recreate new todo project to make it work... was having caching problem with duct.migrator.ragtime/rollback from older config, updating config, reset, even clean, won't help... very strange
Yes, sorry, that was a typo in the guide. Iām still writing it š
@weavejester: Heyā¦ š 1. Firstly great speaking to you at clojurex! Thanks for that it was great speaking to youā¦ 2. Did you post the duct sample app you were using in your talk anywhere?
@rickmoynihan I will do, but I want to finish off the associated guide first.
yeah of course - no rush š
and finallyā¦ a question about #duct/env
ā¦
Is there a reason it needs to support coercion?
i.e. why have another way to do it and write this {:port #duct/env ["PORT" Int :or 3000]}
?
When you can do this?
{:port #int #duct/env "PORT"}
Because #int
isnāt a good data reader.
obviously not the end of the worldā¦ but we already have some readers defined for things that work elsewhere e.g. we have a #uri
to represent a URI type in our config.
can you explain? I know reader literals can sometimes compose badly
Data readers are designed to read tagged data. A #uri
tag is fine, because it adds specificity to strings.
But edn already supports integers, so why write #int "1"
when you can write 1
?
Obviously in this case we want to perform a coercion, but thatās using data readers for something they werenāt designed for.
Even #duct/env "PORT"
is kinda an abuse.
Iāve been considering doing something like:
{[:duct/env :app.const/port] {:var "PORT", :coerce Int, :default 3000}}
is it not a pragmatic abuse? š
aero does it š
I think I see what youāre driving at thoughā¦ because it is kinda weirdā¦ i.e. to use something defined at read time to coerce a runtime value.
I think itās the start of a slippery slope. It might be useful, but beyond a point you have to ask oneself why not just have a Clojure file instead of edn?
e.g.
{:port (Integer. (System/env "PORT"))}
hahaha lolā¦ yesā¦ weāve spoken before about preventing duct sliding too far that way š
Obviously thereās a line somewhere, but the more we abuse data readers, the more uncomfortably close we get to crossing it.
well Iāve been thinking a bit about this whole thingā¦ and TBH Iāve never entirely bought into the whole lets ādata all the thingsā craze thatās swept clojure ecosystem over the last few years. In some sense itās a little strange, as clojure code is just data tooā¦ And things like lists and symbols are part of edn tooā¦ which is why at first I thought integrants use of namespaced keywords to identify functions was strange, when it might be more natural to use namespaced symbols to do the same thing. Though obviously symbols canāt be used in hierarchies etc so good call on that one as hierarchies are great! š
anyway this isnāt a criticism as the data craze has led to some great things and less emphasis on macros etc.
Clojure code is data, but itās not data thatās structured in a way that allows for straightforward querying.
generally noā¦ but it can be; and spec can conform values too.
I do agree with that point thoughā¦ Iām really just saying there is more to data than maps and keywords.
e.g. I think itās very hard to reason about Turing-complete code. For example, try writing a function that uses static analysis to find all the ports an arbitrary Clojure program will listen on.
agreed
but Iām pretty sure duct is already turing complete š
I donāt think code is bad per se, but it is opaque.
What do you mean?
itās really more a technicality than in practiceā¦ so really not the end of the world; in the same way that the java type system being TC isnāt in practiceā¦ But if you were smart enough you could probably compute anything with appropriate use of merge with metadata for conditionals and #duct/include
/resource (I forget) for self reference / loops.
Yeah, :duct.core/include
is a possible source of recursion, but I intend to replace that. The metadata merging Iām reconsidering as well.
Anywayā¦ on the whole clojure vs data thing I think itās interesting that the example you posted is actually valid edn:
(clojure.edn/read-string "{:port (Integer. (System/env \"PORT\"))}")
Iām not suggesting the above is a good config file format; just that there are more types to EDN data than most people think.
Most Clojure code is valid edn š
exactly
With Clojure itās just a question of not āwe should write this with dataā, since everything is data, but more āwe should write this as data with these particular propertiesā
Duct/Integrant want data thatās readable and query-able, for example.
anyway the general realisation I had was that duct/integrant is 50% about moving it to readable data ā as you sayā¦ but 50% about exploding the require tree.
I should really let you assign the actual percentage values š
but for me the move to config is at least in part about removing restrictions over the linear single pass parse process in clojure
sorry got to rush for my trainā¦ could be 20cm of snow by the time I get home š
Good luck on your journey back!