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
a061e229
Commit
a061e229
authored
Aug 25, 2015
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update to newest kernel_info_reply protocol
parent
45011f5a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
21 deletions
+48
-21
.gitignore
.gitignore
+1
-0
ipython-kernel.cabal
ipython-kernel/ipython-kernel.cabal
+1
-1
EasyKernel.hs
ipython-kernel/src/IHaskell/IPython/EasyKernel.hs
+10
-12
Writer.hs
ipython-kernel/src/IHaskell/IPython/Message/Writer.hs
+15
-3
Types.hs
ipython-kernel/src/IHaskell/IPython/Types.hs
+13
-3
Main.hs
main/Main.hs
+8
-2
No files found.
.gitignore
View file @
a061e229
*.hi
Untitled*.ipynb
main/Main
.stack-work
notebooks/Test.ipynb
...
...
ipython-kernel/ipython-kernel.cabal
View file @
a061e229
name: ipython-kernel
version: 0.
6.1.3
version: 0.
7
synopsis: A library for creating kernels for IPython frontends
description: ipython-kernel is a library for communicating with frontends for the interactive IPython framework. It is used extensively in IHaskell, the interactive Haskell environment.
...
...
ipython-kernel/src/IHaskell/IPython/EasyKernel.hs
View file @
a061e229
...
...
@@ -70,11 +70,8 @@ import System.IO (openFile, IOMode(ReadMode))
data
KernelConfig
m
output
result
=
KernelConfig
{
-- | The name of the language. This field is used to calculate the name of the profile,
-- so it should contain characters that are reasonable to have in file names.
languageName
::
String
-- | The version of the language
,
languageVersion
::
[
Int
]
-- | Info on the language of the kernel.
kernelLanguageInfo
::
LanguageInfo
-- | Determine the source of a profile to install using 'installProfile'. The source should be a
-- tarball whose contents will be unpacked directly into the profile directory. For example, the
-- file whose name is @ipython_config.py@ in the tar file for a language named @lang@ will end up in
...
...
@@ -122,7 +119,7 @@ installProfile config = do
where
profDir
=
do
home
<-
liftIO
getHomeDirectory
return
$
home
</>
".ipython"
</>
(
"profile_"
++
languageName
config
)
return
$
home
</>
".ipython"
</>
(
"profile_"
++
languageName
(
kernelLanguageInfo
config
)
)
isInstalled
=
do
prof
<-
profDir
dirThere
<-
liftIO
$
doesDirectoryExist
prof
...
...
@@ -185,8 +182,9 @@ replyTo config _ _ KernelInfoRequest{} replyHeader =
return
KernelInfoReply
{
header
=
replyHeader
,
language
=
languageName
config
,
versionList
=
languageVersion
config
,
languageInfo
=
kernelLanguageInfo
config
,
implementation
=
"ipython-kernel.EasyKernel"
,
implementationVersion
=
"0.0"
}
replyTo
config
_
interface
ShutdownRequest
{
restartPending
=
pending
}
replyHeader
=
do
liftIO
$
writeChan
(
shellReplyChannel
interface
)
$
ShutdownReply
replyHeader
pending
...
...
@@ -206,10 +204,10 @@ replyTo config execCount interface req@ExecuteRequest { getCode = code } replyHe
sendOutput
x
=
send
$
PublishDisplayData
outputHeader
(
languageName
config
)
(
languageName
$
kernelLanguageInfo
config
)
(
displayOutput
config
x
)
in
run
config
code
clearOutput
sendOutput
liftIO
.
send
$
PublishDisplayData
outputHeader
(
languageName
config
)
(
displayResult
config
res
)
liftIO
.
send
$
PublishDisplayData
outputHeader
(
languageName
$
kernelLanguageInfo
config
)
(
displayResult
config
res
)
idleHeader
<-
dupHeader
replyHeader
StatusMessage
...
...
@@ -230,8 +228,8 @@ replyTo config _ _ req@CompleteRequest{} replyHeader =
-- TODO: FIX
error
"Completion: Unimplemented for IPython 3.0"
replyTo
_
_
_
InspectRequest
{}
_
=
do
error
$
"Inspection: Unimplemented for IPython 3.0"
replyTo
_
_
_
InspectRequest
{}
_
=
error
"Inspection: Unimplemented for IPython 3.0"
replyTo
_
_
_
msg
_
=
do
liftIO
$
putStrLn
"Unknown message: "
...
...
ipython-kernel/src/IHaskell/IPython/Message/Writer.hs
View file @
a061e229
...
...
@@ -16,11 +16,23 @@ import Data.Text.Encoding
import
IHaskell.IPython.Types
instance
ToJSON
LanguageInfo
where
toJSON
info
=
object
[
"name"
.=
languageName
info
,
"version"
.=
languageVersion
info
,
"file_extension"
.=
languageFileExtension
info
,
"codemirror_mode"
.=
languageCodeMirrorMode
info
]
-- Convert message bodies into JSON.
instance
ToJSON
Message
where
toJSON
KernelInfoReply
{
versionList
=
vers
,
language
=
language
}
=
object
[
"protocol_version"
.=
string
"5.0"
-- current protocol version, major and minor
,
"language_version"
.=
vers
,
"language"
.=
language
]
toJSON
rep
@
KernelInfoReply
{}
=
object
[
"protocol_version"
.=
string
"5.0"
-- current protocol version, major and minor
,
"implementation"
.=
implementation
rep
,
"implementation_version"
.=
implementationVersion
rep
,
"language_info"
.=
languageInfo
rep
]
toJSON
ExecuteReply
{
status
=
status
,
executionCounter
=
counter
,
pagerOutput
=
pager
}
=
object
...
...
ipython-kernel/src/IHaskell/IPython/Types.hs
View file @
a061e229
...
...
@@ -24,6 +24,7 @@ module IHaskell.IPython.Types (
ExecuteReplyStatus
(
..
),
HistoryAccessType
(
..
),
HistoryReplyElement
(
..
),
LanguageInfo
(
..
),
replyType
,
showMessageType
,
...
...
@@ -246,6 +247,15 @@ instance FromJSON MessageType where
_
->
fail
(
"Unknown message type: "
++
show
s
)
parseJSON
_
=
fail
"Must be a string."
data
LanguageInfo
=
LanguageInfo
{
languageName
::
String
-- ^ The language name, e.g. "haskell"
,
languageVersion
::
String
-- ^ GHC 7.6.3
,
languageFileExtension
::
String
-- ^ .hs
,
languageCodeMirrorMode
::
String
-- ^ 'ihaskell'. can be 'null'
}
deriving
(
Show
,
Eq
)
-- | A message used to communicate with the IPython frontend.
data
Message
=
-- | A request from a frontend for information about the kernel.
...
...
@@ -254,9 +264,9 @@ data Message =
-- | A response to a KernelInfoRequest.
KernelInfoReply
{
header
::
MessageHeader
,
versionList
::
[
Int
]
-- ^ The version of the language, e.g. [7, 6, 3] for GHC
-- 7.6.3
,
language
::
String
-- ^ The language name, e.g. "haskell"
,
implementation
::
String
-- ^ e.g. IHaskell
,
implementationVersion
::
String
-- ^ The version of the implementation
,
language
Info
::
LanguageInfo
}
|
-- | A request from a frontend to execute some code.
...
...
main/Main.hs
View file @
a061e229
...
...
@@ -229,8 +229,14 @@ replyTo _ KernelInfoRequest{} replyHeader state =
return
(
state
,
KernelInfoReply
{
header
=
replyHeader
,
language
=
"haskell"
,
versionList
=
ghcVersionInts
,
implementation
=
"IHaskell"
,
implementationVersion
=
VERSION_ipython_kernel
,
languageInfo
=
LanguageInfo
{
languageName
=
"haskell"
,
languageVersion
=
VERSION_ghc
,
languageFileExtension
=
".hs"
,
languageCodeMirrorMode
=
"ihaskell"
}
})
-- Reply to a shutdown request by exiting the main thread. Before shutdown, reply to the request to
...
...
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