September 2020 Monthly Update
By Alyssa Parado
Here are the updates from our new projects.
Malli
September 1-15
Small improvements based on user feedback, finalized the EntrySchemas and drafted implementation for heterogeneous sequences, aka regex schemas.
Done stuff
- #212 merged in master, closing 2 other PRs and 3 Issues
- #251 transformation terms
- #250 api-docs for public api
- #116 all known issues for initial alpha are now resolved!
Ongoing
- #252
- adding support for lazy registries (supports pulling e.g.AWS CloudFormation Schemas in at runtime, when needed)
- lazy
:multi
impl - first class support for String Schema references
- spell-specking of
:multi
and:enum
values
;; given a lazy registry is provided, pulling the schemas when needed
(def Schema
[:multi {:dispatch :Type, :lazy true}
"AWS::ApiGateway::Stage"
"AWS::ApiGateway::UsagePlan"
"AWS::AppSync::ApiKey"])
(-> (m/explain
Schema
{:Type "AWS::AppSync::ApiKey"
:Descriptionz "kikka"})
(me/with-spell-checking)
(me/humanize))
; ...loaded "AWS::AppSync::ApiKey"
; => {:ApiId ["missing required key"]
; :Descriptionz ["should be spelled :Description"]}
(-> Schema
(m/explain
{:Type "AWS::ApiGatway::UsagePlan"
:Description "kikka"
:UsagePlanName "kukka"})
(me/with-spell-checking)
(me/humanize))
; => {:Type ["did you mean AWS::ApiGateway::UsagePlan"]}
- WIP: Heterogenous sequences, aka regex schemas. Studied implementation of clojure.spec, plumatic schema, seqexp and minimallist and drafted an initial clean slate impl. Validation and parsing mostly work, but lot of rough edges and explaining & generation not yet implemented. Kudos to Vincent Cantin for the initial work on this!
;; internal api
(re/parse
(re/* (re/cat [:prop (re/fn string?)]
[:val (re/alt [:s (re/fn string?)]
[:b (re/fn boolean?)])]))
["-server" "foo" "-verbose" true "-user" "joe"])
;[{:prop "-server", :val [:s "foo"]}
; {:prop "-verbose", :val [:b true]}
; {:prop "-user", :val [:s "joe"]}]
; malli with named branches
[:* [:cat*
[:prop string?]
[:val [:alt*
[:s string?]
[:b boolean?]]]]]
; malli with indexed branches
[:* [:cat string? [:alt string? boolean?]]]
Misc
All old issues for first alpha are now resolved. Will release it soon, without the regexs (take some time to finish)
September 16-30
Polishing the code, updated dependencies, updated libraries using malli, helped people on slack, though about time, lot’s of small improvements, curving out bundle size on js, added type-properties
, rewrote a lot of core code to use it, started to write alpha release blog post.
Done stuff
- kwrooijen/gungnir#31 - update & test Gugnir to use latest malli
- lambdaisland/regal#20 - update & test Regal to to use latest malli
- metosin/reitit#fbff819 - update & test Reitit to use latest malli
- #260 -
:map-of
keys should decode like String with JSON - #116 - just done
- #254 - easy way to attach custom errors to Schemas
- #253 - spell checking for :multi map dispatch keys
- #252 - lazy registries & multis
- #25 - support core predicates or just keyword types?
- #244 - won’t fix, too special case
Ongoing
-
Writing the alpha release post. Have found out many small inconsistencies and even bugs while writing sample code into the post, need to fix all of those to get the library & post out. Still, really happy how it’s all clicking together.
-
Designing how to support schemas for time and dates #49. There is
java.time
, on JS, Temporal is coming, but while waiting, we have tick and cljc.java-time, but they add a whopping 40-50kb gzipped to bundle size (currently, malli starts ~2kb gzipped). Good discussion about this in clojureverse. -
carving out js bundle size with great tooling & tips by Thomas Heller via slack. This could be done later, but is so much fun.
Misc
Thought releasing a library was easy, but want to do it too(?) right, seems to take time more than expected. Had a flu.
Practicalli
September 1-15
Invested time to understand the changes coming to the Clojure CLI tools and understand the opportunities that Clojure exec (:exec-fn
& :exec-args
) brings to aliases. These changes provided a catalyst to start redesigning the aliases used in practicalli/clojure-deps-edn.
Practicalli Study Group
Continuing the Banking on Clojure project, especially around database access. The database schema was refined along with improved approaches to creating database schema, using transactional updates and ensuring connections are closed. The next.jdbc friendly functions were explored and a CRUD approach implemented.
- 082 - Banking On Clojure - Part3 - next.jdbc for SQL in Clojure
- 083 - Banking On Clojure - Part4 - Updating data in the database
Next steps will be to use Clojure spec for generative testing with the database, add connection pooling and using lifecycle management libraries.
Practicalli WebApps
Updated sections on H2 Database and Banking on Clojure
- Design and Create Database Tables
- Defining Database Queries - different approaches
- Create database records
- Read Database Records
- Update Records in the database
- Delete Records in the database
Practicalli Clojure
Added core principles for writing effective unit tests in Clojure. Included project configuration examples of unit tests for Leiningen and Clojure CLI tools. Also included example configuration for Emacs CIDER test runner and link to the test runner configurations in practicalli/clojure-deps-edn.
Clojure deps.edn
Created a draft guide to changes in the next release of the Clojure CLI tools, to understand the significance of the changes it introduces. The -X
flag for executing a function with EDN arguments (hash-map arguments) has already been introduced and the new release depreciates the generic -A
alias in favor of -M
. In the long term using the -X
flag with functions that take a structured argument looks to be an excellent approach.
Started a redesign of practicalli/clojure-deps-edn using qualified keywords for alias names. The Library repositories keyword, :mvn/repos
, is already qualified, so this redesign brings the aliases in line with that style. The alias keywords are prepended with names to communicate the category of purpose for each alias, e.g. repl, project, env, lib, inspect, build, deploy.
As part of the redesign, the new flags introduced with Clojure CLI tools, -M
and -X
, are used. The -X
flag is the preferred Clojure command line flag to use for the aliases, where the library supports executing a function from the library that takes a hash-map of arguments. Otherwise -M
flag replaces -A
flag and continues to use clojure.main
to call the -main
function of the given main namespace.
Add project/check to give detailed report on compilation issues for a project
Practicalli Spacemacs
Resolved simple bug fixes raised by the community.
September 16-30
Practicalli Study Group
Continuing the Live broadcasts covering the development of the Banking on Clojure web application.
- 084 - Banking On Clojure - Part5 - Generated database records from clojure.spec
- 085 - Banking On Clojure - Part6 - Refactor database schema, specs and namespaces
Practicalli Clojure
New sections and Pages:
Added Code Challenges section, covering the Clojure challenges available in 4Clojure.com, Exercism.io, CodwWars.com, ClojureScript Koans and Advent of Code. A quick guide to using each of the Code challenge websites was provided and tips to using them effectively. GitHub code repositories for the Practicalli 4Clojure guides, codewars-guides and exercism-guides were included, along with the 4Clojure guides video playlist which walks through the solution to over 60 challenges and different approaches to solving them. Several 4Clojure and Exercism challenges have been added as solution walk-through, showing the design thinking behind the solution in the website. More of these will be converted from the solution code repositories as time allows, along with a video showing the REPL driven development experience.
Added Unit testing fixtures page with examples from Banking on Clojure project. Also mentioned test selectors as a way to organize slower fixtures.
Started creating project templates for use with clj-new, to create deps.edn projects useful for beginners and experienced developers alike. A section on writing your own custom templates will be added to the Practicalli Clojure book in October.
Continuing to create scripts for video screencasts for a series on the Clojure CLI tools, covering the usage from the latest release (1.10.1.697). The series will convey the developer experience and common practices.
Continue testing Clojure CLI pre-release and enhancing the aliases in practicalli/clojure-deps-edn, no issues found so far.
Clojure WebApps
Redesign the database schema and clojure.spec specifications to simplify the use of generative testing with specifications and in general make the specifications easier to work with.
Using generative testing with the database. Specifications are used to generate random data to test the database CRUD functions, validating the results of those functions against clojure specs.
Added code to create and delete the development database which is called from fixture functions within the handler-helper-test namespace. The tests now run successfully via the CircleCI service.
Using kaocha profiles to configure different behavior in the development environment and when running on the CI server, specifically file change watcher and test output.
Practicalli Spacemacs
Now Emacs 27 is the default, trying out Ligature support in Emacs. Added the unicode layer with variables to include ligatures. Initially switching to the Fira code font which contains a wide range of ligatures in the font already.
Will try the Ligaturizer project to add Fira Code ligatures to the Ubuntu Mono font, the preferred font used by Practicalli.
Clj-kondo/babashka/sci
September 1-15
Here is an overview of the work I did per project. In the last two weeks I spent most of my time focusing on a new release for clj-kondo.
Clj-kondo
-
Add
--parallel
option to lint sources in parallel. This will speed up linting an entire classpath. #632, #972 -
Fix false positive type warning with
into
and custom transducer #952 -
Recognize aliases in quoted keywords #981 e
-
Support ignore hints #872:
(inc 1 2 3) ^--- clojure.core/inc is called with 3 args but expects 1 #_:clj-kondo/ignore (inc 1 2 3) ^--- arity warning ignored #_{:clj-kondo/ignore[:invalid-arity]} (do (inc 1 2 3)) ^--- only redundant do is reported, but invalid arity is ignored
Also see config.md.
-
Merge config from
$HOME/.config/clj-kondo
, respectingXDG_CONFIG_HOME
. See config.md for details. #992 -
New
:config-paths
option in<project>/.clj-kondo/config.edn
. This allows extra configuration directories to be merged in. See config.md for details. -
Config tool that can spit out library specific configurations that can be added via
:config-paths
. Contributions for libraries are welcome. -
Clj-kondo inspector, a POC of inspecting Clojure specs and turning them into clj-kondo type annotations.
-
Rum hooks for
defc
anddefcs
now support multi-arity definitions #987
Babashka
- Made differences with Clojure on the JVM clearer in README
- Investigate inclusion of http-kit client #561
- Investigate inclusion of http-kit server #556
- Bumped clj-yaml to 0.7.2 #562
- Reported bug and implemented patch for test.check related to GraalVM native-image TCHECK-157
- Error when using
use
#565
Sci
- Experimented with faster loop implementation #394
- Hammock time: controlling number of iterations or execution time length #348
- Hammock time: resolving external macro namespaces #397
- Throw when trying to re-define referred var #398
- Fix libsci, an example of how to use sci as a shared native library (https://github.com/borkdude/sci/commit/d0b10f25bbbd6b09fb5c4ac99cf9887d33115845)
September 16-30
Here is an overview of the work I did per project. Most of the time went into improvements to sci and a new babashka release.
Babashka
- Include
org.httpkit.client
, a high performance async http client #561 - Include
org.httpkit.server
, an HTTP server #556. This namespace should be considered experimental and may stay or be removed in a future version of babashka, depending on feedback from the community. See example - Add
java.io.FileNotFoundException
,java.security.DigestInputStream
,java.nio.file.FileVisitOption
classes - Support implementing
IDeref
,IAtom
andIAtom2
on records sci#401 - Support compatibility with version-clj #565 @lread and @borkdude
- Support YAML roundtrip through
*input*
#583 - Support
clojure.core/find-var
sci#420 @RickMoynihan - Fix location printing in REPL (
--repl
) #598 - Babashka.curl sends form params incorrectly as multipart babashka.curl#25
- Update Windows build instructions #574
- Set minimum macOS version in build explicitly #588
- Fix NPE in error handling logic #587
- Fix namespace switch in REPL (
--repl
) #564 - Fix location of errors in REPL (
--repl
) #589 - https://github.com/borkdude/babashka/issues/571
Sci
-
Expose
parse-string
,reader
,parse-next
andeval-form
#404 -
Namespace dependency tree example
-
Support multi-arity methods in
defprotocol
sci#406 -
Constructor call not recognized in protocol impl sci#419
-
Improve handling of top-level do in macro expansion sci#421
-
Throw when trying to redefine referred var sci#398
-
Xterm-sci: https://github.com/babashka/xterm-sci
-
Eval single quote ' should return eof https://github.com/borkdude/edamame/issues/61
-
Fix import from hyphened namespace https://github.com/borkdude/sci/issues/410
Misc
- dynaload 0.2.0, 0.2.1 and 0.2.2: https://github.com/borkdude/dynaload#graalvm
- https://clojure.atlassian.net/browse/CLJ-2582
Datahike
September 1-15
Due to vacation in our team we could only work on the implementation of entity specs.
Entity Specs
The required attributes and entity predicates were implemented, added to Datahike 0.3.2-SNAPSHOT
, and will be release with Datahike 0.3.2. Users can now create new specs with :db.entity/attrs
and :db.entity/preds
and assert entities in transactions with :db/ensure
.
Beyond implementation, we cleaned out older stale branches and PRs. Also we started planning our next feature roadmap after 0.3.2
release.
September 16-30
Everybody is back from vacation now and we continued working together again on the open topics.
Release 0.3.2
We released our latest version 0.3.2 that added entity specs that were implemented in Datahike in the last iteration as well as the following updates that we worked on over the last months:
- fixed hash computation
- improved printer
- fixed history upsert
- added database name to environ
- added circle ci orbs for ci/cd across all libraries
- fixed reverse schema update
- added automatic releases
- added benchmark utility
- extended time variance test
- updated dependencies
- adjusted documentation
Datomic Compatibility
Within our comparison project we created a document on comparing functions from both Datahike and Datomic, and continued discussing adjustments both for signature and naming. Also we started adjusting our API documentation in order to provide better examples on how to use them.
Tuple Support
The schema definition for composite tuples was added to the transaction validation, while the definition for heterogeneous and homogeneous tuples are still drafted and tested. We started discussing the design and architecture for the search of the tuples in Datahike’s index for both read and write schema flexibility.
Beyond Clojurists Together Tasks
Within the task of porting of our own dependencies to ClojureScript, we unified the CI/CD for circleci, moving from leiningen to Clojure CLI tools. Continued with improving the upsert performance. We started discussions on features and next steps for datahike-server and possible http clients. Worked on garbage collection for our backend. Continued on the larger tasks for attribute reference support and partitions that also incorporates vast refactoring of Datahike’s tests.