Fork me on GitHub
#beginners
<
2020-08-13
>
hoopes01:08:58

using plumatic schema, is it possible to extend a schema? If you have BaseSchema , can i have ChildSchema1 and ChildSchema2 extend BaseSchema, and add values on to it?

noisesmith01:08:45

you can use a map from key to validator as a schema, and if you do that you can make a new schema using assoc or merge

noisesmith01:08:14

most people have migrated from schema to spec.alpha (where deriving schemas works much differently)

hoopes01:08:29

yeah, but there really appears to be a dearth of compojure-api examples with spec. schema (so far) is really quite a bit easier to deal with.

hoopes01:08:45

i will take another look at it, though

nate03:08:08

@ we use schema quite a bit, and use https://github.com/metosin/schema-tools, which has merge, assoc, etc functions for combining and modifying schemas

hoopes20:08:01

howwwwwwwwwww did i miss that - i use schema-tools too

nate21:08:16

👍 glad to help

sova18:08:22

(apply brain problems)

neil.hansen.3118:08:14

Does anyone have any tips for reading/cleaning up runtime error messages in Chrome DevTools? This is the kind of thing I see with pretty much every error. I've highlighted the only line that contains a reference to my own source code.

dpsutton18:08:15

these seem quite easy to read? - no cofx handler registered for last-time - no subscription for :viewing-project - no way to deref null at views.cljs at line 123

neil.hansen.3118:08:21

Part of me wants to be able to turn off any references to files that I didn't write myself. It feels "below my layer of abstraction" to be looking at references to code in the cljs runtime.

neil.hansen.3119:08:09

Thanks @dpsutton, I personally find it quite frustrating compared to errors in other languages like Python and Elm... particularly when there are multiple runtime errors and the DevTools console literally explodes with them. I also wish I could somehow see these errors in Emacs/CIDER instead of having to constantly change focus to the DevTools panel when something doesn't look right in the my web app.

neil.hansen.3119:08:27

But if this looks normal to you, I'll get used it. I was wondering I was doing something wrong with configuring source maps or something.

noisesmith19:08:35

a benefit but also a price of clj / cljs is being "close to the host", that leads to leaked abstractions but it also leads to a lot of power

smith.adriane19:08:28

it would certainly be possible to improve tooling like emacs/cider to include the errors in the editor, but I think it's generally been easier to make UI in the browser than in emacs/cider.

neil.hansen.3120:08:45

I'm thinking about introducing spec into my workflow to help pinpoint the simplest errors I make (usually passing the wrong type into a function that expects a map or sequence, etc). Where should a total beginner start with spec? Is Spec2 best practice?

seancorfield21:08:38

Spec 2 isn't ready for use yet (it will ultimately become just clojure.spec) so clojure.spec.alpha is "best practice" for now.

seancorfield21:08:11

That said, Spec 2's wiki https://github.com/clojure/spec-alpha2/wiki/Differences-from-spec.alpha and https://github.com/clojure/spec-alpha2/wiki/Schema-and-select are good reading insofar as understanding how thinking around Spec has evolved and where it is going.

seancorfield21:08:33

You may find this blog post helpful for insight into the various ways that Spec can help you @neil.hansen.31 https://corfield.org/blog/2019/09/13/using-spec/

seancorfield21:08:27

And the official documentation: https://clojure.org/about/spec (rationale) and https://clojure.org/guides/spec (guide).

seancorfield21:08:08

One thing I will say as a caution: Spec is not a type system and you'll find it hard work if you try to use it like one. It's great for checking things at boundaries, such as APIs, but it's not really intended to be used "everywhere" (i.e., on every function).

neil.hansen.3121:08:24

Thanks so much @seancorfield!

lpan21:08:13

Hey folks, I am looking at the guide on https://clojurescript.org/guides/promise-interop. As shown below, I am wondering why (.close browser) doesn't get wrapped with . Thanks!

drewverlee22:08:30

Because regardless of the what happens in try, we want to close the browser next.

karol.wojcik12:08:34

Clojurescript docs are wrong in that particular case. There should be <p!. Promise should be resolved to value. Otherwise you have Promise which is wrapped by chan.