Created
May 25, 2015 16:00
-
-
Save arohner/d7a6bb057824c224b5b3 to your computer and use it in GitHub Desktop.
rudimentary core.typed datomic annotations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; Extremely incomplete type annotations for Datomic. | |
(ns foo.util.type.datomic | |
(:require [clojure.core.typed :as t] | |
[datomic.api :as d]) | |
(:import (datomic Connection | |
Database) | |
(datomic.db DbId) | |
(java.util Date UUID))) | |
(t/ann ^:no-check datomic.api/tempid [t/Keyword -> datomic.db.DbId]) | |
(t/defalias TxVal (t/U DbId t/AnyInteger String Boolean BigInteger Double BigDecimal Date UUID (Array byte))) | |
(t/defalias TxAttr t/Keyword) | |
(t/defalias TxVec (t/HVec [t/Keyword TxAttr TxVal])) ;; [:db/add e a v] | |
(t/defalias TxMap (t/Map TxAttr TxVal)) | |
(t/defalias TxDatom (t/U TxVec TxMap)) | |
(t/defalias TxData (t/Vec TxDatom)) | |
(t/ann ^:no-check datomic.api/db [Connection -> Database]) | |
(t/defalias TxResult (t/HMap :mandatory {})) | |
(t/ann ^:no-check datomic.api/transact [Connection TxData -> (t/Future TxResult)]) | |
(t/defalias PullPattern (t/Vec t/Any)) | |
(t/ann ^:no-check datomic.api/pull [Database PullPattern Long -> (t/Map TxAttr TxVal)]) | |
(t/defalias Query (t/Vec t/Any)) | |
(t/ann ^:no-check datomic.api/q [Query Database TxVal * -> t/Any]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!
In case it's of any interest, I've extended it ever so slightly.
Thanks again.