1
1
(define-library
2
- (scmindex domain)
3
- (import (scheme base)
4
- (scheme read)
5
- (scheme write))
6
- (export
7
-
8
- make-search-result
9
- search-result?
10
- search-result-items
11
- search-result-total
12
- search-result-libs
13
- search-result-params
14
- search-result-tags
15
- search-result-returns
16
-
17
- make-search-result-facet
18
- search-result-facet?
19
- search-result-facet-value
20
- search-result-facet-count
21
-
22
- make-func
23
- func?
24
- func-lib
25
- func-name
26
- func-param-names
27
- func-signature
28
- func-param-signatures
29
- func-syntax-param-signatures
30
- func-tags
31
- func-param-types
32
- func-return-types
33
- func-supertypes
34
-
35
- func->json
36
- json->func
37
- search-result->json
38
- )
39
- (begin
2
+ (scmindex domain)
3
+ (import (scheme base)
4
+ (scheme read)
5
+ (scheme write))
6
+ (export
7
+
8
+ make-search-result
9
+ search-result?
10
+ search-result-items
11
+ search-result-total
12
+ search-result-libs
13
+ search-result-params
14
+ search-result-tags
15
+ search-result-returns
16
+
17
+ make-search-result-facet
18
+ search-result-facet?
19
+ search-result-facet-value
20
+ search-result-facet-count
21
+
22
+ make-func
23
+ func?
24
+ func-lib
25
+ func-name
26
+ func-param-names
27
+ func-signature
28
+ func-param-signatures
29
+ func-syntax-param-signatures
30
+ func-tags
31
+ func-param-types
32
+ func-return-types
33
+ func-supertypes
34
+
35
+ func->json
36
+ json->func
37
+ search-result->json)
38
+
39
+ (begin
40
40
41
41
(define-record-type <scmindex-function>
42
- (make-func
43
- lib
44
- name
45
- param-names
46
- signature
47
- param-signatures
48
- syntax-param-signatures
49
- tags
50
- param-types
51
- return-types
52
- supertypes)
53
-
54
- func?
55
-
56
- (lib func-lib)
57
- (name func-name)
58
- (param-names func-param-names)
59
- (signature func-signature)
60
- (param-signatures func-param-signatures)
61
- (syntax-param-signatures func-syntax-param-signatures)
62
- (tags func-tags)
63
- (param-types func-param-types)
64
- (return-types func-return-types)
65
- (supertypes func-supertypes))
42
+ (make-func
43
+ lib
44
+ name
45
+ param-names
46
+ signature
47
+ param-signatures
48
+ syntax-param-signatures
49
+ tags
50
+ param-types
51
+ return-types
52
+ supertypes)
53
+
54
+ func?
55
+
56
+ (lib func-lib)
57
+ (name func-name)
58
+ (param-names func-param-names)
59
+ (signature func-signature)
60
+ (param-signatures func-param-signatures)
61
+ (syntax-param-signatures func-syntax-param-signatures)
62
+ (tags func-tags)
63
+ (param-types func-param-types)
64
+ (return-types func-return-types)
65
+ (supertypes func-supertypes))
66
66
67
67
; ;TODO move to util?
68
68
(define (->string obj)
71
71
(get-output-string port))
72
72
73
73
(define (read* str )
74
- (define port (open-input-string str))
75
- (read port))
74
+ (define port (open-input-string str))
75
+ (read port))
76
76
77
77
(define (func->json func )
78
78
`((lib . ,(->string (func-lib func)))
81
81
(signature . ,(->string (func-signature func)))
82
82
(param_signatures . ,(->string (func-param-signatures func)))
83
83
(syntax_param_signatures . ,(->string (func-syntax-param-signatures func)))
84
- (tags . ,(list->vector (map ->string (func-tags func))))
85
- (param_types . ,(list->vector (map ->string (func-param-types func))))
86
- (return_types . ,(list->vector (map ->string (func-return-types func))))
87
- (super_types . ,(list->vector (map ->string (func-supertypes func))))))
84
+ (tags . ,(list->vector (map symbol ->string (func-tags func))))
85
+ (param_types . ,(list->vector (map symbol ->string (func-param-types func))))
86
+ (return_types . ,(list->vector (map symbol ->string (func-return-types func))))
87
+ (super_types . ,(list->vector (map symbol ->string (func-supertypes func))))))
88
88
89
89
(define (json->func json )
90
- (define (get field type default )
91
- (cond
92
- ((assoc field json) =>
93
- (lambda (value )
94
- (case type
95
- ((sexpr) (read* (cdr value)))
96
- ((symbol) (string->symbol (cdr value)))
97
- ((symbol-lst) (map string->symbol (vector->list (cdr value))))
98
- (else (cdr value)))))
99
- (else default)))
100
- (make-func
101
- (get 'lib 'sexpr #f )
102
- (get 'name 'symbol #f )
103
- (get 'param_names 'symbol-lst '() )
104
- (get 'signature 'sexpr #f )
105
- (get 'param_signatures 'sexpr '() )
106
- (get 'syntax_param_signatures 'sexpr '() )
107
- (get 'tags 'symbol-lst '() )
108
- (get 'param_types 'symbol-lst '() )
109
- (get 'return_types 'symbol-lst '() )
110
- (get 'supertypes 'symbol-lst '() )))
90
+ (define (get field type default )
91
+ (cond
92
+ ((assoc field json) =>
93
+ (lambda (value )
94
+ (case type
95
+ ((sexpr) (read* (cdr value)))
96
+ ((symbol) (string->symbol (cdr value)))
97
+ ((symbol-lst) (map string->symbol (vector->list (cdr value))))
98
+ (else (cdr value)))))
99
+ (else default)))
100
+ (make-func
101
+ (get 'lib 'sexpr #f )
102
+ (get 'name 'symbol #f )
103
+ (get 'param_names 'symbol-lst '() )
104
+ (get 'signature 'sexpr #f )
105
+ (get 'param_signatures 'sexpr '() )
106
+ (get 'syntax_param_signatures 'sexpr '() )
107
+ (get 'tags 'symbol-lst '() )
108
+ (get 'param_types 'symbol-lst '() )
109
+ (get 'return_types 'symbol-lst '() )
110
+ (get 'supertypes 'symbol-lst '() )))
111
111
112
112
(define-record-type <search-result>
113
- (make-search-result items total libs params tags returns)
114
- search-result?
115
- (items search-result-items)
116
- (total search-result-total)
117
- (libs search-result-libs)
118
- (params search-result-params)
119
- (tags search-result-tags)
120
- (returns search-result-returns))
113
+ (make-search-result items total libs params tags returns)
114
+ search-result?
115
+ (items search-result-items)
116
+ (total search-result-total)
117
+ (libs search-result-libs)
118
+ (params search-result-params)
119
+ (tags search-result-tags)
120
+ (returns search-result-returns))
121
121
122
122
(define-record-type <search-result-facet>
123
- (make-search-result-facet value count)
124
- search-result-facet?
125
- (value search-result-facet-value)
126
- (count search-result-facet-count))
123
+ (make-search-result-facet value count)
124
+ search-result-facet?
125
+ (value search-result-facet-value)
126
+ (count search-result-facet-count))
127
127
128
128
(define (search-result->json sr )
129
- `((items . ,(list->vector (map func->json (search-result-items sr))))
130
- (total . ,(search-result-total sr))
131
- (libs . ,(list->vector (map search-result-facet->json (search-result-libs sr))))
132
- (params . ,(list->vector (map search-result-facet->json (search-result-params sr))))
133
- (returns . ,(list->vector (map search-result-facet->json (search-result-returns sr))))
134
- (tags . ,(list->vector (map search-result-facet->json (search-result-tags sr))))))
129
+ `((items . ,(list->vector (map func->json (search-result-items sr))))
130
+ (total . ,(search-result-total sr))
131
+ (libs . ,(list->vector (map search-result-facet->json (search-result-libs sr))))
132
+ (params . ,(list->vector (map search-result-facet->json (search-result-params sr))))
133
+ (returns . ,(list->vector (map search-result-facet->json (search-result-returns sr))))
134
+ (tags . ,(list->vector (map search-result-facet->json (search-result-tags sr))))))
135
135
136
136
(define (search-result-facet->json f )
137
- `((value . ,(->string ( search-result-facet-value f) ))
138
- (count . ,(search-result-facet-count f))))
137
+ `((value . ,(search-result-facet-value f))
138
+ (count . ,(search-result-facet-count f))))
139
139
140
- ))
140
+ ))
0 commit comments