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
libcloogle
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
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cloogle
libcloogle
Commits
3a3be791
Verified
Commit
3a3be791
authored
Sep 21, 2020
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new maybe type
parent
39ff82e2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
33 deletions
+32
-33
Cloogle/API.dcl
Cloogle/API.dcl
+0
-1
Cloogle/API.icl
Cloogle/API.icl
+30
-30
Cloogle/Client.icl
Cloogle/Client.icl
+2
-2
No files found.
Cloogle/API.dcl
View file @
3a3be791
...
...
@@ -10,7 +10,6 @@ from StdOverloaded import class zero, class fromString, class toString,
from
Data
.
Error
import
::
MaybeError
,
::
MaybeErrorString
from
Data
.
GenEq
import
generic
gEq
from
Data
.
Maybe
import
::
Maybe
from
Text
.
GenJSON
import
generic
JSONEncode
,
generic
JSONDecode
,
::
JSONNode
/**
...
...
Cloogle/API.icl
View file @
3a3be791
...
...
@@ -33,8 +33,8 @@ derive gEq FunctionKind
JSONEncode
{|
ABCArgument
|}
_
arg
=
[
JSONString
(
toString
arg
)]
JSONDecode
{|
ABCArgument
|}
_
[
JSONString
s
:
r
]
=
(
Just
(
fromString
s
),
r
)
JSONDecode
{|
ABCArgument
|}
_
json
=
(
Nothing
,
json
)
JSONDecode
{|
ABCArgument
|}
_
[
JSONString
s
:
r
]
=
(
?
Just
(
fromString
s
),
r
)
JSONDecode
{|
ABCArgument
|}
_
json
=
(
?
None
,
json
)
instance
toInt
CloogleError
where
...
...
@@ -109,18 +109,18 @@ where
instance
zero
Request
where
zero
=
{
unify
=
Nothing
,
name
=
Nothing
,
exactName
=
Nothing
,
className
=
Nothing
,
typeName
=
Nothing
,
using
=
Nothing
,
modules
=
Nothing
,
libraries
=
Nothing
,
include_builtins
=
Nothing
,
include_core
=
Nothing
,
include_apps
=
Nothing
,
page
=
Nothing
{
unify
=
?
None
,
name
=
?
None
,
exactName
=
?
None
,
className
=
?
None
,
typeName
=
?
None
,
using
=
?
None
,
modules
=
?
None
,
libraries
=
?
None
,
include_builtins
=
?
None
,
include_core
=
?
None
,
include_apps
=
?
None
,
page
=
?
None
}
instance
zero
Response
...
...
@@ -129,9 +129,9 @@ where
{
return
=
0
,
msg
=
"Success"
,
data
=
[]
,
more_available
=
Nothing
,
suggestions
=
Nothing
,
warnings
=
Nothing
,
more_available
=
?
None
,
suggestions
=
?
None
,
warnings
=
?
None
}
instance
toString
Request
where
toString
r
=
toString
$
toJSON
r
...
...
@@ -162,27 +162,27 @@ where
instance
==
FunctionKind
where
(==)
a
b
=
a
===
b
getBasicResult
::
!
Result
->
?
BasicResult
getBasicResult
(
FunctionResult
(
br
,_))
=
Just
br
getBasicResult
(
TypeResult
(
br
,_))
=
Just
br
getBasicResult
(
ClassResult
(
br
,_))
=
Just
br
getBasicResult
(
ModuleResult
(
br
,_))
=
Just
br
getBasicResult
(
SyntaxResult
(
br
,_))
=
Just
br
getBasicResult
(
ABCInstructionResult
(
br
,_))
=
Just
br
getBasicResult
(
ProblemResult
_)
=
Nothing
getBasicResult
(
FunctionResult
(
br
,_))
=
?
Just
br
getBasicResult
(
TypeResult
(
br
,_))
=
?
Just
br
getBasicResult
(
ClassResult
(
br
,_))
=
?
Just
br
getBasicResult
(
ModuleResult
(
br
,_))
=
?
Just
br
getBasicResult
(
SyntaxResult
(
br
,_))
=
?
Just
br
getBasicResult
(
ABCInstructionResult
(
br
,_))
=
?
Just
br
getBasicResult
(
ProblemResult
_)
=
?
None
parseSingleLineRequest
::
!
String
->
MaybeErrorString
Request
parseSingleLineRequest
s
=
case
split
"::"
s
of
[
""
,
type
]
->
Ok
{
zero
&
unify
=
Just
$
trim
type
}
[
name
,
type
]
->
Ok
{
zero
&
name
=
Just
$
trim
name
,
unify
=
Just
$
trim
type
}
[
name
]
->
Ok
{
Request
|
zero
&
name
=
Just
$
trim
name
}
[
""
,
type
]
->
Ok
{
zero
&
unify
=
?
Just
$
trim
type
}
[
name
,
type
]
->
Ok
{
zero
&
name
=
?
Just
$
trim
name
,
unify
=
?
Just
$
trim
type
}
[
name
]
->
Ok
{
Request
|
zero
&
name
=
?
Just
$
trim
name
}
_
->
Error
"Multiple ::s found"
toSingleLine
::
!
Request
->
?
String
toSingleLine
req
|
isJust
req
.
typeName
&&
isJust
req
.
className
=
Nothing
|
isJust
req
.
typeName
&&
isJust
req
.
className
=
?
None
|
isJust
req
.
typeName
=
req
.
typeName
|
isJust
req
.
className
=
req
.
className
|
isJust
req
.
unify
=
case
req
.
Request
.
name
of
Nothing
->
Just
$
":: "
+
fromJust
req
.
unify
Just
n
->
Just
$
n
+
" :: "
+
fromJust
req
.
unify
?
None
->
?
Just
$
":: "
+
fromJust
req
.
unify
?
Just
n
->
?
Just
$
n
+
" :: "
+
fromJust
req
.
unify
|
otherwise
=
req
.
Request
.
name
Cloogle/Client.icl
View file @
3a3be791
...
...
@@ -40,5 +40,5 @@ request req w = appFst ((=<<) parseResponse) $ doHTTPRequest (toHTTPRequest req)
where
parseResponse
::
HTTPResponse
->
MaybeErrorString
Response
parseResponse
res
=
case
fromJSON
$
fromString
res
.
rsp_data
of
Nothing
->
Error
"Invalid JSON"
Just
r
->
Ok
r
?
None
->
Error
"Invalid JSON"
?
Just
r
->
Ok
r
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