Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
cloogle.org
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cloogle
cloogle.org
Commits
8394d109
Verified
Commit
8394d109
authored
Jan 30, 2017
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve
#67
parent
48782ad1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
19 deletions
+34
-19
backend/Cache.icl
backend/Cache.icl
+1
-1
backend/Cloogle.dcl
backend/Cloogle.dcl
+2
-1
backend/Cloogle.icl
backend/Cloogle.icl
+10
-1
backend/CloogleServer.icl
backend/CloogleServer.icl
+21
-16
No files found.
backend/Cache.icl
View file @
8394d109
...
...
@@ -29,7 +29,7 @@ toCacheFile t = (</>) (cache_dir t) o cacheKey
readCache
::
!
a
*
World
->
(
Maybe
b
,
!*
World
)
|
toString
a
&
JSONDecode
{|*|}
b
readCache
k
w
#
(
files
,
w
)
=
seqList
[
appFst
error2mb
o
readFile
(
toCacheFile
t
k
)
\\
t
<-
cache_types
]
w
=
(
join
o
fmap
(
fromJSON
o
fromString
)
$
foldl
(<|>)
empty
files
,
w
)
=
(
join
$
fromJSON
<$>
fromString
<$>
foldl
(<|>)
empty
files
,
w
)
writeCache
::
CacheType
!
a
!
b
->
*
World
->
*
World
|
toString
a
&
JSONEncode
{|*|}
b
writeCache
t
k
v
=
snd
o
writeFile
(
toCacheFile
t
k
)
(
toString
$
toJSON
v
)
backend/Cloogle.dcl
View file @
8394d109
...
...
@@ -84,9 +84,10 @@ derive JSONDecode Request, Response, Result, ShortClassResult, BasicResult,
FunctionResultExtras
,
TypeResultExtras
,
ClassResultExtras
,
MacroResultExtras
instance
zero
Request
instance
zero
Response
instance
toString
Response
instance
toString
Request
instance
toString
Response
instance
fromString
(
Maybe
Request
)
...
...
backend/Cloogle.icl
View file @
8394d109
...
...
@@ -20,8 +20,17 @@ where
,
page
=
Nothing
}
instance
toString
Response
where
toString
r
=
toString
(
toJSON
r
)
+
"
\n
"
instance
zero
Response
where
zero
=
{
return
=
0
,
msg
=
"Success"
,
data
=
[]
,
more_available
=
Nothing
,
suggestions
=
Nothing
}
instance
toString
Request
where
toString
r
=
toString
$
toJSON
r
instance
toString
Response
where
toString
r
=
toString
(
toJSON
r
)
+
"
\n
"
instance
fromString
(
Maybe
Request
)
where
fromString
s
=
fromJSON
$
fromString
s
...
...
backend/CloogleServer.icl
View file @
8394d109
...
...
@@ -8,7 +8,7 @@ import StdOrdList
import
StdOverloaded
import
StdString
import
StdTuple
from
StdFunc
import
o
,
flip
,
const
from
StdFunc
import
o
,
flip
,
const
,
seq
from
StdMisc
import
abort
from
TCPIP
import
::
IPAddress
,
::
Port
,
instance
toString
IPAddress
...
...
@@ -59,7 +59,7 @@ toRequestCacheKey r =
,
c_typeName
=
r
.
typeName
,
c_modules
=
sort
<$>
r
.
modules
,
c_libraries
=
appFst
sort
<$>
r
.
libraries
,
c_page
=
r
.
page
,
c_page
=
r
.
page
<|>
Just
0
}
Start
w
...
...
@@ -86,7 +86,7 @@ where
#
(
mbResponse
,
w
)
=
readCache
key
w
|
isJust
mbResponse
#
r
=
fromJust
mbResponse
=
({
r
&
return
=
if
(
r
.
return
==
0
)
1
r
.
return
},
cacheKey
request
,
w
)
=
({
r
&
return
=
if
(
r
.
return
==
0
)
1
r
.
return
},
cacheKey
key
,
w
)
|
isJust
name
&&
size
(
fromJust
name
)
>
40
=
respond
(
err
CLOOGLE_E_INVALIDNAME
"Function name too long"
)
w
|
isJust
name
&&
any
isSpace
(
fromString
$
fromJust
name
)
...
...
@@ -99,22 +99,27 @@ where
#
more
=
max
0
(
length
results
-
MAX_RESULTS
)
// Suggestions
#
mbType
=
unify
>>=
parseType
o
fromString
#
suggestions
=
mbType
>>=
flip
(
suggs
name
)
db
#
w
=
seq
[
cachePages
(
toRequestCacheKey
req
)
CACHE_PREFETCH
0
zero
suggs
\\
(
req
,
suggs
)
<-
mb2list
suggestions
]
w
with
mb2list
Nothing
=
[];
mb2list
(
Just
xs
)
=
xs
#
suggestions
=
sortBy
(\
a
b
->
snd
a
>
snd
b
)
<$>
filter
((<)(
length
results
)
o
snd
)
<$>
(
mbType
>>=
\
t
->
suggs
name
t
db
)
filter
((<)
(
length
results
)
o
snd
)
<$>
map
(
appSnd
length
)
<$>
suggestions
#
(
results
,
nextpages
)
=
splitAt
MAX_RESULTS
results
// Response
#
response
=
if
(
isEmpty
results
)
(
err
CLOOGLE_E_NORESULTS
"No results"
)
{
return
=
0
,
msg
=
"Success"
,
data
=
results
{
zero
&
data
=
results
,
more_available
=
Just
more
,
suggestions
=
suggestions
}
// Save page prefetches
#
w
=
cachePages
CACHE_PREFETCH
1
response
nextpages
w
#
w
=
cachePages
key
CACHE_PREFETCH
1
response
nextpages
w
// Save cache file
=
respond
response
w
where
...
...
@@ -123,12 +128,12 @@ where
respond
::
Response
*
World
->
*(
Response
,
CacheKey
,
*
World
)
respond
r
w
=
(
r
,
cacheKey
key
,
writeCache
LongTerm
key
r
w
)
cachePages
::
Int
Int
Response
[
Result
]
*
World
->
*
World
cachePages
_
_
_
[]
w
=
w
cachePages
0
_
_
_
w
=
w
cachePages
npages
i
response
results
w
cachePages
::
RequestCacheKey
Int
Int
Response
[
Result
]
*
World
->
*
World
cachePages
key
_
_
_
[]
w
=
w
cachePages
key
0
_
_
_
w
=
w
cachePages
key
npages
i
response
results
w
#
w
=
writeCache
Brief
req`
resp`
w
=
cachePages
(
npages
-
1
)
(
i
+
1
)
response
keep
w
=
cachePages
key
(
npages
-
1
)
(
i
+
1
)
response
keep
w
where
req`
=
{
key
&
c_page
=
((+)
i
)
<$>
(
key
.
c_page
<|>
pure
0
)
}
resp`
=
...
...
@@ -138,12 +143,12 @@ where
}
(
give
,
keep
)
=
splitAt
MAX_RESULTS
results
suggs
::
!(
Maybe
String
)
!
Type
!
TypeDB
->
Maybe
[(
Request
,
Int
)]
suggs
::
!(
Maybe
String
)
!
Type
!
TypeDB
->
Maybe
[(
Request
,
[
Result
]
)]
suggs
n
(
Func
is
r
cc
)
db
|
length
is
<
3
=
Just
[
let
t`
=
concat
$
print
False
$
Func
is`
r
cc
in
let
request
=
{
zero
&
name
=
n
,
unify
=
Just
t`
}
in
(
request
,
length
$
search
request
db
)
(
request
,
search
request
db
)
\\
is`
<-
permutations
is
|
is`
<>
is
]
suggs
_
_
_
=
Nothing
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment