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
73469b7c
Commit
73469b7c
authored
May 13, 2015
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for type inspection with shift tab (inspect_reply)
parent
c8ee3d8e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
71 additions
and
6 deletions
+71
-6
ihaskell.cabal
ihaskell.cabal
+1
-0
Writer.hs
ipython-kernel/src/IHaskell/IPython/Message/Writer.hs
+2
-1
ZeroMQ.hs
ipython-kernel/src/IHaskell/IPython/ZeroMQ.hs
+5
-1
Evaluate.hs
src/IHaskell/Eval/Evaluate.hs
+1
-0
Inspect.hs
src/IHaskell/Eval/Inspect.hs
+51
-0
Main.hs
src/Main.hs
+11
-4
No files found.
ihaskell.cabal
View file @
73469b7c
...
@@ -106,6 +106,7 @@ library
...
@@ -106,6 +106,7 @@ library
IHaskell.Convert.IpynbToLhs
IHaskell.Convert.IpynbToLhs
IHaskell.Convert.LhsToIpynb
IHaskell.Convert.LhsToIpynb
IHaskell.Eval.Completion
IHaskell.Eval.Completion
IHaskell.Eval.Inspect
IHaskell.Eval.Evaluate
IHaskell.Eval.Evaluate
IHaskell.Eval.Info
IHaskell.Eval.Info
IHaskell.Eval.Lint
IHaskell.Eval.Lint
...
...
ipython-kernel/src/IHaskell/IPython/Message/Writer.hs
View file @
73469b7c
...
@@ -72,6 +72,7 @@ instance ToJSON Message where
...
@@ -72,6 +72,7 @@ instance ToJSON Message where
else
"error"
else
"error"
,
"data"
.=
object
(
map
displayDataToJson
.
inspectData
$
i
)
,
"data"
.=
object
(
map
displayDataToJson
.
inspectData
$
i
)
,
"metadata"
.=
object
[]
,
"metadata"
.=
object
[]
,
"found"
.=
inspectStatus
i
]
]
toJSON
ShutdownReply
{
restartPending
=
restart
}
=
toJSON
ShutdownReply
{
restartPending
=
restart
}
=
...
@@ -128,4 +129,4 @@ ints :: [Int] -> [Int]
...
@@ -128,4 +129,4 @@ ints :: [Int] -> [Int]
ints
=
id
ints
=
id
string
::
String
->
String
string
::
String
->
String
string
=
id
string
=
id
\ No newline at end of file
ipython-kernel/src/IHaskell/IPython/ZeroMQ.hs
View file @
73469b7c
...
@@ -194,7 +194,11 @@ receiveMessage debug socket = do
...
@@ -194,7 +194,11 @@ receiveMessage debug socket = do
sendMessage
::
Sender
a
=>
Bool
->
ByteString
->
Socket
a
->
Message
->
IO
()
sendMessage
::
Sender
a
=>
Bool
->
ByteString
->
Socket
a
->
Message
->
IO
()
sendMessage
_
_
_
SendNothing
=
return
()
sendMessage
_
_
_
SendNothing
=
return
()
sendMessage
debug
hmacKey
socket
message
=
do
sendMessage
debug
hmacKey
socket
message
=
do
when
debug
$
print
message
when
debug
$
do
putStr
"Message: "
print
message
putStr
"Sent: "
print
content
-- Send all pieces of the message.
-- Send all pieces of the message.
mapM_
sendPiece
idents
mapM_
sendPiece
idents
...
...
src/IHaskell/Eval/Evaluate.hs
View file @
73469b7c
...
@@ -12,6 +12,7 @@ module IHaskell.Eval.Evaluate (
...
@@ -12,6 +12,7 @@ module IHaskell.Eval.Evaluate (
liftIO
,
liftIO
,
typeCleaner
,
typeCleaner
,
globalImports
,
globalImports
,
formatType
,
)
where
)
where
import
ClassyPrelude
hiding
(
init
,
last
,
liftIO
,
head
,
hGetContents
,
tail
,
try
)
import
ClassyPrelude
hiding
(
init
,
last
,
liftIO
,
head
,
hGetContents
,
tail
,
try
)
...
...
src/IHaskell/Eval/Inspect.hs
0 → 100644
View file @
73469b7c
{-# LANGUAGE CPP, NoImplicitPrelude, OverloadedStrings, DoAndIfThenElse, FlexibleContexts #-}
{- |
Description: Generates inspections when asked for by the frontend.
-}
module
IHaskell.Eval.Inspect
(
inspect
)
where
import
ClassyPrelude
import
qualified
Prelude
as
P
import
Data.List.Split
(
splitOn
)
import
Exception
(
ghandle
)
import
IHaskell.Eval.Evaluate
(
Interpreter
)
import
IHaskell.Display
import
IHaskell.Eval.Util
(
getType
)
import
IHaskell.Types
-- | Characters used in Haskell operators.
operatorChars
::
String
operatorChars
=
"!#$%&*+./<=>?@
\\
^|-~:"
-- | Whitespace characters.
whitespace
::
String
whitespace
=
"
\t\n
"
-- | Compute the identifier that is being queried.
getIdentifier
::
String
->
Int
->
String
getIdentifier
code
pos
=
identifier
where
chunks
=
splitOn
whitespace
code
lastChunk
=
P
.
last
chunks
::
String
identifier
=
if
all
(`
elem
`
operatorChars
)
lastChunk
then
"("
++
lastChunk
++
")"
else
lastChunk
inspect
::
String
-- ^ Code in the cell
->
Int
-- ^ Cursor position in the cell
->
Interpreter
(
Maybe
Display
)
inspect
code
pos
=
do
let
identifier
=
getIdentifier
code
pos
handler
::
SomeException
->
Interpreter
(
Maybe
a
)
handler
_
=
return
Nothing
response
<-
ghandle
handler
(
Just
<$>
getType
identifier
)
let
prefix
=
identifier
++
" :: "
fmt
str
=
Display
[
plain
$
prefix
++
str
]
return
$
fmt
<$>
response
src/Main.hs
View file @
73469b7c
...
@@ -24,6 +24,7 @@ import qualified Data.Text as T
...
@@ -24,6 +24,7 @@ import qualified Data.Text as T
-- IHaskell imports.
-- IHaskell imports.
import
IHaskell.Convert
(
convert
)
import
IHaskell.Convert
(
convert
)
import
IHaskell.Eval.Completion
(
complete
)
import
IHaskell.Eval.Completion
(
complete
)
import
IHaskell.Eval.Inspect
(
inspect
)
import
IHaskell.Eval.Evaluate
import
IHaskell.Eval.Evaluate
import
IHaskell.Display
import
IHaskell.Display
import
IHaskell.Eval.Info
import
IHaskell.Eval.Info
...
@@ -335,10 +336,16 @@ replyTo _ req@CompleteRequest{} replyHeader state = do
...
@@ -335,10 +336,16 @@ replyTo _ req@CompleteRequest{} replyHeader state = do
reply
=
CompleteReply
replyHeader
(
map
pack
completions
)
start
end
Map
.
empty
True
reply
=
CompleteReply
replyHeader
(
map
pack
completions
)
start
end
Map
.
empty
True
return
(
state
,
reply
)
return
(
state
,
reply
)
-- TODO: Implement inspect_reply
replyTo
_
req
@
InspectRequest
{}
replyHeader
state
=
do
replyTo
_
InspectRequest
{}
replyHeader
state
=
do
result
<-
inspect
(
unpack
$
inspectCode
req
)
(
inspectCursorPos
req
)
-- FIXME
let
reply
=
let
reply
=
InspectReply
{
header
=
replyHeader
,
inspectStatus
=
False
,
inspectData
=
[]
}
case
result
of
Just
(
Display
datas
)
->
InspectReply
{
header
=
replyHeader
,
inspectStatus
=
True
,
inspectData
=
datas
}
_
->
InspectReply
{
header
=
replyHeader
,
inspectStatus
=
False
,
inspectData
=
[]
}
return
(
state
,
reply
)
return
(
state
,
reply
)
-- TODO: Implement history_reply.
-- TODO: Implement history_reply.
...
...
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