lasertag-logo https://github.com/paintparty/lasertag A library for categorizing values in Clojure dialects - v0.15.0 Works with Clojure, ClojureScript, and Babashka, and Jolt This library arose during development of the hifi printing engine used by https://github.com/paintparty/bling and https://github.com/paintparty/fireworks. Basic examples:
(require '[lasertag.core :refer [tag tag-map]])
(tag "hi") ; => :string
(tag :hi) ; => :keyword
(tag #"^hi$") ; => :regex
(tag true) ; => :boolean
(tag [1 2 3]) ; => :vector
(tag '(1 2 3)) ; => :seq
(tag (range 3)) ; => :seq
(tag 1) ; => :number
(tag 1.5) ; => :number
(tag ##Inf) ; => :number
;; tag-map returns a map with more info
(tag-map (range 3))
=>
{:tag :seq
:type clojure.lang.LongRange
:classname "clojure.lang.LongRange"
:category "collections"
:all-tags #{:seqable
:sequential
:coll
:deferred
:coll-like
:lazy
:seq
:list-like
:carries-meta
:range}}
https://github.com/paintparty/lasertag/blob/main/CHANGELOG.md highlights:
• New project logo, compliant with the https://www.lasermet.com/blog/laser-warning-labels-requirements-and-what-you-need-to-know-for-compliance/ for laser products
• More robust and refined primary and secondary tags for type categorization (see thread for details)
• Added canonical :category entry to tag-map result.
• Performance improvements - most values will return in 15 ~ 50 nanoseconds, depending on hardware
• Now works with Jolt:zap:
• More granular secondary tagging for subclasses of Number
• Significant refactoring and simplification of codebase
• Streamlined testing internals
More details in 🧵All primary tags:
[:agent
:array
:atom
:boolean
:char
:datetime
:delay
:function
:keyword
:list
:map
:nil
:number
:queue
:reader-conditional
:ref
:regex
:seq
:set
:string
:symbol
:throwable
:uuid
:var
:vector
:volatile]
All secondary tags (these show up in the :all-tags entry). Some are specific to respective platform (JVM, JS):
[:array-like
:associative
:big-decimal
:big-int
:byte
:callable
:carries-meta
:char-sequence
:coll
:coll-like
:cons
:def
:deferred
:double
:editable
:error
:exception
:float
:fractional
:generator
:global-this
:hash-map
:infinite
:infinity
:-infinity
:inst
:int
:iterable
:js
:lazy
:list-like
:long
:map-entry
:map-like
:multi-function
:named
:nan
:nat-int
:neg
:neg-int
:object
:pos
:pos-int
:promise
:range
:ratio
:real
:record
:reference
:scalar
:seqable
:sequential
:set-like
:short
:sorted
:stack
:subvec
:transient
:typed-array
:whole
:zero]
New canonical-categories . A value’s canonical category is based on its primary tag.
(def canonical-categories
{"scalars" #{:keyword :number :string :symbol :boolean :nil :char :uuid :regex}
"collections" #{:seq :map :vector :set :list :array :queue}
"functions" #{:function}
"temporal values" #{:datetime}
"identities" #{:volatile :atom :agent :ref :var :delay}
"pending values" #{:promise :future}
"throwables" #{:throwable}
"reflection" #{:reader-conditional}})