Skip to content

Commit 87279a8

Browse files
committed
UNIFY-3: Refined docstrings and added browseable API docs.
1 parent 03359fe commit 87279a8

8 files changed

Lines changed: 228 additions & 118 deletions

File tree

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ org.clojure/core.unify {:mvn/version "0.7.2"}
4141
<version>0.7.2</version>
4242
</dependency>
4343

44+
Usage
45+
=====
4446

45-
46-
Example Usage
47-
========================================
47+
Refer to docstrings in the `clojure.core.unify` namespace or browseable API documentation in docs/API.md.
4848

4949
```clojure
5050
(use 'clojure.core.unify)
@@ -55,17 +55,20 @@ Example Usage
5555
;=> ((?a * 5 ** 2) + (4 * 5) + 3)
5656
```
5757

58-
Refer to docstrings in the `clojure.core.unify` namespace.
59-
60-
61-
6258
Developer Information
6359
========================================
6460

6561
* [GitHub project](https://github.com/clojure/core.unify)
6662
* [Bug Tracker](https://clojure.atlassian.net/browse/UNIFY)
6763
* [Continuous Integration](https://github.com/clojure/core.unify/actions/workflows/test.yml)
6864

65+
Running the tests at the command line against multiple CLJ versions:
66+
67+
./run-tests.sh
68+
69+
To generate the current API docs run the following:
70+
71+
clj -Tquickdoc quickdoc '{:outfile "docs/API.md", :github/repo "https://github.com/clojure/core.unify", :git/branch "master", :toc false}'
6972

7073
Change Log
7174
====================

docs/API.md

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
2+
-----
3+
# <a name="clojure.core.unify">clojure.core.unify</a>
4+
5+
6+
A unification library for Clojure.
7+
8+
9+
10+
11+
## <a name="clojure.core.unify/extract-lvars">`extract-lvars`</a><a name="clojure.core.unify/extract-lvars"></a>
12+
``` clojure
13+
14+
(extract-lvars form)
15+
(extract-lvars lv-fn form)
16+
```
17+
18+
Takes a datastructure form and returns a distinct set of the logical
19+
variables found within. By default, the lvar? predicate is used to detect nested
20+
lvars, but the function also accepts a custom predciate lv-fn to use instead.
21+
<p><sub><a href="https://github.com/clojure/core.unify/blob/master/src/main/clojure/clojure/core/unify.cljc#L25-L35">Source</a></sub></p>
22+
23+
## <a name="clojure.core.unify/flatten-bindings">`flatten-bindings`</a><a name="clojure.core.unify/flatten-bindings"></a>
24+
``` clojure
25+
26+
(flatten-bindings binds)
27+
(flatten-bindings variable? binds)
28+
```
29+
30+
Flattens recursive bindings in binds to the same ground, if possible.
31+
If a variable cannot be resolved then it is left in place.
32+
<p><sub><a href="https://github.com/clojure/core.unify/blob/master/src/main/clojure/clojure/core/unify.cljc#L136-L147">Source</a></sub></p>
33+
34+
## <a name="clojure.core.unify/ignore-variable?">`ignore-variable?`</a><a name="clojure.core.unify/ignore-variable?"></a>
35+
``` clojure
36+
37+
(ignore-variable? sym)
38+
```
39+
<p><sub><a href="https://github.com/clojure/core.unify/blob/master/src/main/clojure/clojure/core/unify.cljc#L16-L16">Source</a></sub></p>
40+
41+
## <a name="clojure.core.unify/lvar?">`lvar?`</a><a name="clojure.core.unify/lvar?"></a>
42+
``` clojure
43+
44+
(lvar? %1)
45+
```
46+
47+
Returns true if a symbol represents a core.unify lvar.
48+
By default, core.unify expects a symbol starting with ? or just _.
49+
<p><sub><a href="https://github.com/clojure/core.unify/blob/master/src/main/clojure/clojure/core/unify.cljc#L20-L23">Source</a></sub></p>
50+
51+
## <a name="clojure.core.unify/make-occurs-subst-fn">`make-occurs-subst-fn`</a><a name="clojure.core.unify/make-occurs-subst-fn"></a>
52+
``` clojure
53+
54+
(make-occurs-subst-fn variable-fn)
55+
```
56+
57+
Given a function to recognize logic variables, returns a function that
58+
will attempt to substitute unification bindings between two expressions.
59+
This function uses an 'occurs check' to detect cycles.
60+
<p><sub><a href="https://github.com/clojure/core.unify/blob/master/src/main/clojure/clojure/core/unify.cljc#L180-L185">Source</a></sub></p>
61+
62+
## <a name="clojure.core.unify/make-occurs-unifier-fn">`make-occurs-unifier-fn`</a><a name="clojure.core.unify/make-occurs-unifier-fn"></a>
63+
``` clojure
64+
65+
(make-occurs-unifier-fn variable-fn)
66+
```
67+
68+
Given a function to recognize logic variables, returns a function to
69+
perform the unification of two expressions. This function uses an 'occurs check'
70+
to detect cycles.
71+
<p><sub><a href="https://github.com/clojure/core.unify/blob/master/src/main/clojure/clojure/core/unify.cljc#L187-L192">Source</a></sub></p>
72+
73+
## <a name="clojure.core.unify/make-occurs-unify-fn">`make-occurs-unify-fn`</a><a name="clojure.core.unify/make-occurs-unify-fn"></a>
74+
``` clojure
75+
76+
(make-occurs-unify-fn variable-fn)
77+
```
78+
79+
Given a function to recognize logic variables, returns a function to
80+
return a bindings map for two expressions. This function uses an 'occurs check'
81+
to detect cycles.
82+
<p><sub><a href="https://github.com/clojure/core.unify/blob/master/src/main/clojure/clojure/core/unify.cljc#L171-L178">Source</a></sub></p>
83+
84+
## <a name="clojure.core.unify/make-subst-fn">`make-subst-fn`</a><a name="clojure.core.unify/make-subst-fn"></a>
85+
``` clojure
86+
87+
(make-subst-fn variable-fn)
88+
```
89+
90+
Given a function to recognize unification variables, returns a function that
91+
will attempt to substitute unification bindings between two expressions
92+
without an 'occurs check'.
93+
<p><sub><a href="https://github.com/clojure/core.unify/blob/master/src/main/clojure/clojure/core/unify.cljc#L220-L225">Source</a></sub></p>
94+
95+
## <a name="clojure.core.unify/make-unifier-fn">`make-unifier-fn`</a><a name="clojure.core.unify/make-unifier-fn"></a>
96+
``` clojure
97+
98+
(make-unifier-fn variable-fn)
99+
```
100+
101+
Given a function to recognize unification variables, returns a function to
102+
perform the unification of two expressions without an 'occurs check'.
103+
<p><sub><a href="https://github.com/clojure/core.unify/blob/master/src/main/clojure/clojure/core/unify.cljc#L227-L235">Source</a></sub></p>
104+
105+
## <a name="clojure.core.unify/make-unify-fn">`make-unify-fn`</a><a name="clojure.core.unify/make-unify-fn"></a>
106+
``` clojure
107+
108+
(make-unify-fn variable-fn)
109+
```
110+
111+
Given a function to recognize unification variables, returns a function to
112+
return a bindings map for two expressions without an 'occurs check'.
113+
<p><sub><a href="https://github.com/clojure/core.unify/blob/master/src/main/clojure/clojure/core/unify.cljc#L212-L218">Source</a></sub></p>
114+
115+
## <a name="clojure.core.unify/subst">`subst`</a><a name="clojure.core.unify/subst"></a>
116+
``` clojure
117+
118+
(subst expression bindings)
119+
```
120+
121+
Attempts to substitute the logic variables within an expression with their mapped values in bindings.
122+
<p><sub><a href="https://github.com/clojure/core.unify/blob/master/src/main/clojure/clojure/core/unify.cljc#L201-L203">Source</a></sub></p>
123+
124+
## <a name="clojure.core.unify/unifier">`unifier`</a><a name="clojure.core.unify/unifier"></a>
125+
``` clojure
126+
127+
(unifier expression1 expression2)
128+
```
129+
130+
Attempts the entire unification process from garnering the bindings to substituting
131+
the appropriate bindings, using an 'occurs check'.
132+
<p><sub><a href="https://github.com/clojure/core.unify/blob/master/src/main/clojure/clojure/core/unify.cljc#L205-L208">Source</a></sub></p>
133+
134+
## <a name="clojure.core.unify/unifier-">`unifier-`</a><a name="clojure.core.unify/unifier-"></a>
135+
``` clojure
136+
137+
(unifier- expression1 expression2)
138+
```
139+
140+
Attempts the entire unification process from garnering the bindings to substituting
141+
the appropriate bindings. This function is not guranteed to terminate if cyclic logic variables
142+
are present.
143+
<p><sub><a href="https://github.com/clojure/core.unify/blob/master/src/main/clojure/clojure/core/unify.cljc#L244-L248">Source</a></sub></p>
144+
145+
## <a name="clojure.core.unify/unify">`unify`</a><a name="clojure.core.unify/unify"></a>
146+
``` clojure
147+
148+
(unify expression1 expression2)
149+
```
150+
151+
Attempts to unify x and y with the given bindings (if any). May return a map of the
152+
unifiers (bindings) found. Will throw if an 'occurs check' determines that the expressions contain
153+
cyclic bindings or if the sub-expressions clash.
154+
<p><sub><a href="https://github.com/clojure/core.unify/blob/master/src/main/clojure/clojure/core/unify.cljc#L195-L199">Source</a></sub></p>
155+
156+
## <a name="clojure.core.unify/unify-">`unify-`</a><a name="clojure.core.unify/unify-"></a>
157+
``` clojure
158+
159+
(unify- expression1 expression2)
160+
```
161+
162+
Attempt to unify x and y with the given bindings (if any). May return a map of the
163+
unifiers (bindings) found. Will throw if the sub-expressions clash. This function is not guranteed
164+
to terminate if cyclic logic variables are present.
165+
<p><sub><a href="https://github.com/clojure/core.unify/blob/master/src/main/clojure/clojure/core/unify.cljc#L237-L241">Source</a></sub></p>
166+
167+
## <a name="clojure.core.unify/wildcard?">`wildcard?`</a><a name="clojure.core.unify/wildcard?"></a>
168+
``` clojure
169+
170+
(wildcard? form)
171+
```
172+
173+
Returns true if form starts with a core.unify wildcard. By default, core.unify expects the symbol &.
174+
<p><sub><a href="https://github.com/clojure/core.unify/blob/master/src/main/clojure/clojure/core/unify.cljc#L108-L112">Source</a></sub></p>

docs/Building.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,4 @@ To test that the build succeeded try:
1111

1212
mvn clojure:repl
1313

14-
This will launch a Clojure REPL. Try the following to exercise core.unify:
15-
16-
```clojure
17-
:TODO
18-
```
19-
20-
TODO
14+
This will launch a Clojure REPL.

docs/Including.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

docs/README.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

docs/Using.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)