Fork me on GitHub
#malli
<
2023-01-11
>
Carlo13:01:34

I have a question on the workflow - I need to check my understanding; ideally I would just put a (dev/start! {:report (pretty/reporter)}) inside my user.clj so that it's executed at startup time. But, if I understand correctly that only start instrumentation for the currently loaded modules (of which there's none at the time of user.clj execution). A workflow that works is loading some ns, then go back and dev/start! again, but is there a workaround that also keeps track of the loaded modules?

ikitommi14:01:11

Also interested in better ways to do this. You could hook it into integrant/etc workflow or make a shortcut for running that. Best would be if the would follow the new Var registration itself, tried that once, but got dirty quick. Ideas most welcome.

Carlo15:01:38

Thank you, I agree that morally this should belong to a hook on var interning, but I did not know that was possbile at all. What would be the entry point for that?

pithyless16:01:55

My understanding was that would instrument new namespaces correctly, assuming that one used m/=> and not eg. via metadata on defn.

Carlo17:01:01

@U05476190 there doesn't seem to be a difference between m/=> and metadata for this, do you have an example in mind?

Noah Bogart15:01:00

I'm struggling to get decoding working correctly. I want to transform a string timestamp to a clj-time instant: #clj-time/date-time "2023-01-11T15:14:48.964Z". (Yes, I know clj-time is deprecated lol). Do I have to define a custom schema for this?

Ben Sless18:01:51

Yes You can look at how the time schemas are implemented

Noah Bogart18:01:54

Oh, did those get merged? I remember seeing your PR but didn't follow closely. They've not been released yet, right?

Ben Sless18:01:32

merged but not released

Ben Sless18:01:44

if you're on deps you can enjoy them right now

Noah Bogart18:01:24

Sadly, we're using leiningen 😭

Noah Bogart18:01:32

I'll look at the code on master tho, thanks

escherize18:01:36

Am I doing something wrong here? I thought these would be using the same schema underneath. Maybe I was mistaken

[(m/validate [:double {:min 1}] -1.0)
 (m/validate [double? {:min 1}] -1.0)]
;; => [false true]

ikitommi18:01:26

predicate schemas double? don’t read any properties like real schemas :double. As this is a common cause of confusion, options to fix: 1. drop support for predicate schemas, kinda extra anyways 2. map predicate schemas into real schemas 3. finish “schema of schemas” to describe allowed properties so the latter would give a warning in… dev-mode

2️⃣ 2
3️⃣ 2
escherize19:01:45

You mentioned something about not needed to define a describe multimethod for both 'integer? :integer. Is that related to 2.? It seems better to have a single schema for both. I can’t see any downsides.

escherize19:01:19

I think the only way it would break is if you had [double? {:min 1}], and it was being ignored. Which a) never happened b) is wrong anyway.

ikitommi20:01:00

1️⃣ :registry property

[:schema {:registry {"ConsCell" [:maybe [:tuple :int [:ref "ConsCell"]]]}}
 "ConsCell"]
2️⃣ :let schema
[:let ["ConsCell" [:maybe [:tuple :int [:ref "ConsCell"]]]]
 "ConsCell"]

escherize18:01:32

:let is clearer, But :registry has the benefit of restricting shadowing / duplicate schema refs