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 :)I think this was fixed in 1.1.0 or 1.1.3. Are you using the latest version?
Well, the error is fixed, but the inference doesn't work. I'll try and fix it.
fixed it, will push a new version
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)])
released 1.1.4 with this fix
Thank you