Skip to content

Commit 919e97f

Browse files
committed
Merge branch 'main' of github.com:active-group/active-clojure
2 parents b9f4ccc + 6f60983 commit 919e97f

File tree

3 files changed

+48
-38
lines changed

3 files changed

+48
-38
lines changed

.github/workflows/clojure.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: ci
2-
on: [push]
2+
on: [push, workflow_dispatch]
33

44
jobs:
55
test:

README.md

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
# Active Clojure
22

3+
## Breaking changes in recent releases
4+
35
A library with various basic utilities for programming with Clojure.
46

57
[![Clojars Project](https://img.shields.io/clojars/v/de.active-group/active-clojure.svg)](https://clojars.org/de.active-group/active-clojure)
68
[![Actions Status](https://github.com/active-group/active-clojure/workflows/ci/badge.svg)](https://github.com/active-group/active-clojure/actions)
79
[![cljdoc badge](https://cljdoc.org/badge/de.active-group/active-clojure)](https://cljdoc.org/d/de.active-group/active-clojure/CURRENT)
810

9-
### Breaking changes in version `0.40.0`
11+
### `0.40.0`
1012

1113
- `active.clojure.monad/run-monadic-swiss-army` was renamed to
1214
`active.clojure.monad/run-monadic`.
1315

14-
### Breaking changes in version `0.38`
16+
### `0.38`
1517

1618
- For an RTD record `MyRecord`, `(MyRecord :meta)` will no longer
1719
return a meta data map. Use `(meta #'MyRecord)` instead.
1820

19-
### Breaking changes since version `0.28.0`
21+
### Since `0.28.0`
2022

2123
- Clojure version 1.9.0 or higher and Clojurescript version 1.9.542 or higher
2224
are required.
@@ -35,9 +37,8 @@ A library with various basic utilities for programming with Clojure.
3537

3638
### Records
3739

38-
The `active.clojure.record` namespace implements a
39-
`define-record-type` form similar to Scheme's [SRFI
40-
9](http://srfi.schemers.org/srfi-9/).
40+
The `active.clojure.record` namespace implements a `define-record-type` form
41+
similar to Scheme's [SRFI 9](http://srfi.schemers.org/srfi-9/).
4142

4243
Example: A card consists of a number and a color
4344

@@ -63,8 +64,6 @@ Example: A card consists of a number and a color
6364
;; => false
6465
```
6566

66-
### Options
67-
6867
You can provide additional options in an option-map as second argument to `define-record-type`.
6968

7069
#### Specs
@@ -128,42 +127,39 @@ provided for the selector functions:
128127

129128
#### Non generative option
130129

131-
If you provide a value (uid) to the `nongenerative` option,
132-
the record-creation operation is nongenerative i.e.,
133-
a new record type is created only if no previous call to
134-
`define-record-type ` was made with the uid.
135-
Otherwise, an error is thrown.
136-
If uid is `true`, a uuid is created automatically.
137-
If this option is not given (or value is falsy),
138-
the record-creation operation is generative, i.e.,
139-
a new record type is created even if a previous call
140-
to `define-record-type` was made with the same arguments.
130+
If you provide a value (uid) to the `nongenerative` option, the record-creation
131+
operation is nongenerative i.e., a new record type is created only if no
132+
previous call to `define-record-type ` was made with the uid. Otherwise, an
133+
error is thrown. If uid is `true`, a uuid is created automatically. If this
134+
option is not given (or value is falsy), the record-creation operation is
135+
generative, i.e., a new record type is created even if a previous call to
136+
`define-record-type` was made with the same arguments.
141137

142138
#### Arrow constructor
143139

144140
Default is `true`.
145141

146-
If you provide the key:val pair `:arrow-constructor?`:`false`,
147-
the creation of the arrow-constructor of the `defrecord` call is omitted,
148-
i.e.
142+
If you provide the key:val pair `:arrow-constructor?`:`false`, the creation of
143+
the arrow constructor of the `defrecord` call is omitted, i.e.
149144

150145
```clojure
151146
(define-record-type Test {:arrow-constructor? false} (make-test a) ...)
152147
```
153-
won't yield a function `->Test`.
148+
149+
won't create a function `->Test`.
154150

155151
#### Map protocol
156152

157153
Default is `true`.
158154

159-
If you don't want your records to implement the Map-protocols (in *Clojure*
155+
If you don't want your records to implement the Map protocols (in *Clojure*
160156
these are `java.util.Map` and `clojure.lang.IPersistentMap`, in *ClojureScript*
161157
`IMap` and `IAssociative`), you can provide the key:val pair
162158
`:map-protocol?`:`false` to the options map.
163159

164160
#### Remove default interfaces/protocols
165161

166-
There are a number of interfaces, that our records defaultly implement (like
162+
There are a number of interfaces, that our records implement by default (like
167163
e.g. aforementioned `java.util.Map`). Providing key:val pair
168164
`:remove-interfaces`:`[interface1 interface2 ...]` will prevent the
169165
implementations of the given interfaces.

src/active/clojure/dynj.clj

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,40 @@
11
(ns active.clojure.dynj
2-
"Thin layer over dynamic vars for implicit dependency injection. Dynjs
3-
can be used to have better control over side effects, to abstract
4-
over different possible interpretations of an aspect of a program or
5-
to make things easier for testing.
2+
"Thin layer over dynamic vars for implicit dependency injection. *Dynjs* can be
3+
used to have better control over side effects, to abstract over different
4+
possible interpretations of an aspect of a program or to make things easier
5+
for testing.
66
7-
Main usage patterns:
7+
### Example
8+
9+
First we declare a *dynj* named `eff`, which expects a single argument.
810
911
```
1012
(declare-dynj eff [a])
13+
```
14+
15+
Note that `eff` itself can already be called, but it's \"abstract\" in the
16+
sense that without a bound implementation/interpreter, it cannot do anything.
17+
Hence the following will throw an exception:
18+
19+
```
20+
(eff 2)
21+
```
1122
12-
(defn foo []
23+
Let's say `foo` is a usage site of `eff`. (Of course, calling `foo` now will
24+
still throw the same exception as above.)
25+
26+
```
27+
(defn foo [s]
1328
(assert (= 4 (eff 2))))
14-
15-
(defn square [a] (* a a))
29+
```
1630
17-
(foo) ;; => throws exception
18-
19-
(binding [eff square]
20-
(foo))
31+
With `binding` we can interpret `eff` as, say, a `square` function locally.
2132
22-
((with-bindings* {#'eff square} foo))
33+
```
34+
(defn square [a] (* a a))
2335
36+
(binding [eff square]
37+
(foo)) ;; => this works now
2438
```
2539
"
2640
(:refer-clojure :rename {bound-fn* clj-bound-fn*

0 commit comments

Comments
 (0)