Skip to content

Version 0.6.0

Latest
Compare
Choose a tag to compare
@coconutpalm coconutpalm released this 12 Apr 19:09
· 6 commits to main since this release

Summary

This release adds indexed, a small but useful feature for using RightTypes to create an in-memory database using Clojure. and fixes a few small bugs. Any breaking changes should be reported as bugs.

Indexed

Added indexed type constructor macro for constructing a map of maps, indexed by a some field in the maps. Here's some example usage, taken from the tests:

(def Person (T {:key keyword? :first-name string? :last-name string?}))
(def PersonDB (indexed Person :key)))

(tests
    "Happy path"
    (let [testee (PersonDB {:key :franken :first-name "Franken" :last-name "Stein"}
                           {:key :charlie :first-name "Charlie" :last-name "Brown"})]
      (-> testee :franken :last-name) := "Stein"
      (-> testee :charlie :last-name) := "Brown"))

(tests
    "Sadness: A field value fails type checking"
    (let [failure (PersonDB {:key :franken :first-name "Franken" :last-name :stein})]
      (-> failure :errors count)       := 1
      (-> failure :errors first :path) := '(:franken :last-name)
      (-> failure :errors first :msg)  := ":last-name:(:last-name string? :stein)"))

The failure messages could be improved somewhat, but I'm leaving that for a future release.

Bugs fixed

Just a bunch of small things. git log is your friend, if you care.