|
|
|
|
|
by weavejester
1455 days ago
|
|
siknad and uryga give good replies on dependent types and TypeScript's structural typing. There's also an experimental static typing system for Clojure that allows for typing of maps: (defalias NamedMap
(HMap :mandatory {:first-name Str, :last-name Str}))
(ann full-name [NamedMap -> Str])
(defn full-name [{:keys [first-name last-name]}]
(str first-name " " last-name))
If you can determine some subset of the keys of a map at compile type, then you can type check it to some degree. |
|