Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-ihaskell
Commits
05dd79dc
Commit
05dd79dc
authored
Mar 04, 2015
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing hoogle access by urlencoding parameters
parent
6b6a9b89
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
146 additions
and
5 deletions
+146
-5
IHaskell.ipynb
notebooks/IHaskell.ipynb
+118
-4
Evaluate.hs
src/IHaskell/Eval/Evaluate.hs
+1
-0
Hoogle.hs
src/IHaskell/Eval/Hoogle.hs
+27
-1
No files found.
notebooks/IHaskell.ipynb
View file @
05dd79dc
This diff is collapsed.
Click to expand it.
src/IHaskell/Eval/Evaluate.hs
View file @
05dd79dc
...
...
@@ -1212,6 +1212,7 @@ formatErrorWithClass cls =
replace
"
\n
"
"<br/>"
.
replace
useDashV
""
.
replace
"Ghci"
"IHaskell"
.
replace
"‘interactive:"
"‘"
.
fixDollarSigns
.
rstrip
.
typeCleaner
...
...
src/IHaskell/Eval/Hoogle.hs
View file @
05dd79dc
...
...
@@ -14,7 +14,9 @@ import Network.HTTP.Client.TLS
import
Data.Aeson
import
Data.String.Utils
import
Data.List
(
elemIndex
,
(
!!
),
last
)
import
Data.Char
(
isAscii
,
isAlphaNum
)
import
qualified
Data.ByteString.Lazy.Char8
as
Char
import
qualified
Prelude
as
P
import
IHaskell.IPython
...
...
@@ -58,7 +60,7 @@ instance FromJSON HoogleResponse where
-- message or the successful JSON result.
query
::
String
->
IO
(
Either
String
String
)
query
str
=
do
request
<-
parseUrl
$
queryUrl
str
request
<-
parseUrl
$
queryUrl
$
urlEncode
str
response
<-
try
$
withManager
tlsManagerSettings
$
httpLbs
request
return
$
case
response
of
Left
err
->
Left
$
show
(
err
::
SomeException
)
...
...
@@ -67,6 +69,30 @@ query str = do
queryUrl
::
String
->
String
queryUrl
=
printf
"https://www.haskell.org/hoogle/?hoogle=%s&mode=json"
-- | Copied from the HTTP package.
urlEncode
::
String
->
String
urlEncode
[]
=
[]
urlEncode
(
ch
:
t
)
|
(
isAscii
ch
&&
isAlphaNum
ch
)
||
ch
`
P
.
elem
`
"-_.~"
=
ch
:
urlEncode
t
|
not
(
isAscii
ch
)
=
P
.
foldr
escape
(
urlEncode
t
)
(
eightBs
[]
(
P
.
fromEnum
ch
))
|
otherwise
=
escape
(
P
.
fromEnum
ch
)
(
urlEncode
t
)
where
escape
::
Int
->
String
->
String
escape
b
rs
=
'%'
:
showH
(
b
`
P
.
div
`
16
)
(
showH
(
b
`
mod
`
16
)
rs
)
showH
::
Int
->
String
->
String
showH
x
xs
|
x
<=
9
=
toEnum
(
o_0
+
x
)
:
xs
|
otherwise
=
toEnum
(
o_A
+
(
x
-
10
))
:
xs
where
o_0
=
P
.
fromEnum
'0'
o_A
=
P
.
fromEnum
'A'
eightBs
::
[
Int
]
->
Int
->
[
Int
]
eightBs
acc
x
|
x
<=
0xff
=
(
x
:
acc
)
|
otherwise
=
eightBs
((
x
`
mod
`
256
)
:
acc
)
(
x
`
P
.
div
`
256
)
-- | Search for a query on Hoogle.
-- Return all search results.
search
::
String
->
IO
[
HoogleResult
]
...
...
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