Skip to content

Commit

Permalink
version 4-alpha3: revising list of kinds, refactoring the creation of…
Browse files Browse the repository at this point in the history
… kinds using a macro
  • Loading branch information
daslu committed Sep 8, 2023
1 parent 8dacbfd commit ce5afb9
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 59 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).

## [4-alpha3] - 2023-09-08
- revising list of kinds
- refactorin the creation of kinds using a macro

## [4-alpha2] - 2023-09-01
- adding kinds

Expand Down
2 changes: 1 addition & 1 deletion build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[org.corfield.build :as bb]))

(def lib 'org.scicloj/kindly)
(def version "4-alpha2")
(def version "4-alpha3")
#_ ; alternatively, use MAJOR.MINOR.COMMITS:
(def version (format "1.0.%s" (b/git-count-revs nil)))

Expand Down
20 changes: 15 additions & 5 deletions src/scicloj/kindly/v4/fn.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@
(attach-kind-to-value [value] kind)))

(defn kind-as-a-fn [kind]
(fn
([]
kind)
([value]
(attach-kind-to-value value kind))))
(let [kind-kw (->> kind
name
(keyword "kind"))]
(fn
([]
kind-kw)
([value]
(attach-kind-to-value value kind-kw)))))

(defmacro defkinds [& kind-symbols]
(->> kind-symbols
(map (fn [s]
`(def ~s
(kind-as-a-fn (quote ~s)))))
(cons 'do)))
87 changes: 34 additions & 53 deletions src/scicloj/kindly/v4/kind.cljc
Original file line number Diff line number Diff line change
@@ -1,56 +1,37 @@
(ns scicloj.kindly.v4.kind
(:require [scicloj.kindly.v4.fn :as fn]))

(def hidden
(fn/kind-as-a-fn :kind/hidden))

(def pprint
(fn/kind-as-a-fn :kind/pprint))

(def println
(fn/kind-as-a-fn :kind/println))

(def test
(fn/kind-as-a-fn :kind/test))

(def var
(fn/kind-as-a-fn :kind/var))

(def map
(fn/kind-as-a-fn :kind/map))

(def set
(fn/kind-as-a-fn :kind/set))

(def vector
(fn/kind-as-a-fn :kind/vector))

(def seq
(fn/kind-as-a-fn :kind/seq))

(def table
(fn/kind-as-a-fn :kind/table))

(def md
(fn/kind-as-a-fn :kind/md))

(def code
(fn/kind-as-a-fn :kind/code))

(def hiccup
(fn/kind-as-a-fn :kind/hiccup))

(def reagent
(fn/kind-as-a-fn :kind/reagent))

(def vega
(fn/kind-as-a-fn :kind/vega))

(def vega-lite
(fn/kind-as-a-fn :kind/vega-lite))

(def cytoscape
(fn/kind-as-a-fn :kind/cytoscape))

(def echarts
(fn/kind-as-a-fn :kind/echarts))
(fn/defkinds

;; simple behaviours
pprint
hidden

;; web dev
hiccup
reagent

;; data visualization formats
md
code
vega
vega-lite
echarts
cytoscape

;; specific types
image
dataset

;; clojure specific
var
test

;; plain structures
seq
vector
set
map

;; other recursive structures
table)

0 comments on commit ce5afb9

Please sign in to comment.