~statianzo/sevenlangs

1da98880a03e311ffbe1997475e82c2f9809944e — Jason Staten 2 years ago b26bfc8
implement what type via protocols
1 files changed, 26 insertions(+), 1 deletions(-)

M clojure/src/one/core.cljs
M clojure/src/one/core.cljs => clojure/src/one/core.cljs +26 -1
@@ 8,4 8,29 @@
    (list? xs) :list
    (vector? xs) :vector
    (map? xs) :map
    (set? xs) :set))
\ No newline at end of file
    (set? xs) :set))

;; Protocols!
(defprotocol WhatType
  "Tells what type"
  (what-type [w]))

(extend-type
 cljs.core/PersistentVector
  WhatType
  (what-type [w] :vector))

(extend-type
 cljs.core/PersistentArrayMap
  WhatType
  (what-type [w] :map))

(extend-type
 cljs.core/PersistentHashSet
  WhatType
  (what-type [w] :set))

(extend-type
 cljs.core/List
  WhatType
  (what-type [w] :list))
\ No newline at end of file