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
70c05db1
Verified
Commit
70c05db1
authored
Jun 18, 2016
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More efficient unification; better distance measure
parent
8f021cd3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
26 deletions
+29
-26
CleanTypeUnifier
CleanTypeUnifier
+1
-1
CloogleServer.icl
CloogleServer.icl
+28
-25
No files found.
CleanTypeUnifier
@
c1474126
Compare
61b6d74e
...
c1474126
Subproject commit
61b6d74e060ca8dd6bba5a7cbe98feb583acd1ce
Subproject commit
c14741265f1de8cf7ecc08e70c8f36d8f01b6c37
CloogleServer.icl
View file @
70c05db1
...
...
@@ -137,7 +137,9 @@ where
// Suggestions
#
mbType
=
unify
>>=
parseType
o
fromString
#
suggestions
=
filter
((<)(
length
results
)
o
snd
)
<$>
(
mbType
>>=
flip
suggs
db
)
=
sortBy
(\
a
b
->
snd
a
>
snd
b
)
<$>
filter
((<)(
length
results
)
o
snd
)
<$>
(
mbType
>>=
flip
suggs
db
)
// Response
|
isEmpty
results
=
(
err
E_NORESULTS
"No results"
,
w
)
=
(
{
return
=
0
...
...
@@ -150,26 +152,27 @@ where
suggs
::
!
Type
!
TypeDB
->
Maybe
[(
String
,
Int
)]
suggs
(
Func
is
r
cc
)
db
|
length
is
<
3
=
Just
[
let
t`
=
concat
$
print
False
$
Func
is`
r
cc
in
(
t`
,
length
$
search
{
zero
&
unify
=
Just
t`
}
db
)
\\
is`
<-
permutations
is
|
is`
<>
is
]
|
length
is
<
3
=
Just
[
let
t`
=
concat
$
print
False
$
Func
is`
r
cc
in
(
t`
,
length
$
search
{
zero
&
unify
=
Just
t`
}
db
)
\\
is`
<-
permutations
is
|
is`
<>
is
]
suggs
_
_
=
Nothing
search
::
!
Request
!
TypeDB
->
[
Result
]
search
{
unify
,
name
,
modules
,
page
}
db
#
mbType
=
prepare_unification
True
<$>
(
unify
>>=
parseType
o
fromString
)
// Search normal functions
#
filts
=
catMaybes
$
[
(\
t
_
->
isUnifiable
t
)
<$>
mbType
,
(\
n
loc
_
->
isNameMatch
(
size
n
-2
)
n
loc
)
<$>
name
,
isModMatchF
<$>
modules
]
#
filts
=
catMaybes
[
(\
t
_
->
isUnifiable
t
)
<$>
mbType
,
(\
n
loc
_
->
isNameMatch
(
size
n
-2
)
n
loc
)
<$>
name
,
isModMatchF
<$>
modules
]
#
funs
=
map
(
makeFunctionResult
name
mbType
Nothing
)
$
findFunction``
filts
db
// Search class members
#
filts
=
catMaybes
$
[
(\
t
_
_
_->
isUnifiable
t
)
<$>
mbType
,
(\
n
(
CL
lib
mod
_)
_
f
_
->
isNameMatch
(
size
n
-2
)
n
(
FL
lib
mod
f
))
<$>
name
,
isModMatchC
<$>
modules
]
#
filts
=
catMaybes
[
(\
t
_
_
_->
isUnifiable
t
)
<$>
mbType
,
(\
n
(
CL
lib
mod
_)
_
f
_
->
isNameMatch
(
size
n
-2
)
n
(
FL
lib
mod
f
))
<$>
name
,
isModMatchC
<$>
modules
]
#
members
=
findClassMembers``
filts
db
#
members
=
map
(\(
CL
lib
mod
cls
,
vs
,
f
,
et
)
->
makeFunctionResult
name
mbType
(
Just
{
cls_name
=
cls
,
cls_vars
=
vs
})
(
FL
lib
mod
f
,
et
))
members
...
...
@@ -191,7 +194,7 @@ where
,
filename
=
modToFilename
mod
,
modul
=
mod
,
distance
=
if
(
isNothing
mbName
)
-100
(
levenshtein`
t
(
fromJust
mbName
))
=
if
(
isNothing
mbName
)
-100
(
levenshtein`
t
(
fromJust
mbName
))
}
,
{
type
=
concat
$
print
False
td
}
)
...
...
@@ -208,8 +211,8 @@ where
}
,
{
func
=
fname
+++
toStrPriority
tes
.
te_priority
+++
" :: "
+++
concat
(
print
False
type
)
,
unifier
=
toStrUnifier
<$>
finish_unification
<$>
(
orgsearchtype
>>=
unify
[]
(
prepare_unification
False
type
))
,
unifier
=
toStrUnifier
<$>
finish_unification
<$>
(
orgsearchtype
>>=
unify
[]
(
prepare_unification
False
type
))
,
cls
=
mbCls
}
)
...
...
@@ -225,18 +228,18 @@ where
|
isNothing
orgsearch
||
fromJust
orgsearch
==
""
|
isNothing
orgsearchtype
=
0
#
orgsearchtype
=
fromJust
orgsearchtype
#
(
Just
(
ass1
,
ass2
))
=
finish_unification
<$>
unify
[]
orgsearchtype
(
prepare_unification
False
type
)
=
sum
[
typeComplexity
t
\\
(_,
t
)<-
ass1
++
ass2
|
not
(
isVar
t
)]
#
(
Just
(
ass1
,
ass2
))
=
finish_unification
<$>
unify
[]
orgsearchtype
(
prepare_unification
False
type
)
=
toInt
$
sum
[
typeComplexity
t
\\
(_,
t
)<-
ass1
++
ass2
|
not
(
isVar
t
)]
#
orgsearch
=
fromJust
orgsearch
=
levenshtein`
orgsearch
fname
where
typeComplexity
::
Type
->
Int
typeComplexity
(
Type
_
ts
)
=
foldr
((+)
o
typeComplexity
)
1
ts
typeComplexity
(
Func
is
_
_)
=
foldr
((+)
o
typeComplexity
)
5
is
typeComplexity
(
Var
_)
=
1
typeComplexity
(
Cons
_
ts
)
=
foldr
((+)
o
typeComplexity
)
1
ts
typeComplexity
(
Uniq
t
)
=
3
+
typeComplexity
t
typeComplexity
::
Type
->
Real
typeComplexity
(
Type
_
ts
)
=
1.2
*
foldr
((+)
o
typeComplexity
)
1.0
ts
typeComplexity
(
Func
is
r
_)
=
2.0
*
foldr
((+)
o
typeComplexity
)
1.0
[
r
:
is
]
typeComplexity
(
Var
_)
=
1
.0
typeComplexity
(
Cons
_
ts
)
=
1.2
*
foldr
((+)
o
typeComplexity
)
1.0
ts
typeComplexity
(
Uniq
t
)
=
3
.0
+
typeComplexity
t
levenshtein`
::
String
String
->
Int
levenshtein`
a
b
=
if
(
indexOf
a
b
==
-1
)
0
-100
+
levenshtein
a
b
...
...
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