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
f2a6ee88
Verified
Commit
f2a6ee88
authored
Mar 09, 2017
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve
#37
: use type synonyms in unification
parent
5f7b54c4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
24 deletions
+46
-24
backend/CleanTypeUnifier
backend/CleanTypeUnifier
+1
-1
backend/Cloogle.dcl
backend/Cloogle.dcl
+7
-3
backend/Cloogle.icl
backend/Cloogle.icl
+2
-2
backend/CloogleServer.icl
backend/CloogleServer.icl
+19
-11
frontend/api.js
frontend/api.js
+17
-7
No files found.
CleanTypeUnifier
@
c1ba15f2
Compare
42cc5aa9
...
c1ba15f2
Subproject commit
42cc5aa9649163d0a275e801a32b056c154f4d3b
Subproject commit
c1ba15f2a4181153639831d4f1fc92ee89ecb604
backend/Cloogle.dcl
View file @
f2a6ee88
...
...
@@ -80,16 +80,20 @@ from Text.JSON import generic JSONEncode, generic JSONDecode, :: JSONNode
::
LocationResult
:==
(
String
,
String
,
Maybe
Int
,
Maybe
Int
)
::
StrUnifier
:==
([(
String
,
String
)],
[(
String
,
String
)])
::
StrUnifier
=
{
left_to_right
::
[(
String
,
String
)]
,
right_to_left
::
[(
String
,
String
)]
,
used_synonyms
::
[(
String
,
String
)]
}
::
ShortClassResult
=
{
cls_name
::
String
,
cls_vars
::
[
String
]
}
derive
JSONEncode
Request
,
Response
,
Result
,
ShortClassResult
,
BasicResult
,
FunctionResultExtras
,
TypeResultExtras
,
ClassResultExtras
,
MacroResultExtras
,
ModuleResultExtras
MacroResultExtras
,
ModuleResultExtras
,
StrUnifier
derive
JSONDecode
Request
,
Response
,
Result
,
ShortClassResult
,
BasicResult
,
FunctionResultExtras
,
TypeResultExtras
,
ClassResultExtras
,
MacroResultExtras
,
ModuleResultExtras
MacroResultExtras
,
ModuleResultExtras
,
StrUnifier
instance
zero
Request
instance
zero
Response
...
...
backend/Cloogle.icl
View file @
f2a6ee88
...
...
@@ -6,10 +6,10 @@ import Text.JSON
derive
JSONEncode
Request
,
Response
,
Result
,
ShortClassResult
,
BasicResult
,
FunctionResultExtras
,
TypeResultExtras
,
ClassResultExtras
,
MacroResultExtras
,
ModuleResultExtras
MacroResultExtras
,
ModuleResultExtras
,
StrUnifier
derive
JSONDecode
Request
,
Response
,
Result
,
ShortClassResult
,
BasicResult
,
FunctionResultExtras
,
TypeResultExtras
,
ClassResultExtras
,
MacroResultExtras
,
ModuleResultExtras
MacroResultExtras
,
ModuleResultExtras
,
StrUnifier
instance
zero
Request
where
...
...
backend/CloogleServer.icl
View file @
f2a6ee88
...
...
@@ -13,14 +13,16 @@ from StdMisc import abort
from
TCPIP
import
::
IPAddress
,
::
Port
,
instance
toString
IPAddress
import
Control
.
Applicative
import
Control
.
Monad
import
qualified
Data
.
Foldable
as
Foldable
from
Data
.
Foldable
import
class
Foldable
,
instance
Foldable
Maybe
from
Data
.
Func
import
$
import
Data
.
Functor
import
Data
.
List
import
Data
.
Tuple
import
Data
.
Maybe
import
Data
.
Tuple
import
System
.
CommandLine
import
Data
.
Functor
import
Control
.
Applicative
import
Control
.
Monad
from
Text
import
class
Text
(
concat
,
trim
,
indexOf
,
toLowerCase
,
split
),
instance
Text
String
,
instance
+
String
import
Text
.
JSON
...
...
@@ -186,12 +188,15 @@ where
#
typeName
=
fromJust
typeName
#
types
=
findType
typeName
db
=
[
makeTypeResult
(
Just
typeName
)
l
td
db
\\
(
l
,
td
)
<-
types
]
#
mbType
=
snd
<$>
prepare_unification
True
(
allTypes
db_org
)
<$>
(
unify
>>=
parseType
o
fromString
)
#
mbPreppedType
=
prepare_unification
True
(
allTypes
db_org
)
<$>
(
unify
>>=
parseType
o
fromString
)
#
usedSynonyms
=
'
Foldable
'.
concat
(
fst
<$>
mbPreppedType
)
#
mbType
=
snd
<$>
mbPreppedType
// Search normal functions
#
filts
=
catMaybes
[
(\
t
_
->
isUnifiable
t
db_org
)
<$>
mbType
,
(\
n
loc
_
->
isNameMatch
(
size
n
*
2
/
3
)
n
$
getName
loc
)
<$>
name
]
#
funs
=
map
(\
f
->
makeFunctionResult
name
mbType
Nothing
f
db_org
)
$
findFunction``
filts
db
#
funs
=
map
(\
f
->
makeFunctionResult
name
mbType
usedSynonyms
Nothing
f
db_org
)
$
findFunction``
filts
db
// Search macros
#
macros
=
case
(
isNothing
mbType
,
name
)
of
(
True
,
Just
n
)
=
findMacro`
(\
loc
_
->
isNameMatch
(
size
n
*
2
/
3
)
n
$
getName
loc
)
db
...
...
@@ -203,7 +208,7 @@ where
(
size
n
*
2
/
3
)
n
f
)
<$>
name
]
#
members
=
findClassMembers``
filts
db
#
members
=
map
(\(
Location
lib
mod
line
iclline
cls
,
vs
,_,
f
,
et
)
->
makeFunctionResult
name
mbType
#
members
=
map
(\(
Location
lib
mod
line
iclline
cls
,
vs
,_,
f
,
et
)
->
makeFunctionResult
name
mbType
usedSynonyms
(
Just
{
cls_name
=
cls
,
cls_vars
=
vs
})
(
Location
lib
mod
line
iclline
f
,
et
)
db
)
members
// Search types
#
lcName
=
if
(
isJust
mbType
&&
isType
(
fromJust
mbType
))
...
...
@@ -340,10 +345,10 @@ where
}
)
makeFunctionResult
::
(
Maybe
String
)
(
Maybe
Type
)
(
Maybe
ShortClassResult
)
makeFunctionResult
::
(
Maybe
String
)
(
Maybe
Type
)
[
TypeDef
]
(
Maybe
ShortClassResult
)
(
Location
,
ExtendedType
)
TypeDB
->
Result
makeFunctionResult
orgsearch
orgsearchtype
mbCls
(
fl
,
et
=:(
ET
type
tes
))
db
orgsearch
orgsearchtype
usedsynonyms
mbCls
(
fl
,
et
=:(
ET
type
tes
))
db
=
FunctionResult
(
{
library
=
lib
,
filename
=
modToFilename
mod
...
...
@@ -355,7 +360,7 @@ where
}
,
{
func
=
fromJust
(
tes
.
te_representation
<|>
(
pure
$
concat
$
print
False
(
fname
,
et
)))
,
unifier
=
toStrUnifier
<$>
finish_unification
unisyns
<$>
,
unifier
=
toStrUnifier
<$>
finish_unification
(
unisyns
++
usedsynonyms
)
<$>
(
orgsearchtype
>>=
unify
[]
unitype
)
,
cls
=
mbCls
,
constructor_of
=
if
tes
.
te_isconstructor
...
...
@@ -383,7 +388,10 @@ where
{
StrUnifier
|
left_to_right
=
map
toStr
unif
.
Unifier
.
left_to_right
,
right_to_left
=
map
toStr
unif
.
Unifier
.
right_to_left
,
used_synonyms
=
[]
,
used_synonyms
=
[
(
concat
$
[
td
.
td_name
,
" "
:
intersperse
" "
$
print
False
td
.
td_args
]
,
concat
$
print
False
s
)
\\
td
=:{
td_rhs
=
TDRSynonym
s
}
<-
unif
.
Unifier
.
used_synonyms
]
}
where
toStr
(
var
,
type
)
=
(
var
,
concat
$
print
False
type
)
...
...
frontend/api.js
View file @
f2a6ee88
...
...
@@ -250,8 +250,18 @@ function getResults(str, libs, include_builtins, include_core, page) {
highlightCallback
,
'
className
'
)
+
'
</code>
'
);
if
(
'
unifier
'
in
extra
&&
(
extra
[
'
unifier
'
][
0
].
length
>
0
||
extra
[
'
unifier
'
][
1
].
length
>
0
))
(
extra
[
'
unifier
'
].
left_to_right
.
length
>
0
||
extra
[
'
unifier
'
].
right_to_left
.
length
>
0
))
meta
.
push
(
'
Unifier:
'
+
makeUnifier
(
extra
[
'
unifier
'
]));
if
(
'
unifier
'
in
extra
)
{
var
synonyms
=
extra
[
'
unifier
'
].
used_synonyms
;
for
(
var
i
in
synonyms
)
{
console
.
log
(
synonyms
[
i
]);
meta
.
push
(
'
Used the type synonym <code>
'
+
highlightTypeDef
(
'
::
'
+
synonyms
[
i
][
0
]
+
'
:==
'
+
synonyms
[
i
][
1
],
highlightCallback
)
+
'
</code>.
'
);
}
}
if
(
'
generic_derivations
'
in
extra
)
{
var
derivations
=
makeInstanceTable
(
...
...
@@ -394,15 +404,15 @@ function getResults(str, libs, include_builtins, include_core, page) {
}
function
makeUnifier
(
ufr
)
{
var
from_left
=
ufr
[
0
]
;
var
from_right
=
ufr
[
1
]
;
var
from_left
=
ufr
.
left_to_right
;
var
from_right
=
ufr
.
right_to_left
;
var
s
=
''
;
for
(
i
in
from_right
)
{
for
(
i
in
from_right
)
s
+=
'
<tt>
'
+
from_right
[
i
][
0
]
+
'
</tt> → <tt>
'
+
from_right
[
i
][
1
]
+
'
</tt>;
'
;
}
for
(
i
in
from_left
)
{
for
(
i
in
from_left
)
s
+=
'
<tt>
'
+
from_left
[
i
][
1
]
+
'
</tt> ← <tt>
'
+
from_left
[
i
][
0
]
+
'
</tt>;
'
;
}
return
s
.
substring
(
0
,
s
.
length
-
2
);
}
...
...
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