Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(ns doc.doc-diff
#+clj (:require [clojure.core.typed :as t])
#+cljs (:require-macros [cljs.core.typed :as t]))
(t/declare-datatypes 'Set-Attrs)
(t/declare-names 'Set-Attrs)
(t/declare-datatypes Set-Attrs)
(t/declare-names Set-Attrs)
(t/defalias Cmd (U Set-Attrs Set-Order Update-Child Swap-Child))
(t/defalias Cmds (t/Seqable Cmd))
(t/defalias Cmds-A (Atom1 Cmds))
(t/defalias Set-Attrs
(HMap :mandatory {:tag (Value :set-attrs!)
:old-attrs (t/Map Any Any)
:new-attrs (t/Map Any Any)}))
(t/defalias Set-Order
(HMap :mandatory {:tag (Value :set-order!)
:old-order (t/Seq Any)
:new-order (t/Seq Any)}))
(t/defalias Update-Child
(HMap :mandatory {:tag (Value :update-child!)
:cmds Cmds}))
(t/defalias Swap-Child
(HMap :mandatory {:tag (Value :swap-child!)
:new-tag Any
:cmds Cmds}))
(t/defn> atom-cons-cmd! :- Any
[atm :- Cmds-A
elem :- Cmd]
(swap! atm #(cons elem %)))
ERROR:
ExceptionInfo Type Checker: Found 1 error clojure.core/ex-info (core.clj:4327)
user=> (clojure.core.typed/check-ns 'doc.doc-diff)
Start collecting doc.doc-diff
Type Error (NO_SOURCE_FILE) Internal Error (doc/doc_diff.clj:10:1) Cannot resolve type: Set-Attrs
Hint: Is Set-Attrs in scope?
Hint: Has Set-Attrs's annotation been found via check-ns, cf or typed-deps?
ExceptionInfo Type Checker: Found 1 error clojure.core/ex-info (core.clj:4327)
user=>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment