Fork me on GitHub
#beginners
<
2022-12-26
>
mister_m01:12:04

Are there any conventions that exist for providing a library/program that has an API designed to be used in the REPL? Or any gotchas to be aware of? As far as I can tell the user just has to ensure the library is on the classpath, and then import it and work with it like any other function(s).

Marc Andreu Fernandez04:12:14

Hello, I am trying to setup my spacemacs configuration using the https://practical.li/spacemacs/. When I start spacemacs I get the following warnings.

Error (use-package): org/:config: Symbol's function definition is void: org-assert-version
Error (use-package): ligature/:init: Symbol's function definition is void: ligature-set-ligatures
Error (use-package): Cannot load ligature
Error (use-package): org/:config: Symbol's function definition is void: org-assert-version
Error (use-package): flycheck/:config: Wrong type argument: listp, t
Is this something I should fix? Any tips on what could I do to fix this? Many thanks Merry Christmas and happy new year to everyone.

practicalli-john10:12:36

I'll take a look and try replicate the error (Update: having carried out a package update and Spacemacs update I havent been able to replicate the error) In the mean time there is a troubleshooting guide at https://practical.li/spacemacs/install-spacemacs/troubleshooting.html

practicalli-john10:12:01

The errors may be from packages installed in an order that doesnt meet all their requirements (although usually these are only warnings, not errors), so a quick check is to restart Emacs after all packages have been installed. Some errors mention Ligatures, so it may be the font that is defined in the Spacemacs configuration is not installed. The practicalli/spacemacs.d configuration uses Fira Code which has ligature support. Check if Fira Code is installed or change the configuration to use an a Font that is installed on the operating system

practicalli-john10:12:41

FYI: there is also a #C09C8GRLY channel for future questions about using Spacemacs and an #C099W16KZ channel for more general Emacs questions

Marc Andreu Fernandez12:12:16

I John, I think that I have installed Fira Code font

fc-list | grep firacode                                                                                                                                             ─╯
/usr/share/fonts/truetype/firacode/FiraCode-Bold.ttf: Fira Code:style=Bold
/usr/share/fonts/truetype/firacode/FiraCode-SemiBold.ttf: Fira Code,Fira Code SemiBold:style=SemiBold,Regular
/usr/share/fonts/truetype/firacode/FiraCode-Retina.ttf: Fira Code,Fira Code Retina:style=Retina,Regular
/usr/share/fonts/truetype/firacode/FiraCode-Medium.ttf: Fira Code,Fira Code Medium:style=Medium,Regular
/usr/share/fonts/truetype/firacode/FiraCode-Regular.ttf: Fira Code:style=Regular
/usr/share/fonts/truetype/firacode/FiraCode-Light.ttf: Fira Code,Fira Code Light:style=Light,Regular
I have updated the init.el from .spacemacs.d with as
dotspacemacs-default-font '("Ubuntu Mono"
                               :size 12.0
                               :weight normal
                               :width normal)

Marc Andreu Fernandez12:12:04

I got the same warning, but no worries if these are only warning I will leave it and progress my learning 🙂

Daniel Vieira11:12:06

Why (name nil) throws?

andy.fingerhut13:12:25

The doc string for name defines a return value if the parameter is a string, symbol, or keyword. It promises nothing if the parameter is not one of those types.

andy.fingerhut13:12:01

When the doc string promises nothing, in some cases you may get something you don't like, e.g. an exception.

andy.fingerhut13:12:10

That is the case in general for all Clojure functions, not just name -- if you call them with parameters that are not documented, all bets are off for the return value / behavior.

Daniel Vieira14:12:08

Thank you very much! I was not aware of this pattern.

pppaul17:12:48

clojure typically handles nil inputs to functions well. in the case of name it may be better that bad inputs throw, and in this case nil is a bad input. "nil" :nil (symbol nil) should be ok input. I can imagine the case where you have a map of keys you expect to be strings or keywords, and one of the keys is nil this is pretty common with output from group-by and maybe it makes sense in your case to have (name nil) => "nil" you can do this via the fnil function i believe.

👍 1
pppaul17:12:20

((fnil name "nil") nil)

Sakib16:12:57

I'm trying to build a personal blog site using Clojurescript. What would be some best practice to serve it? Could github page be an option?

practicalli-john18:12:31

I use GitHub pages for the https://practical.li/blog/ (using https://cryogenweb.org/) and all the books I've written. The main http://Practical.li page is a ClojureScript app created with figwheel and reagent, deployed to GitHub pages (using a GitHub actions workflow) If more dynamic storage should be needed, then GirHub pages for the build of ClojureScript code backed with https://firebase.google.com/ for dynamic state, e.g login account s, etc. (if GitHub pages is not enough)

❤️ 2
simongray17:12:59

If it's a static site, I would just use Caddy.

simongray17:12:40

If you need the backend to do something, any of the popular Clojure libs are fine. Personally, I like to use Pedestal (Jetty) and—as of late—Caddy as a reverse proxy (it used to be nginx).

JoshLemer18:12:26

Oh hey TIL you can use vectors instead of lists in ns macro clauses:

(ns foo
  [:require [...]
            [...]]
  [:import (...)])
I always thought it was weird that ns uses () with keyword verbs, since it is very unlike any other clojure code. It's usually always () with symbols, or [] with keywords, not () with keywords

👍 1
seancorfield18:12:31

Yeah, the elements just have to be sequential so you can use either vectors or lists. But idiomatically: https://stuartsierra.com/2016/clojure-how-to-ns.html

❤️ 1
jumar11:12:12

Btw. afaik neither Rich nor Alex agree with the argument for using () for imports.

seancorfield23:12:13

@U06BE1L6T Yeah, I think I've seen them both disagree with () there and if you look at modern code they've written, such as https://github.com/clojure/tools.deps/blob/master/src/main/clojure/clojure/tools/deps/extensions/maven.clj#L17-L28 it uses []. Although some of the older code in Clojure itself uses () -- even for require/refer/exclude/etc.

mister_m22:12:08

Can anyone point me to the full documentation of "directives" in a deps.edn file?

Bob B22:12:53

I think that deps.edn is technically open, so other tools could potentially get things from deps.edn that aren't used by the deps CLI itself, however I believe <https://clojure.org/reference/deps_and_cli#_deps_edn> should cover the things that would be most cromulent to clojure itself

mister_m22:12:50

That page omits a lot of specifics about what each directive really is doing or exactly what all the directives are.

Bob B22:12:15

can you provide an example of a directive that isn't covered?

mister_m22:12:52

I don't know what they all are

mister_m22:12:05

there's no exhaustive index (on that page)

mister_m22:12:48

I'm left to infer things like how :exec-args interacts with :exec-fn - or how :main-opts interacts with :exec-fn among other things

Bob B23:12:57

<https://clojure.org/reference/deps_and_cli#_arg_map_keys> mentions the exec ones being tied to -X (and based on the tool section, I guess -T by extension) and main-opts being tied to -M