-
Notifications
You must be signed in to change notification settings - Fork 0
/
specs-types-and-namespaces.html
103 lines (94 loc) · 2.97 KB
/
specs-types-and-namespaces.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!DOCTYPE html>
<html lang="en-us">
<head>
<!-- Static Metadata -->
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="icon" href="data:"/>
<meta property="og:type" content="article"/>
<meta name="twitter:card" content="summary"/>
<!-- Metadata about me -->
<meta name="twitter:site" content="@souenzzo"/>
<meta name="twitter:creator" content="@souenzzo"/>
<meta name="author" content="Enzzo Cavallo">
<!-- Title metadata -->
<title>Spec, types and namespaces</title>
<meta name="twitter:title" content="Spec, types and namespaces"/>
<meta property="og:title" content="Spec, types and namespaces"/>
<!-- Description metadata -->
<meta name="twitter:description"
content="DRAFT"/>
<meta name="Description"
content="DRAFT"/>
<meta name="description"
content="DRAFT">
<meta property="og:description"
content="DRAFT"/>
<!-- https://jrl.ninja/etc/1 -->
<style>
section {
max-width: 38em;
padding: 1em;
margin: auto;
}
aside {
background-color: lightcyan;
padding: 1em;
}
code {
color: darkred;
}
pre {
color: darkred;
}
</style>
</head>
<body>
<pre>
## DRAFT ##
```clojure
(ns myApp.account
(:require [clojure.spec.alpha :as s]
[clojure.string :as string]))
(s/def ::firstName string?)
(s/def ::lastName string?)
(s/def ::pronoun string?)
(defn fullName
[{::keys [firstName lastName]}]
(string/join " " [firstName lastName]))
(s/fdef fullName
:args (s/cat :account (s/keys :req [::firstName ::lastName]))
:ref string?)
(defn greet
[{::keys [firstName pronoun]}]
(string/join " " [pronoun firstName]))
(s/fdef greet
:args (s/cat :account (s/keys :req [::firstName ::pronoun]))
:ref string?)
```
```java-like
package myApp;
class account {
String firstName;
String lastName;
String pronoun;
String fullName() {
return " ".join(firstName, lastName)
}
String greet() {
return " ".join(pronoun, firstName)
}
}
```
Both codes are saying:
- Exists a field, named `myApp.account.firstName` that should be a string
- Exists a field, named `myApp.account.lastName` that should be a string
- Exists a field, named `myApp.account.pronoun` that should be a string
- Exists a method, named `myApp.account.fullName` that within a context containing
`myApp.account.firstName` and `myApp.account.lastName`, will return a string.
- Exists a method, named `myApp.account.greet` that within a context containing
`myApp.account.firstName` and `myApp.account.pronoun`, will return a string.
Many java-like force you to aways thing about "a group of fields", that is usually called a "class"
</pre>
</body>
</html>