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
a2553fa5
Commit
a2553fa5
authored
Oct 25, 2013
by
Adam Vogt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
generate completions on the ghc-side, doesn't get interpreted correctly yet
see note in Completion.hs
parent
3700cbb3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
2 deletions
+56
-2
IHaskell.cabal
IHaskell.cabal
+2
-0
Completion.hs
IHaskell/Completion.hs
+50
-0
Main.hs
Main.hs
+4
-2
No files found.
IHaskell.cabal
View file @
a2553fa5
...
@@ -70,6 +70,8 @@ executable IHaskell
...
@@ -70,6 +70,8 @@ executable IHaskell
ghc ==7.6.*,
ghc ==7.6.*,
ghc-paths ==0.1.*,
ghc-paths ==0.1.*,
random ==1.0.*,
random ==1.0.*,
split,
utf8-string,
strict ==0.3.*,
strict ==0.3.*,
shelly ==1.3.*,
shelly ==1.3.*,
text ==0.11.*
text ==0.11.*
IHaskell/Completion.hs
0 → 100644
View file @
a2553fa5
{-# LANGUAGE PatternGuards #-}
{- | very approximate completion. Seems to generate what is required by
<http://ipython.org/ipython-doc/dev/development/messaging.html#complete>,
but for whatever reason nothing gets added when the liftIO below prints
stuff like:
> {"status":"ok","text":"import Data hea","matches":["head"]}
When the cursor is after the hea, and you press tab.
-}
module
IHaskell.Completion
(
makeCompletions
)
where
import
Prelude
import
Data.List
import
IHaskell.Types
import
GhcMonad
(
liftIO
)
import
qualified
GHC
import
Outputable
(
showPpr
)
import
Data.Char
import
Data.ByteString.UTF8
import
Data.List.Split
import
Data.List.Split.Internals
import
Data.Aeson
import
IHaskell.Message.Writer
import
qualified
Data.ByteString.Lazy
as
L
makeCompletions
replyHeader
(
CompleteRequest
hdr
code
line
pos
)
=
do
ns
<-
GHC
.
getRdrNamesInScope
fs
<-
GHC
.
getProgramDynFlags
let
candidate
=
getWordAt
(
toString
line
)
pos
opts
|
Just
cand
<-
candidate
=
filter
(
cand
`
isPrefixOf
`)
$
map
(
showPpr
fs
)
ns
|
otherwise
=
[]
let
reply
=
CompleteReply
replyHeader
(
map
fromString
opts
)
line
True
liftIO
(
L
.
putStrLn
$
encode
$
toJSON
reply
)
return
reply
-- there are better ways to accomplish this
getWordAt
::
String
->
Int
->
Maybe
String
getWordAt
xs
n
=
fmap
(
map
fst
)
$
find
(
any
(
==
n
)
.
map
snd
)
$
split
(
defaultSplitter
{
delimiter
=
Delimiter
[
(
==
)
' '
.
fst
],
condensePolicy
=
Condense
})
(
zip
xs
[
1
..
])
Main.hs
View file @
a2553fa5
...
@@ -12,6 +12,7 @@ import qualified IHaskell.Message.UUID as UUID
...
@@ -12,6 +12,7 @@ import qualified IHaskell.Message.UUID as UUID
import
IHaskell.Eval.Evaluate
import
IHaskell.Eval.Evaluate
import
qualified
Data.ByteString.Char8
as
Chars
import
qualified
Data.ByteString.Char8
as
Chars
import
IHaskell.IPython
import
IHaskell.IPython
import
IHaskell.Completion
(
makeCompletions
)
data
KernelState
=
KernelState
data
KernelState
=
KernelState
{
getExecutionCounter
::
Int
{
getExecutionCounter
::
Int
...
@@ -147,7 +148,8 @@ replyTo interface ExecuteRequest{ getCode = code } replyHeader state = do
...
@@ -147,7 +148,8 @@ replyTo interface ExecuteRequest{ getCode = code } replyHeader state = do
})
})
replyTo
_
cr
@
CompleteRequest
{}
replyHeader
state
=
trace
(
show
cr
)
$
do
replyTo
_
creq
@
CompleteRequest
{}
replyHeader
state
=
trace
(
show
creq
)
$
do
return
(
state
,
CompleteReply
replyHeader
[]
""
True
)
cr
<-
makeCompletions
replyHeader
creq
return
(
state
,
cr
)
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