Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Cloogle
Cloogle
Commits
a2a620fa
Verified
Commit
a2a620fa
authored
Nov 18, 2018
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add nr. of args to Type/Cons in unifier to ranking factors
parent
cb66601e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
12 deletions
+20
-12
Cloogle/Search/Rank.dcl
Cloogle/Search/Rank.dcl
+2
-0
Cloogle/Search/Rank.icl
Cloogle/Search/Rank.icl
+18
-12
No files found.
Cloogle/Search/Rank.dcl
View file @
a2a620fa
...
...
@@ -21,6 +21,8 @@ from Cloogle.DB import :: Annotation, :: CloogleEntry, :: CloogleDB
,
rs_unifier_n_types
::
!
Real
//* number of Type constructors in the unifier
,
rs_unifier_n_funcs
::
!
Real
//* number of Func constructors in the unifier
,
rs_unifier_n_conss
::
!
Real
//* number of Cons constructors in the unifier
,
rs_unifier_n_args
::
!
Real
//* number of arguments of Type and Cons in the unifier
,
rs_used_synonyms
::
!
Real
//* the number of synonyms required
,
rs_resolved_context
::
!
Real
//* class contexts with known instances
,
rs_unresolved_context
::
!
Real
//* class contexts without known instances
...
...
Cloogle/Search/Rank.icl
View file @
a2a620fa
...
...
@@ -33,6 +33,7 @@ distance settings entry annots = let info = symbolicDistance entry annots in
settings
.
rs_unifier_n_types
*
info
.
rs_unifier_n_types
+
settings
.
rs_unifier_n_funcs
*
info
.
rs_unifier_n_funcs
+
settings
.
rs_unifier_n_conss
*
info
.
rs_unifier_n_conss
+
settings
.
rs_unifier_n_args
*
info
.
rs_unifier_n_args
+
settings
.
rs_used_synonyms
*
info
.
rs_used_synonyms
+
settings
.
rs_resolved_context
*
info
.
rs_resolved_context
+
settings
.
rs_unresolved_context
*
info
.
rs_unresolved_context
+
...
...
@@ -47,6 +48,7 @@ symbolicDistance entry annots =
,
rs_unifier_n_types
=
ntype
,
rs_unifier_n_funcs
=
nfunc
,
rs_unifier_n_conss
=
ncons
,
rs_unifier_n_args
=
nargs
,
rs_used_synonyms
=
case
[
s
\\
UsedSynonyms
s
<-
annots
]
of
[
s
:_]
->
toReal
s
;
_
->
0.0
,
rs_resolved_context
=
resolved_context
,
rs_unresolved_context
=
unresolved_context
...
...
@@ -63,26 +65,26 @@ where
|
otherwise
=
context_sizes
(
res
+1
)
unres
rest
context_sizes
res
unres
[]
=
(
res
,
unres
)
(
ntype
,
nfunc
,
ncons
)
=
case
[
unifier_sizes
u
\\
Unifier
u
<-
annots
]
of
[(
nt
,
nf
,
nc
):_]
->
(
toReal
nt
,
toReal
nf
,
toReal
nc
)
_
->
(
0.0
,
0.0
,
0.0
)
(
ntype
,
nfunc
,
ncons
,
nargs
)
=
case
[
unifier_sizes
u
\\
Unifier
u
<-
annots
]
of
[(
nt
,
nf
,
nc
,
na
):_]
->
(
toReal
nt
,
toReal
nf
,
toReal
nc
,
toReal
na
)
_
->
(
0.0
,
0.0
,
0.0
,
0.0
)
/**
* @result nr. of Type constructors
* @result nr. of Func constructors
* @result nr. of Cons constructors
*/
unifier_sizes
::
!
Unifier
->
(!
Int
,!
Int
,!
Int
)
unifier_sizes
::
!
Unifier
->
(!
Int
,!
Int
,!
Int
,!
Int
)
unifier_sizes
unif
=
count
0
0
0
[
t
\\
(_,
t`
)
<-
map
fromUnifyingAssignment
unif
.
assignments
,
t
<-
subtypes
t`
]
=
count
0
0
0
0
[
t
\\
(_,
t`
)
<-
map
fromUnifyingAssignment
unif
.
assignments
,
t
<-
subtypes
t`
]
where
count
::
!
Int
!
Int
!
Int
![
Type
]
->
(!
Int
,!
Int
,!
Int
)
count
nt
nf
nc
[
t
:
ts
]
=
case
t
of
Type
_
_
->
count
(
nt
+1
)
nf
nc
ts
Func
_
_
_
->
count
nt
(
nf
+1
)
nc
ts
Cons
_
_
->
count
nt
nf
(
nc
+1
)
ts
_
->
count
nt
nf
nc
ts
count
nt
nf
nc
[]
=
(
nt
,
nf
,
nc
)
count
::
!
Int
!
Int
!
Int
!
Int
![
Type
]
->
(!
Int
,!
Int
,!
Int
,!
Int
)
count
nt
nf
nc
na
[
t
:
ts
]
=
case
t
of
Type
_
as
->
count
(
nt
+1
)
nf
nc
(
na
+
length
as
)
ts
Func
_
_
_
->
count
nt
(
nf
+1
)
nc
na
ts
Cons
_
as
->
count
nt
nf
(
nc
+1
)
(
na
+
length
as
)
ts
_
->
count
nt
nf
nc
na
ts
count
nt
nf
nc
na
[]
=
(
nt
,
nf
,
nc
,
na
)
match
::
!
UniqueResultIdentifier
!
CloogleEntry
->
Bool
match
(
thing
,
mod
,
name
)
ce
...
...
@@ -126,6 +128,7 @@ findRankSettings constraints cdb w
,
rs_unifier_n_types
=
0.0
,
rs_unifier_n_funcs
=
0.0
,
rs_unifier_n_conss
=
0.0
,
rs_unifier_n_args
=
0.0
,
rs_used_synonyms
=
0.0
,
rs_resolved_context
=
0.0
,
rs_unresolved_context
=
0.0
...
...
@@ -146,6 +149,7 @@ where
"rs_unifier_n_types"
->
{
rs
&
rs_unifier_n_types
=
val
}
"rs_unifier_n_funcs"
->
{
rs
&
rs_unifier_n_funcs
=
val
}
"rs_unifier_n_conss"
->
{
rs
&
rs_unifier_n_conss
=
val
}
"rs_unifier_n_args"
->
{
rs
&
rs_unifier_n_args
=
val
}
"rs_used_synonyms"
->
{
rs
&
rs_used_synonyms
=
val
}
"rs_resolved_context"
->
{
rs
&
rs_resolved_context
=
val
}
"rs_unresolved_context"
->
{
rs
&
rs_unresolved_context
=
val
}
...
...
@@ -167,6 +171,7 @@ where
,
"(declare-const rs_unifier_n_types Real)"
,
"(declare-const rs_unifier_n_funcs Real)"
,
"(declare-const rs_unifier_n_conss Real)"
,
"(declare-const rs_unifier_n_args Real)"
,
"(declare-const rs_used_synonyms Real)"
,
"(declare-const rs_resolved_context Real)"
,
"(declare-const rs_unresolved_context Real)"
...
...
@@ -208,6 +213,7 @@ where
,
"* rs_unifier_n_types "
<+
ri
.
rs_unifier_n_types
,
"* rs_unifier_n_funcs "
<+
ri
.
rs_unifier_n_funcs
,
"* rs_unifier_n_conss "
<+
ri
.
rs_unifier_n_conss
,
"* rs_unifier_n_args "
<+
ri
.
rs_unifier_n_args
,
"* rs_used_synonyms "
<+
ri
.
rs_used_synonyms
,
"* rs_resolved_context "
<+
ri
.
rs_resolved_context
,
"* rs_unresolved_context "
<+
ri
.
rs_unresolved_context
...
...
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