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
da3788ce
Commit
da3788ce
authored
Nov 28, 2014
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hoogle updated to use HTTPS, closes #311
parent
4eca3f2c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
9 deletions
+17
-9
ihaskell.cabal
ihaskell.cabal
+2
-2
Hoogle.hs
src/IHaskell/Eval/Hoogle.hs
+15
-7
No files found.
ihaskell.cabal
View file @
da3788ce
...
@@ -71,7 +71,8 @@ library
...
@@ -71,7 +71,8 @@ library
hlint >=1.9 && <2.0,
hlint >=1.9 && <2.0,
haskell-src-exts ==1.16.*,
haskell-src-exts ==1.16.*,
hspec -any,
hspec -any,
HTTP == 4000.2.*,
http-client == 0.4.*,
http-client-tls == 0.2.*,
HUnit -any,
HUnit -any,
MissingH >=1.2,
MissingH >=1.2,
mtl >=2.1,
mtl >=2.1,
...
@@ -166,7 +167,6 @@ Test-Suite hspec
...
@@ -166,7 +167,6 @@ Test-Suite hspec
hlint >=1.9 && <2.0,
hlint >=1.9 && <2.0,
haskell-src-exts ==1.15.*,
haskell-src-exts ==1.15.*,
hspec -any,
hspec -any,
HTTP -any,
HUnit -any,
HUnit -any,
MissingH >=1.2,
MissingH >=1.2,
mtl >=2.1,
mtl >=2.1,
...
...
src/IHaskell/Eval/Hoogle.hs
View file @
da3788ce
...
@@ -9,11 +9,11 @@ module IHaskell.Eval.Hoogle (
...
@@ -9,11 +9,11 @@ module IHaskell.Eval.Hoogle (
import
ClassyPrelude
hiding
(
last
,
span
,
div
)
import
ClassyPrelude
hiding
(
last
,
span
,
div
)
import
Text.Printf
import
Text.Printf
import
Network.HTTP
import
Network.HTTP.Client
import
Network.HTTP.Client.TLS
import
Data.Aeson
import
Data.Aeson
import
Data.String.Utils
import
Data.String.Utils
import
Data.List
(
elemIndex
,
(
!!
),
last
)
import
Data.List
(
elemIndex
,
(
!!
),
last
)
import
Control.Monad
(
guard
)
import
qualified
Data.ByteString.Lazy.Char8
as
Char
import
qualified
Data.ByteString.Lazy.Char8
as
Char
...
@@ -58,14 +58,14 @@ instance FromJSON HoogleResponse where
...
@@ -58,14 +58,14 @@ instance FromJSON HoogleResponse where
-- message or the successful JSON result.
-- message or the successful JSON result.
query
::
String
->
IO
(
Either
String
String
)
query
::
String
->
IO
(
Either
String
String
)
query
str
=
do
query
str
=
do
let
request
=
getRequest
$
queryUrl
str
request
<-
parseUrl
$
queryUrl
str
response
<-
simpleHTTP
request
response
<-
try
$
withManager
tlsManagerSettings
$
httpLbs
request
return
$
case
response
of
return
$
case
response
of
Left
err
->
Left
$
show
err
Left
err
->
Left
$
show
(
err
::
SomeException
)
Right
resp
->
Right
$
rsp
Body
resp
Right
resp
->
Right
$
Char
.
unpack
$
response
Body
resp
where
where
queryUrl
::
String
->
String
queryUrl
::
String
->
String
queryUrl
=
printf
"http
://www.haskell.org/hoogle/?hoogle=%s&mode=json"
.
urlEncode
queryUrl
=
printf
"http
s://www.haskell.org/hoogle/?hoogle=%s&mode=json"
-- | Search for a query on Hoogle.
-- | Search for a query on Hoogle.
-- Return all search results.
-- Return all search results.
...
@@ -156,6 +156,12 @@ renderSelf string loc
...
@@ -156,6 +156,12 @@ renderSelf string loc
span
"hoogle-class"
(
link
loc
$
extractClass
string
)
++
span
"hoogle-class"
(
link
loc
$
extractClass
string
)
++
packageSub
package
packageSub
package
|
startswith
"data"
string
=
let
package
=
extractPackageName
loc
in
dat
++
" "
++
span
"hoogle-class"
(
link
loc
$
extractData
string
)
++
packageSub
package
|
otherwise
|
otherwise
=
let
[
name
,
args
]
=
split
"::"
string
=
let
[
name
,
args
]
=
split
"::"
string
package
=
extractPackageName
loc
package
=
extractPackageName
loc
...
@@ -170,9 +176,11 @@ renderSelf string loc
...
@@ -170,9 +176,11 @@ renderSelf string loc
extractPackage
=
strip
.
replace
"package"
""
extractPackage
=
strip
.
replace
"package"
""
extractModule
=
strip
.
replace
"module"
""
extractModule
=
strip
.
replace
"module"
""
extractClass
=
strip
.
replace
"class"
""
extractClass
=
strip
.
replace
"class"
""
extractData
=
strip
.
replace
"data"
""
pkg
=
span
"hoogle-head"
"package"
pkg
=
span
"hoogle-head"
"package"
mod
=
span
"hoogle-head"
"module"
mod
=
span
"hoogle-head"
"module"
cls
=
span
"hoogle-head"
"class"
cls
=
span
"hoogle-head"
"class"
dat
=
span
"hoogle-head"
"data"
unicodeReplace
::
String
->
String
unicodeReplace
::
String
->
String
unicodeReplace
=
unicodeReplace
=
...
...
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