Skip to content

Instantly share code, notes, and snippets.

View mfikes's full-sized avatar

Mike Fikes mfikes

View GitHub Profile
cljs.user=> (def my-inc (with-meta inc {:a 2}))
#'cljs.user/my-inc
cljs.user=> (my-inc 17)
18
cljs.user=> (js/cljs.user.my_inc 17)
cljs.user.my_inc is not a function. (In 'cljs.user.my_inc((17))', 'cljs.user.my_inc' is an instance of MetaFn)
cljs.user=> (def my-inc' (fn [x] (my-inc x)))
#'cljs.user/my-inc'
cljs.user=> (js/cljs.user.my_inc_SINGLEQUOTE_ 17)
ClojureScript 1.10.439
cljs.user=> (defprotocol IFoo
(delete [_]))
false
cljs.user=> (defrecord Foo []
IFoo
(delete [_] 1))
cljs.user/Foo
cljs.user=> (delete (->Foo))
1

Old behavior:

cljs.user=> (defn f [x] (when (even? x) (inc x)))
#'cljs.user/f
cljs.user=> (let [x (f 2)] (if x (+ x "a")))
                                 ^
WARNING: cljs.core/+, all arguments must be numbers, got [#{number clj-nil} string] instead at line 1
"3a"
ClojureScript 1.10.439
cljs.user=> (require '[clojure.spec.alpha :as s])
nil
cljs.user=> (require '[clojure.spec.test.alpha :as st])
nil
cljs.user=> (defn foo [x])
#'cljs.user/foo
cljs.user=> (s/fdef foo :args (s/cat :x int?))
cljs.user/foo
cljs.user=> (st/instrument)
cljs.user=> (def metas (atom {}))
#'cljs.user/metas
cljs.user=> (extend-type object
#_=> IWithMeta
#_=> (-with-meta [o meta]
#_=> (swap! metas assoc (goog/getUid o) meta)
#_=> o))
nil
cljs.user=> (extend-type object
#_=> IMeta
$ script/test-self-parity
Testing with Node
WARNING: / already refers to: cljs.core// being replaced by: cljs.core-test// at line 625 src/test/cljs/cljs/core_test.cljs
WARNING: Protocol IFn implements method -invoke with variadic signature (&) at line 1397 src/test/cljs/cljs/core_test.cljs
WARNING: baz is a single segment namespace at line 1 src/test/cljs/baz.cljs
WARNING: Namespace static.core-test contains a reserved JavaScript keyword, the corresponding Google Closure namespace will be munged to static$.core_test at line 1 src/test/cljs/static/core_test.cljs
WARNING: Ignoring target object "this" passed in recur to protocol method head at line 24 src/test/cljs/cljs/recur_test.cljs
WARNING: Bad method signature in protocol implementation, IIndexed -nth does not declare arity 1 at line 124 src/test/cljs/cljs/extend_to_native_test.cljs
Testing cljs.eval-test
Testing with Node
Testing self-host.test
FAIL in (test-CLJS-1612) (core-self-test.js:942:362)
core macros under syntax quote
expected: (nil? error)
actual: (not (nil? #error {:message "Could not eval ", :data {:tag :cljs/analysis-error}, :cause #error {:message "0 is not ISeqable at line 1 ", :data {:file nil, :line 1, :column 5, :tag :cljs/analysis-error}, :cause #object[Error Error: 0 is not ISeqable]}}))
FAIL in (test-CLJS-1612) (core-self-test.js:942:362)
(ns advent-2018.day-02
(:require
#?(:cljs [planck.core :refer [line-seq read-string]])
[#?(:clj clojure.java.io :cljs planck.io) :as io]
[advent-2018.day-01 :as day-01])
(:import (java.util.concurrent Executors ExecutorService)))
(def input (->> "advent_2018/day_02/input" io/resource io/reader line-seq))
(defn count-with-exact [box-ids n]
@mfikes
mfikes / err-msgs.md
Last active December 1, 2018 10:08
WIP on ClojureScript Error Messages

Illustration of WIP on CLJS-2913 is in this branch: https://github.com/mfikes/clojurescript/tree/CLJS-2913-WIP

Here are examples exploring :clojure.error/phase :read-source, :macro-syntax-check, :macroexpansion, and :compile-syntax-check

ClojureScript:

$ clj -Srepro -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.10.0-RC2"} org.clojure/clojurescript {:git/url "https://github.com/mfikes/clojurescript" :sha "b43d38a9c7d8dea1438cb8762709d95a3b447d90"}}}' -m cljs.main
cljs.user=> (require 'cljs.core.specs.alpha)
nil
@mfikes
mfikes / cljs.md
Last active January 6, 2024 07:13
cljs command

If you wan't a cljs that acts like clj, but for ClojureScript, there are a few minor changes you can make:

First, add the following entry to ~/.clojure/deps.edn under the :deps key:

org.clojure/clojurescript {:mvn/version "1.10.439"}

Then make copies of clj and clojure named cljs and clojurescript, and put those copies on your path.