Clojure development environment by Vagrant

May 13, 2019

If you want to have a portable Clojure development environment and you use Vagrant, vim-fireplace, you may consider to try my Vagrantfile.

git clone https://github.com/humorless/dotfiles
cd dotfiles
vagrant up
Continue reading →

Using Datomic in my app

April 27, 2019

The background of this post

I began to use Datomic seriously in my project at work from February 2019. Now, it is time to write down certain experience. When I just began, I found a lot of documents talking about how to use Datomic. However, I still found certain points worth to mention from my project.

Continue reading →

REPL tips

March 30, 2019

從今年 2 月開始,接了一個公司內部應用軟體的專案開發,我用 clojure + luminus + datomic 來實作。不知不覺也就每天寫 clojure 的 REPL 近兩個月了。每天玩 REPL 之後,很快就發現一些過去我用 REPL 的盲點。

沒有善用 clojure.repl/pprint

Continue reading →

dependency injection with Clojure

July 12, 2017

寫 clojure 的時候,雖然套用了 REPL-driven development 的開發方式,已經相對可以讓大多數的函數很快地做過測試。但是,隨著要開發的專案愈來愈大,還是一樣需要用標準的寫法來寫單元測試 (unit test) 。有一個非正規的統計,如果是 Ruby on Rail 的專案,一般而言,90% 的函數都是有副作用的。然而, clojure 語言的專案,往往只有 40% 的函數帶有副作用。

即使是寫 clojure 語言,還是會遇到有 side effect 的函數,那比較好的寫法是怎麼樣呢?

Continue reading →

groupby

May 21, 2017

一開始是我在寫 4clojure 的練習題的時候,寫到了一個題目,要重新實現 clojure 語言的 groupby 函數。我糾結了好一陣子,又查了不少資料,才勉強用 reduce 寫出來。然而,最近卻在工作中,用上了 groupby 。

(fn f [k coll]
  (reduce
    (fn [c v]
      (update-in c [(k v)] (fnil conj []) v))
    {} coll))

Continue reading →