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
6cb1c4c5
Commit
6cb1c4c5
authored
Mar 02, 2015
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial refactoring of startup and kernelspec installation
parent
2138b81e
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
219 additions
and
336 deletions
+219
-336
Kernel.hs
ipython-kernel/src/IHaskell/IPython/Kernel.hs
+6
-10
Types.hs
ipython-kernel/src/IHaskell/IPython/Types.hs
+19
-0
Flags.hs
src/IHaskell/Flags.hs
+8
-8
IPython.hs
src/IHaskell/IPython.hs
+170
-288
Types.hs
src/IHaskell/Types.hs
+1
-0
Main.hs
src/Main.hs
+15
-30
No files found.
ipython-kernel/src/IHaskell/IPython/Kernel.hs
View file @
6cb1c4c5
...
...
@@ -2,15 +2,11 @@
-- IPython language kernel that supports the @ipython console@ and @ipython
-- notebook@ frontends.
module
IHaskell.IPython.Kernel
(
module
IHaskell
.
IPython
.
Types
,
module
IHaskell
.
IPython
.
Message
.
Writer
,
module
IHaskell
.
IPython
.
Message
.
Parser
,
module
IHaskell
.
IPython
.
Message
.
UUID
,
module
IHaskell
.
IPython
.
ZeroMQ
,
module
X
,
)
where
import
IHaskell.IPython.Types
import
IHaskell.IPython.Message.Writer
import
IHaskell.IPython.Message.Parser
import
IHaskell.IPython.Message.UUID
import
IHaskell.IPython.ZeroMQ
import
IHaskell.IPython.Types
as
X
import
IHaskell.IPython.Message.Writer
as
X
import
IHaskell.IPython.Message.Parser
as
X
import
IHaskell.IPython.Message.UUID
as
X
import
IHaskell.IPython.ZeroMQ
as
X
ipython-kernel/src/IHaskell/IPython/Types.hs
View file @
6cb1c4c5
...
...
@@ -8,6 +8,9 @@ module IHaskell.IPython.Types (
Port
(
..
),
IP
(
..
),
-- * IPython kernelspecs
KernelSpec
(
..
),
-- * IPython messaging protocol
Message
(
..
),
MessageHeader
(
..
),
...
...
@@ -100,6 +103,22 @@ instance ToJSON Transport where
toJSON
TCP
=
String
"tcp"
-------------------- IPython Kernelspec Types ----------------------
data
KernelSpec
=
KernelSpec
{
kernelDisplayName
::
String
,
-- ^ Name shown to users to describe this kernel (e.g. "Haskell")
kernelLanguage
::
String
,
-- ^ Name for the kernel; unique kernel identifier (e.g. "haskell")
kernelCommand
::
[
String
]
-- ^ Command to run to start the kernel. One of the strings may be
-- @"{connection_file}"@, which will be replaced by the path to a
-- kernel profile file (see @Profile@) when the command is run.
}
deriving
(
Eq
,
Show
)
instance
ToJSON
KernelSpec
where
toJSON
kernelspec
=
object
[
"argv"
.=
kernelCommand
kernelspec
,
"display_name"
.=
kernelDisplayName
kernelspec
,
"language"
.=
kernelLanguage
kernelspec
]
-------------------- IPython Message Types ----------------------
-- | A message header with some metadata.
...
...
src/IHaskell/Flags.hs
View file @
6cb1c4c5
...
...
@@ -24,7 +24,6 @@ data Args = Args IHaskellMode [Argument]
data
Argument
=
ServeFrom
String
-- ^ Which directory to serve notebooks from.
|
Extension
String
-- ^ An extension to load at startup.
|
ConfFile
String
-- ^ A file with commands to load at startup.
|
IPythonFrom
String
-- ^ Which executable to use for IPython.
|
OverwriteFiles
-- ^ Present when output should overwrite existing files.
|
ConvertFrom
String
|
ConvertTo
String
...
...
@@ -51,6 +50,7 @@ data NotebookFormat = LhsMarkdown
-- Which mode IHaskell is being invoked in.
-- `None` means no mode was specified.
data
IHaskellMode
=
ShowHelp
String
|
InstallKernelSpec
|
Notebook
|
Console
|
ConvertLhs
...
...
@@ -76,20 +76,18 @@ parseFlags flags =
modeFlags
=
concatMap
modeNames
allModes
allModes
::
[
Mode
Args
]
allModes
=
[
console
,
notebook
,
view
,
kernel
,
convert
]
allModes
=
[
installKernelSpec
,
console
,
notebook
,
view
,
kernel
,
convert
]
-- | Get help text for a given IHaskell ode.
help
::
IHaskellMode
->
String
help
mode
=
showText
(
Wrap
100
)
$
helpText
[]
HelpFormatAll
$
chooseMode
mode
where
chooseMode
Console
=
console
chooseMode
InstallKernelSpec
=
installKernelSpec
chooseMode
Notebook
=
notebook
chooseMode
(
Kernel
_
)
=
kernel
chooseMode
ConvertLhs
=
convert
ipythonFlag
::
Flag
Args
ipythonFlag
=
flagReq
[
"ipython"
,
"i"
]
(
store
IPythonFrom
)
"<path>"
"Executable for IPython."
ghcLibFlag
::
Flag
Args
ghcLibFlag
=
flagReq
[
"ghclib"
,
"l"
]
(
store
GhcLibDir
)
"<path>"
"Library directory for GHC."
...
...
@@ -109,11 +107,13 @@ store constructor str (Args mode prev) = Right $ Args mode $ constructor str : p
notebook
::
Mode
Args
notebook
=
mode
"notebook"
(
Args
Notebook
[]
)
"Browser-based notebook interface."
noArgs
$
flagReq
[
"serve"
,
"s"
]
(
store
ServeFrom
)
"<dir>"
"Directory to serve notebooks from."
:
ipythonFlag
:
universalFlags
console
::
Mode
Args
console
=
mode
"console"
(
Args
Console
[]
)
"Console-based interactive repl."
noArgs
$
ipythonFlag
:
universalFlags
console
=
mode
"console"
(
Args
Console
[]
)
"Console-based interactive repl."
noArgs
universalFlags
installKernelSpec
::
Mode
Args
installKernelSpec
=
mode
"install"
(
Args
InstallKernelSpec
[]
)
"Install the Jupyter kernelspec."
noArgs
[]
kernel
::
Mode
Args
kernel
=
mode
"kernel"
(
Args
(
Kernel
Nothing
)
[]
)
"Invoke the IHaskell kernel."
kernelArg
[
ghcLibFlag
]
...
...
@@ -186,7 +186,7 @@ view =
}
where
flags
=
[
ipythonFlag
,
flagHelpSimple
(
add
Help
)]
flags
=
[
flagHelpSimple
(
add
Help
)]
formatArg
=
flagArg
updateFmt
"<format>"
filenameArg
=
flagArg
updateFile
"<name>[.ipynb]"
updateFmt
fmtStr
(
Args
(
View
_
s
)
flags
)
=
...
...
src/IHaskell/IPython.hs
View file @
6cb1c4c5
This diff is collapsed.
Click to expand it.
src/IHaskell/Types.hs
View file @
6cb1c4c5
...
...
@@ -29,6 +29,7 @@ module IHaskell.Types (
IHaskellWidget
(
..
),
Widget
(
..
),
CommInfo
(
..
),
KernelSpec
(
..
),
)
where
import
ClassyPrelude
...
...
src/Main.hs
View file @
6cb1c4c5
...
...
@@ -52,33 +52,19 @@ main = do
Left
errorMessage
->
hPutStrLn
stderr
errorMessage
Right
args
->
ihaskell
args
chooseIPython
[]
=
return
DefaultIPython
chooseIPython
(
IPythonFrom
path
:
_
)
=
ExplicitIPython
<$>
subHome
path
chooseIPython
(
_
:
xs
)
=
chooseIPython
xs
ihaskell
::
Args
->
IO
()
-- If no mode is specified, print help text.
ihaskell
(
Args
(
ShowHelp
help
)
_
)
=
putStrLn
$
pack
help
ihaskell
(
Args
ConvertLhs
args
)
=
showingHelp
ConvertLhs
args
$
convert
args
ihaskell
(
Args
Console
flags
)
=
showingHelp
Console
flags
$
do
ipython
<-
chooseIPython
flags
setupIPython
ipython
ihaskell
(
Args
InstallKernelSpec
_
)
=
withIPython
$
return
()
ihaskell
(
Args
Console
flags
)
=
showingHelp
Console
flags
$
withIPython
$
do
flags
<-
addDefaultConfFile
flags
info
<-
initInfo
IPythonConsole
flags
runConsole
ipython
info
ihaskell
(
Args
mode
@
(
View
(
Just
fmt
)
(
Just
name
))
args
)
=
showingHelp
mode
args
$
do
ipython
<-
chooseIPython
args
nbconvert
ipython
fmt
name
ihaskell
(
Args
Notebook
flags
)
=
showingHelp
Notebook
flags
$
do
ipython
<-
chooseIPython
flags
setupIPython
ipython
let
server
=
case
mapMaybe
serveDir
flags
of
runConsole
info
ihaskell
(
Args
mode
@
(
View
(
Just
fmt
)
(
Just
name
))
args
)
=
showingHelp
mode
args
$
withIPython
$
nbconvert
fmt
name
ihaskell
(
Args
Notebook
flags
)
=
showingHelp
Notebook
flags
$
withIPython
$
do
let
server
=
case
mapMaybe
serveDir
flags
of
[]
->
Nothing
xs
->
Just
$
last
xs
...
...
@@ -88,21 +74,20 @@ ihaskell (Args Notebook flags) = showingHelp Notebook flags $ do
curdir
<-
getCurrentDirectory
let
info
=
undirInfo
{
initDir
=
curdir
}
runNotebook
i
python
info
server
runNotebook
i
nfo
(
pack
<$>
server
)
where
serveDir
(
ServeFrom
dir
)
=
Just
dir
serveDir
_
=
Nothing
ihaskell
(
Args
(
Kernel
(
Just
filename
))
flags
)
=
do
initInfo
<-
readInitInfo
runKernel
libdir
filename
initInfo
where
libdir
=
case
flags
of
libdir
=
case
flags
of
[]
->
GHC
.
Paths
.
libdir
[
GhcLibDir
dir
]
->
dir
-- | Add a conf file to the arguments if none exists.
addDefaultConfFile
::
[
Argument
]
->
IO
[
Argument
]
addDefaultConfFile
flags
=
do
...
...
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