Skip to content

Commit 158b64c

Browse files
committed
Add definition search transcripts
1 parent f5364c5 commit 158b64c

10 files changed

+520
-8
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ docker/tmp
1515
*.prof
1616
*.prof.html
1717
prelude.output.md
18+
19+
# Scratch files
20+
*.u

transcripts/run-transcripts.zsh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ source "$(realpath "$(dirname "$0")")/transcript_helpers.sh"
1111

1212
typeset -A transcripts
1313
transcripts=(
14+
search transcripts/share-apis/search/
1415
users transcripts/share-apis/users/
1516
contribution-diffs transcripts/share-apis/contribution-diffs/
1617
definition-diffs transcripts/share-apis/definition-diffs/
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
{
2+
"body": {
3+
"results": [
4+
{
5+
"branchRef": "releases/1.2.3",
6+
"definition": {
7+
"displayName": "List.map",
8+
"hash": "#53u6nne5tneggsh2ngr76khq4kfdpvuf4l7kv6sq39kr9hjvh3qg4midcc5b69qhjlfii3io7pe2rn1on7rr6h76qsmjbc66n2ivpeo",
9+
"summary": {
10+
"contents": [
11+
{
12+
"annotation": null,
13+
"segment": "("
14+
},
15+
{
16+
"annotation": {
17+
"tag": "Var"
18+
},
19+
"segment": "a"
20+
},
21+
{
22+
"annotation": null,
23+
"segment": " "
24+
},
25+
{
26+
"annotation": {
27+
"tag": "TypeOperator"
28+
},
29+
"segment": "->"
30+
},
31+
{
32+
"annotation": {
33+
"tag": "AbilityBraces"
34+
},
35+
"segment": "{"
36+
},
37+
{
38+
"annotation": {
39+
"tag": "Var"
40+
},
41+
"segment": "g"
42+
},
43+
{
44+
"annotation": {
45+
"tag": "AbilityBraces"
46+
},
47+
"segment": "}"
48+
},
49+
{
50+
"annotation": null,
51+
"segment": " "
52+
},
53+
{
54+
"annotation": {
55+
"tag": "Var"
56+
},
57+
"segment": "b"
58+
},
59+
{
60+
"annotation": null,
61+
"segment": ")"
62+
},
63+
{
64+
"annotation": null,
65+
"segment": " "
66+
},
67+
{
68+
"annotation": {
69+
"tag": "TypeOperator"
70+
},
71+
"segment": "->"
72+
},
73+
{
74+
"annotation": null,
75+
"segment": " "
76+
},
77+
{
78+
"annotation": {
79+
"contents": "#22ffou62u91ks8av7bdmhq10jct5ulot40c84j0k3kfdrh5rj2o6a3ditsfpo6sv6mkde2p13um06mkrsdckudmeh6k4oa7v53887f8",
80+
"tag": "TypeReference"
81+
},
82+
"segment": "List"
83+
},
84+
{
85+
"annotation": null,
86+
"segment": " "
87+
},
88+
{
89+
"annotation": {
90+
"tag": "Var"
91+
},
92+
"segment": "a"
93+
},
94+
{
95+
"annotation": null,
96+
"segment": " "
97+
},
98+
{
99+
"annotation": {
100+
"tag": "TypeOperator"
101+
},
102+
"segment": "->"
103+
},
104+
{
105+
"annotation": {
106+
"tag": "AbilityBraces"
107+
},
108+
"segment": "{"
109+
},
110+
{
111+
"annotation": {
112+
"tag": "Var"
113+
},
114+
"segment": "g"
115+
},
116+
{
117+
"annotation": {
118+
"tag": "AbilityBraces"
119+
},
120+
"segment": "}"
121+
},
122+
{
123+
"annotation": null,
124+
"segment": " "
125+
},
126+
{
127+
"annotation": {
128+
"contents": "#22ffou62u91ks8av7bdmhq10jct5ulot40c84j0k3kfdrh5rj2o6a3ditsfpo6sv6mkde2p13um06mkrsdckudmeh6k4oa7v53887f8",
129+
"tag": "TypeReference"
130+
},
131+
"segment": "List"
132+
},
133+
{
134+
"annotation": null,
135+
"segment": " "
136+
},
137+
{
138+
"annotation": {
139+
"tag": "Var"
140+
},
141+
"segment": "b"
142+
}
143+
],
144+
"tag": "UserObject"
145+
},
146+
"tag": "Plain"
147+
},
148+
"fqn": "List.map",
149+
"kind": "term",
150+
"projectRef": "@transcripts/search"
151+
}
152+
]
153+
},
154+
"status": [
155+
{
156+
"status_code": 200
157+
}
158+
]
159+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"body": {
3+
"causalHashSquashed": "#ih4vtflqotqkapjcmcfsbn7ohs94rp5mr4lo4tddlbja0hf6n0bp964dbqumfli49jbvu40uu9i3257aq406kt3v0nt6jrei9ajf9j0",
4+
"causalHashUnsquashed": "#ih4vtflqotqkapjcmcfsbn7ohs94rp5mr4lo4tddlbja0hf6n0bp964dbqumfli49jbvu40uu9i3257aq406kt3v0nt6jrei9ajf9j0",
5+
"createdAt": "<TIMESTAMP>",
6+
"createdBy": "@transcripts",
7+
"projectRef": "@transcripts/search",
8+
"status": {
9+
"publishedAt": "<TIMESTAMP>",
10+
"publishedBy": "@transcripts",
11+
"status": "published"
12+
},
13+
"updatedAt": "<TIMESTAMP>",
14+
"version": "1.2.3"
15+
},
16+
"status": [
17+
{
18+
"status_code": 201
19+
}
20+
]
21+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"body": [
3+
{
4+
"tag": "plain",
5+
"token": "function.const"
6+
}
7+
],
8+
"status": [
9+
{
10+
"status_code": 200
11+
}
12+
]
13+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"body": [
3+
{
4+
"tag": "plain",
5+
"token": "function.const"
6+
},
7+
{
8+
"tag": "data-constructor",
9+
"token": "List.Cons"
10+
}
11+
],
12+
"status": [
13+
{
14+
"status_code": 200
15+
}
16+
]
17+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
```unison
2+
structural type List a = Nil | Cons a (List a)
3+
4+
function.const : a -> b -> a
5+
function.const a b = a
6+
7+
structural ability Throw e where
8+
throw : e -> a
9+
10+
List.map : (a -> {g} b) -> List a -> {g} List b
11+
List.map f = cases
12+
(Cons a rest) -> Cons (f a) (List.map f rest)
13+
Nil -> Nil
14+
```
15+
16+
17+
```ucm
18+
scratch/main> add
19+
scratch/main> push @transcripts/search/main
20+
```

transcripts/share-apis/search/run.zsh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env zsh
2+
3+
set -e
4+
source ../../transcript_helpers.sh
5+
6+
# Reset DB to a known state
7+
pg_reset_fixtures
8+
9+
login_user_for_ucm 'transcripts'
10+
transcript_ucm transcript prelude.md
11+
12+
echo 'get-causal-hash'
13+
causalHash="$(fetch_data "$transcript_user" GET 'get-causal-hash' '/users/transcripts/projects/search/branches/main/browse' 2>/dev/null | jq -r '.namespaceListingHash')"
14+
15+
echo 'create-release'
16+
# Create a release so it will be indexed
17+
fetch "$transcript_user" POST create-release '/users/transcripts/projects/search/releases' "{
18+
\"causalHash\": \"${causalHash}\",
19+
\"major\": 1,
20+
\"minor\": 2,
21+
\"patch\": 3
22+
}"
23+
24+
echo 'check-indexed'
25+
# We have to wait for it to be indexed
26+
for i in {1..10}; do
27+
if fetch_data "$transcript_user" GET 'check-indexed' '/search-names?query=const' | jq -e '(. | length) > 0' 2>/dev/null >/dev/null; then
28+
echo 'Found definition search results, continuing...';
29+
break;
30+
# If we're on the last iteration fail the transcript
31+
elif [[ "$i" -ge 10 ]] then
32+
echo 'Failed to find any definition search results before timeout.';
33+
exit 1;
34+
fi
35+
sleep 3;
36+
done
37+
38+
# Name searches
39+
fetch "$transcript_user" GET 'name-search-suffix' '/search-names?query=const'
40+
fetch "$transcript_user" GET 'name-search-prefix' '/search-names?query=Func'
41+
42+
# Type searches
43+
# "b -> a -> a"
44+
fetch "$transcript_user" GET 'type-var-search' '/search-definitions?query=b%20-%3E%20a%20-%3E%20a'
45+
46+
# (a -> b) -> List a -> List b
47+
fetch "$transcript_user" GET 'complex-type-mention-search' '/search-definitions?query=(a%20-%3E%20b)%20-%3E%20List%20a%20-%3E%20List%20b'

0 commit comments

Comments
 (0)