core-typed

Corneliu Hoffman 2023-10-06T09:13:59.242869Z

Hi, Rather newbie here Working my way through typed closure trying to build a small typed DSL. Wondering about the use of t/Merge. It seems to not work with polymorphic types. I kind of expected to be able to define:

(t/ann mapmerge (t/All [a b] [ a [a -> b] -> (t/Merge a b)]))
(defn mapmerge [a f] (merge a (f a)))
I get
No implementation of method: :fold-default* of protocol: #'typed.cljc.checker.fold-rep/IFoldDefault found for class: typed.cljc.checker.type_rep.MergeType
Is a variation of this possible? It seems that if a or b are not maps presumably t/Merge seems to revert to t/Any so presumably this is safe. I can write a macro of course but I was hoping for a more out-of-the-box solution :)

2023-10-09T19:53:02.192269Z

I think this was fixed in 1.1.0 or 1.1.3. Are you using the latest version?

2023-10-09T20:23:30.652729Z

Well, the error is fixed, but the inference doesn't work. I'll try and fix it.

2023-10-09T20:50:02.340779Z

fixed it, will push a new version

2023-10-09T20:52:03.746249Z

You'll need to use bounded type variables to get it to work:

(t/All [[a :< (t/Nilable (t/Map t/Any t/Any))]
        [b :< (t/Nilable (t/Map t/Any t/Any))]]
       [a [a :-> b] :-> (t/Merge a b)])

2023-10-09T22:08:11.568999Z

released 1.1.4 with this fix

Corneliu Hoffman 2023-10-10T06:01:29.888859Z

Thank you