Couple of extracts from lein deps :tree
With
:dependencies [[com.taoensso/encore "2.92.0"]
[org.clojure/clojurescript "1.9.946"]]
[com.taoensso/encore "2.92.0"]
(ns can-i-stub.main | |
(:require [cljs.nodejs :as nodejs] | |
[cljs.spec.alpha :as s] | |
[clojure.spec.test.alpha :as stest])) | |
(nodejs/enable-util-print!) | |
(defn add2 [a b] 10.1) | |
(s/fdef add2 :args (s/cat :a int? :b int?) :ret int?) |
Couple of extracts from lein deps :tree
With
:dependencies [[com.taoensso/encore "2.92.0"]
[org.clojure/clojurescript "1.9.946"]]
[com.taoensso/encore "2.92.0"]
(s/def ::columns (s/coll-of qualified-keyword? :type set?)) | |
(s/def ::from (s/coll-of simple-keyword? :type set?)) | |
(s/def ::aliases (s/map-of simple-keyword? simple-keyword?)) | |
(s/def ::left-join (s/map-of simple-keyword? ::where)) | |
(s/def ::where (s/coll-of ::condition)) | |
(s/def ::condition (s/cat :op #{:=} :args (s/+ any?))) | |
(def my-query1 | |
{::columns #{:SITE/NAME :BL/NAME} | |
::from #{:SITE} |
From: https://groups.google.com/forum/#!msg/clojurescript/o0Q8Gs_0HYQ/yv0NgDD1BgAJ
You can easily achieve this by creating a CLJS namespace that self-requires the macros. Having dedicated .macros namespaces is generally not recommended.
pixi/something.cljs
(ns pixi.something
(:require-macros [pixi.something]))
(def example-data (atom {:args #{} :ret #{}})) | |
(defn record-example [k v] | |
(js/console.debug ::record-example [k v]) | |
(swap! example-data update k conj v) | |
v) |
(ns condense.replacing-fks | |
(:require [clojure.inspector] | |
[clojure.pprint :refer [pprint]] | |
[clojure.java.jdbc :as j] | |
[clojure.string :as string] | |
[clojure.spec :as s] | |
[honeysql.core :as sql] | |
[honeysql.helpers :as hh])) | |
(defn db-primary-keys |
(def reg | |
{::doc '(keys [::id ::title ::summary ::authors]) | |
::doc2 '(keys [::title]) | |
::title :field/text | |
::summary :field/text | |
::authors '(and (coll-of ::author) :field/many) | |
::author '(keys [::id ::name]) | |
:field/text (fn [data] {:value data :type :text}) | |
:field/many (fn [data] {:value data :type :many})}) |
(ns kotka.memoizer) | |
; Published by Meikel Brandmeyer on 15 March 2010, 23:53. | |
; https://kotka.de/blog/2010/03/memoize_done_right.html | |
; Minor tweaks for CLJS use | |
; Untested! | |
(defn current-time-millis | |
[] |
This strikes me as a handy debugging pattern:
(defonce dbg-db (atom {}))
(defn log [k v]
(swap! dbg-db update-in [k] conj v)
(js/console.log k v)
v)
Currently writing a function spec is a bit like verbose destructing - it can require as much code as the function itself.
Reduced effort in spec'ing functions would be nice.
Spec encourages namespaced keywords to have one "type". That means within your program any map with that key can be assumed to have a predictable type.
A similar convention is to have one meaning for a variable name in a specific namespace. Nothing in spec about that... it's just less confusing.