This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-28
Channels
- # announcements (4)
- # aws (2)
- # babashka (56)
- # beginners (43)
- # calva (70)
- # clj-kondo (25)
- # cljs-dev (29)
- # clojure (103)
- # clojure-dev (9)
- # clojure-europe (55)
- # clojure-gamedev (8)
- # clojure-nl (5)
- # clojure-norway (5)
- # clojure-uk (4)
- # clojured (1)
- # clojurescript (56)
- # copenhagen-clojurians (1)
- # core-async (2)
- # cursive (16)
- # datomic (5)
- # deps-new (18)
- # emacs (9)
- # events (3)
- # fulcro (45)
- # graphql (2)
- # gratitude (2)
- # kaocha (6)
- # lambdaisland (8)
- # lsp (72)
- # meander (41)
- # missionary (5)
- # nextjournal (52)
- # off-topic (2)
- # pathom (12)
- # pedestal (2)
- # practicalli (1)
- # re-frame (6)
- # reitit (5)
- # releases (1)
- # reveal (1)
- # specter (3)
- # sql (4)
- # tools-deps (22)
- # vim (8)
- # wasm (1)
- # xtdb (22)
Hi there! Thanks! I found something more regarding custom types (playing with that now). Will post details in the thread.
I'll start with the following, which works properly.
(deftype MyType [a b])
(MyType. 1 2)
;; => #object[sometest.MyType 0x57c6a598 "[email protected]"]
Then, l add toString
:
(deftype MyType [a b]
Object
(toString [_] (str "#MyType " [a b])))
(MyType. 1 2)
;; => #object[sometest.MyType 0x1987e9b3 "#MyType [1 2]"]
Now I add two more interfaces:
(deftype MyType [a b]
Object
(toString [_] (str "#MyType " [a b]))
clojure.lang.Sequential
clojure.lang.Seqable
(seq [_] (seq [a b])))
(MyType. 1 2)
;; => #object[sometest.MyType 0x6fd2252 "#MyType [1 2]"]
1. Unhandled java.lang.AbstractMethodError
Receiver class sometest.MyType does not define or inherit an
implementation of the resolved method 'abstract clojure.lang.ISeq
seq()' of interface clojure.lang.Seqable.
RT.java: 543 clojure.lang.RT/seqFrom
RT.java: 537 clojure.lang.RT/seq
core.clj: 139 clojure.core/seq
core.clj: 7392 clojure.core/bounded-count
core.clj: 7386 clojure.core/bounded-count
viewer.cljc: 320 nextjournal.clerk.viewer$bounded_count_opts$fn__18923/invoke
viewer.cljc: 320 nextjournal.clerk.viewer$bounded_count_opts/invokeStatic
viewer.cljc: 317 nextjournal.clerk.viewer$bounded_count_opts/invoke
viewer.cljc: 418 nextjournal.clerk.viewer$describe/invokeStatic
viewer.cljc: 366 nextjournal.clerk.viewer$describe/invoke
viewer.cljc: 372 nextjournal.clerk.viewer$describe/invokeStatic
viewer.cljc: 366 nextjournal.clerk.viewer$describe/invoke
view.clj: 110 nextjournal.clerk.view/->result
view.clj: 109 nextjournal.clerk.view/->result
view.clj: 164 nextjournal.clerk.view/describe-block
view.clj: 151 nextjournal.clerk.view/describe-block
core.clj: 2635 clojure.core/partial/fn
core.clj: 2746 clojure.core/map/fn/fn
PersistentVector.java: 343 clojure.lang.PersistentVector/reduce
core.clj: 6885 clojure.core/transduce
core.clj: 6901 clojure.core/into
core.clj: 6889 clojure.core/into
view.clj: 171 nextjournal.clerk.view/doc->viewer/fn
core.clj: 6185 clojure.core/update
core.clj: 6177 clojure.core/update
view.clj: 171 nextjournal.clerk.view/doc->viewer
view.clj: 167 nextjournal.clerk.view/doc->viewer
clerk.clj: 274 nextjournal.clerk/file->viewer
clerk.clj: 271 nextjournal.clerk/file->viewer
clerk.clj: 273 nextjournal.clerk/file->viewer
clerk.clj: 271 nextjournal.clerk/file->viewer
core.clj: 2598 clojure.core/juxt/fn
core.clj: 2746 clojure.core/map/fn/fn
PersistentVector.java: 343 clojure.lang.PersistentVector/reduce
core.clj: 6885 clojure.core/transduce
core.clj: 6901 clojure.core/into
core.clj: 6889 clojure.core/into
clerk.clj: 380 nextjournal.clerk/build-static-app!
clerk.clj: 366 nextjournal.clerk/build-static-app!
REPL: 15 sometest/eval25870
When I copied above code to the different namespace I've got the same error. When I changed MyType
to MyType2
the result is almost ok (ignoring toString
though):
adding another interface causes an error again (for example clojure.lang.Counted (count [_] 2)
pushed a fix for the first issue https://github.com/nextjournal/clerk/commit/a30123a231a4b13e7caed66e12b4d29bdd92d772 now looking at the second one…
@mkvlr how to locally install Clerk snapshot from the source code (I use lein in current project I wanted to test for #64)?
(in-ns 'nextjournal.clerk.viewer)
(defn- var-from-def? [x]
(and (map? x) (get x :nextjournal.clerk/var-from-def)))
genuary.2022.day26> (in-ns 'nextjournal.clerk.viewer)
#namespace[nextjournal.clerk.viewer]
nextjournal.clerk.viewer> (defn- var-from-def? [x] (println "aaa")
(and (map? x) (get x :nextjournal.clerk/var-from-def)))
#'nextjournal.clerk.viewer/var-from-def?
nextjournal.clerk.viewer> (clerk/build-static-app! {:out-path "docs" :paths ["src/genuary/2022/day26.clj"]})
#error {
:cause class clojure.lang.Keyword cannot be cast to class java.lang.Character (clojure.lang.Keyword is in unnamed module of loader 'app'; java.lang.Character is in module java.base of loader 'bootstrap')
:via
[{:type java.lang.ClassCastException
:message class clojure.lang.Keyword cannot be cast to class java.lang.Character (clojure.lang.Keyword is in unnamed module of loader 'app'; java.lang.Character is in module java.base of loader 'bootstrap')
:at [clojure.lang.RT uncheckedIntCast RT.java 1476]}]
:trace
we were actually talking about this piece of code and we wondering if it’s safe to call get
yesterday 😼
A couple of minor observations when using build-static-app!
(version 0.5.346)...
• Using :bundle? false
nicely generates the individual .html
files but with incorrect hyperlinks between them. Is there a sort of root URL parameter that I ought to have set? (Using :bundle? true
generated correct intra-page hyperlinks.) Or perhaps the :bundle? false
setting isn’t quite public yet.
• It opens my web browser at http://localhost:7778/build but nothing is being served from there.
Thanks.
Thanks @mkvlr…
:path-prefix "public/build/"
is what I needed to get my hyperlinks to work (when using :bundle? false
). Although (very minor) build-static-app!
still tries to open my web browser at
when
is what works.
I don’t think you want public in your links or do you actually want to serve it from your.domain/public/build
?
…as you say, I don’t want public in my URLs but, I was struggling to get to the right value for a :path-prefix
. This is what now works for me in my deps.edn
:
:aliases {:web-pages
;; To use this alias...
;; (1) run a webserver, e.g.
;; python3 -m http.server 7778 --directory public
;; (2) and run this alias, e.g.
;; clj -X:web-pages
;; (3) once Clerk has finished generating the HTML files
;; it will open a web browser at the 'index' URL for those HTML files:
;;
{:extra-paths ["datasets"]
:exec-fn nextjournal.clerk/build-static-app!
:exec-args {:bundle? false
:path-prefix "build/"
:paths ["index.md"
"notebooks/scotgov_datasets.clj"
"notebooks/wikidata_label_first_querying_for_scotgov_agencies.clj"]}}}
Thanks for the pointers 😃@mkvlr as @borkdude pointed out in issue comments, fault was on my side. Saying that I think the change you've made should be reverted since get
may work on many other types (unless you expect a map and only map).
yeah, in this case I expect only a map, this is a data structure internal to Clerk so I don’t think being defensive hurts here
I noticed that enums in tables get rendered as objects: I this wanted behaviour ?