                       spins)]
     d-sym))
 
+(defprotocol DSymbolSource
+  (dsymbol [_]))
+
+(extend-type String
+  DSymbolSource
+  (dsymbol [code] (ds-from-str code)))
+
+(extend-type DSymbol
+  DSymbolSource
+  (dsymbol [ds] ds))
+
+(extend-type DelaneySymbol
+  DSymbolSource
+  (dsymbol [ds] (ds-from-ds ds)))
+
 ;; === Building a Java DSymbol instance from a Clojure one
 
 (defn java-dsymbol [ds]

          ds
          (range (count spins))))

(defmethod dsymbol String [code]
  (let [parts (-> code s/trim
                (s/replace #"^<" "") (s/replace #">$" "") (s/split #":"))
        [dims gluings spins] (vec (if (re-matches #"\d+\.\d+" (first parts))

      (print-simple code w))))


;; === Factories for DSymbol instances

(defn- parse-numbers [str]
  (when (and str (< 0 (count (s/trim str))))
