This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-06
Channels
- # aleph (15)
- # announcements (2)
- # babashka (121)
- # beginners (62)
- # biff (6)
- # cherry (2)
- # cider (51)
- # clerk (30)
- # cljs-dev (5)
- # clojure (77)
- # clojure-austin (2)
- # clojure-europe (10)
- # clojure-germany (6)
- # clojure-nl (1)
- # clojure-norway (19)
- # clojure-romania (1)
- # clojure-uk (3)
- # clojurescript (16)
- # core-typed (7)
- # cursive (17)
- # datomic (12)
- # deps-new (11)
- # emacs (7)
- # events (2)
- # fulcro (5)
- # honeysql (2)
- # hyperfiddle (32)
- # introduce-yourself (1)
- # jobs-discuss (2)
- # membrane (18)
- # missionary (2)
- # music (5)
- # polylith (7)
- # reagent (26)
- # releases (5)
- # testing (32)
- # tools-build (14)
- # tools-deps (7)
- # xtdb (8)
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 :)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)])
Thank you