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
2e4b4d3e
Unverified
Commit
2e4b4d3e
authored
Jul 14, 2018
by
Vaibhav Sagar
Committed by
GitHub
Jul 14, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #886 from MMesch/jupyterlab_compatibility
Jupyterlab compatibility
parents
fbd91afb
ff6f1fa7
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
1681 additions
and
19 deletions
+1681
-19
README.md
README.md
+7
-0
.gitignore
ihaskell_labextension/.gitignore
+5
-0
README.md
ihaskell_labextension/README.md
+32
-0
package-lock.json
ihaskell_labextension/package-lock.json
+850
-0
package.json
ihaskell_labextension/package.json
+46
-0
codemirror-ihaskell.ts
ihaskell_labextension/src/codemirror-ihaskell.ts
+26
-0
index.ts
ihaskell_labextension/src/index.ts
+28
-0
index.css
ihaskell_labextension/style/index.css
+0
-0
tsconfig.json
ihaskell_labextension/tsconfig.json
+16
-0
yarn.lock
ihaskell_labextension/yarn.lock
+633
-0
EasyKernel.hs
ipython-kernel/src/IHaskell/IPython/EasyKernel.hs
+8
-5
Parser.hs
ipython-kernel/src/IHaskell/IPython/Message/Parser.hs
+1
-2
Writer.hs
ipython-kernel/src/IHaskell/IPython/Message/Writer.hs
+13
-5
Types.hs
ipython-kernel/src/IHaskell/IPython/Types.hs
+2
-1
Main.hs
main/Main.hs
+9
-1
Widgets.hs
src/IHaskell/Eval/Widgets.hs
+4
-4
Publish.hs
src/IHaskell/Publish.hs
+1
-1
No files found.
README.md
View file @
2e4b4d3e
...
...
@@ -41,6 +41,13 @@ stack install --fast
ihaskell
install
--stack
```
if you want to use jupyterlab, you need to install the jupyterlab ihaskell
extension to get syntax highlighting with:
```
bash
jupyter labextension
install
ihaskell_labextension
```
## Mac
You need to have
[
Homebrew
](
https://brew.sh
)
installed.
...
...
ihaskell_labextension/.gitignore
0 → 100644
View file @
2e4b4d3e
*.bundle.*
lib/
node_modules/
*.egg-info/
.ipynb_checkpoints
ihaskell_labextension/README.md
0 → 100644
View file @
2e4b4d3e
# ihaskell_labextension
Haskell Syntax Highlighting in Jupyterlab
## Prerequisites
*
JupyterLab
## Installation
```
bash
jupyter labextension
install
ihaskell_labextension
```
## Development
For a development install (requires npm version 4 or later), do the following in the repository directory:
```
bash
npm
install
npm run build
jupyter labextension
link
.
```
To rebuild the package and the JupyterLab app:
```
bash
npm run build
jupyter lab build
```
ihaskell_labextension/package-lock.json
0 → 100644
View file @
2e4b4d3e
This diff is collapsed.
Click to expand it.
ihaskell_labextension/package.json
0 → 100644
View file @
2e4b4d3e
{
"name"
:
"ihaskell_jupyterlab"
,
"version"
:
"0.0.1"
,
"description"
:
"JupyterLab extension"
,
"keywords"
:
[
"jupyter"
,
"jupyterlab"
,
"jupyterlab-extension"
],
"homepage"
:
"https://github.com/xxx"
,
"bugs"
:
{
"url"
:
"https://github.com/xxx/issues"
},
"license"
:
"BSD-3-Clause"
,
"author"
:
"MMesch"
,
"files"
:
[
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}"
,
"style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}"
],
"main"
:
"lib/index.js"
,
"types"
:
"lib/index.d.ts"
,
"repository"
:
{
"type"
:
"git"
,
"url"
:
"https://github.com/xxx/jupyterlab-sos.git"
},
"scripts"
:
{
"build"
:
"tsc"
,
"clean"
:
"rimraf lib"
,
"watch"
:
"tsc -w"
},
"dependencies"
:
{
"@jupyterlab/application"
:
"^0.16.1"
,
"@jupyterlab/apputils"
:
"^0.16.2"
,
"@jupyterlab/docregistry"
:
"^0.16.1"
,
"@jupyterlab/notebook"
:
"^0.16.1"
,
"@jupyterlab/services"
:
"^2.0.1"
,
"@phosphor/disposable"
:
"^1.1.2"
},
"devDependencies"
:
{
"rimraf"
:
"^2.6.1"
,
"typescript"
:
"~2.6.0"
},
"jupyterlab"
:
{
"extension"
:
true
}
}
ihaskell_labextension/src/codemirror-ihaskell.ts
0 → 100644
View file @
2e4b4d3e
import
*
as
CodeMirror
from
'codemirror'
;
import
'codemirror/lib/codemirror'
;
import
'codemirror/mode/haskell/haskell'
;
CodeMirror
.
defineMode
(
"ihaskell"
,
(
config
)
=>
{
let
hmode
=
CodeMirror
.
getMode
(
config
,
"haskell"
);
return
CodeMirror
.
multiplexingMode
(
hmode
,
{
open
:
/:
(?=
!
)
/
,
// Matches : followed by !, but doesn't consume !
close
:
/^
(?!
!
)
/
,
// Matches start of line not followed by !, doesn't consume character
mode
:
CodeMirror
.
getMode
(
config
,
"text/plain"
),
delimStyle
:
"delimit"
}
);
});
CodeMirror
.
defineMIME
(
"text/x-ihaskell"
,
"ihaskell"
);
CodeMirror
.
modeInfo
.
push
({
ext
:
[
'hs'
],
mime
:
"text/x-ihaskell"
,
mode
:
'ihaskell'
,
name
:
'ihaskell'
});
ihaskell_labextension/src/index.ts
0 → 100644
View file @
2e4b4d3e
import
{
JupyterLab
,
JupyterLabPlugin
}
from
'@jupyterlab/application'
;
import
'./codemirror-ihaskell'
;
import
'../style/index.css'
;
/**
* Initialization data for the extension1 extension.
*/
const
extension
:
JupyterLabPlugin
<
void
>
=
{
id
:
'ihaskell'
,
autoStart
:
true
,
requires
:
[],
activate
:
(
app
:
JupyterLab
)
=>
{
app
.
serviceManager
.
ready
.
then
(()
=>
{
defineIHaskell
()});
}
};
function
defineIHaskell
()
{
console
.
log
(
'ihaskell codemirror activated'
);
}
export
default
extension
;
ihaskell_labextension/style/index.css
0 → 100644
View file @
2e4b4d3e
ihaskell_labextension/tsconfig.json
0 → 100644
View file @
2e4b4d3e
{
"compilerOptions"
:
{
"declaration"
:
true
,
"noImplicitAny"
:
false
,
"noEmitOnError"
:
true
,
"noUnusedLocals"
:
true
,
"allowSyntheticDefaultImports"
:
true
,
"module"
:
"commonjs"
,
"moduleResolution"
:
"node"
,
"target"
:
"es2015"
,
"outDir"
:
"./lib"
,
"lib"
:
[
"dom"
,
"es2015"
],
"types"
:
[]
},
"include"
:
[
"src/*"
]
}
ihaskell_labextension/yarn.lock
0 → 100644
View file @
2e4b4d3e
This diff is collapsed.
Click to expand it.
ipython-kernel/src/IHaskell/IPython/EasyKernel.hs
View file @
2e4b4d3e
...
...
@@ -163,7 +163,12 @@ replyTo :: MonadIO m
->
Message
->
MessageHeader
->
m
Message
replyTo
config
_
_
KernelInfoRequest
{}
replyHeader
=
replyTo
config
_
interface
KernelInfoRequest
{}
replyHeader
=
do
let
send
=
writeChan
(
iopubChannel
interface
)
idleHeader
<-
dupHeader
replyHeader
StatusMessage
liftIO
.
send
$
PublishStatus
idleHeader
Idle
return
KernelInfoReply
{
header
=
replyHeader
...
...
@@ -172,6 +177,7 @@ replyTo config _ _ KernelInfoRequest{} replyHeader =
,
implementationVersion
=
kernelImplVersion
config
,
banner
=
kernelBanner
config
,
protocolVersion
=
kernelProtocolVersion
config
,
status
=
Ok
}
replyTo
config
_
_
CommInfoRequest
{}
replyHeader
=
...
...
@@ -198,12 +204,9 @@ replyTo config execCount interface req@ExecuteRequest { getCode = code } replyHe
sendOutput
x
=
send
$
PublishDisplayData
outputHeader
(
languageName
$
kernelLanguageInfo
config
)
(
displayOutput
config
x
)
in
run
config
code
clearOutput
sendOutput
liftIO
.
send
$
PublishDisplayData
outputHeader
(
languageName
$
kernelLanguageInfo
config
)
(
displayResult
config
res
)
liftIO
.
send
$
PublishDisplayData
outputHeader
(
displayResult
config
res
)
idleHeader
<-
dupHeader
replyHeader
StatusMessage
...
...
ipython-kernel/src/IHaskell/IPython/Message/Parser.hs
View file @
2e4b4d3e
...
...
@@ -178,8 +178,7 @@ displayDataParser :: LByteString -> Message
displayDataParser
=
requestParser
$
\
obj
->
do
dataDict
::
Object
<-
obj
.:
"data"
let
displayDatas
=
makeDisplayDatas
dataDict
maybeSource
<-
obj
.:?
"source"
return
$
PublishDisplayData
noHeader
(
fromMaybe
""
maybeSource
)
displayDatas
return
$
PublishDisplayData
noHeader
displayDatas
requestParser
parser
content
=
case
parseEither
parser
decoded
of
...
...
ipython-kernel/src/IHaskell/IPython/Message/Writer.hs
View file @
2e4b4d3e
...
...
@@ -20,6 +20,7 @@ instance ToJSON LanguageInfo where
,
"version"
.=
languageVersion
info
,
"file_extension"
.=
languageFileExtension
info
,
"codemirror_mode"
.=
languageCodeMirrorMode
info
,
"pygments_lexer"
.=
languagePygmentsLexer
info
]
-- Convert message bodies into JSON.
...
...
@@ -31,6 +32,7 @@ instance ToJSON Message where
,
"implementation"
.=
implementation
rep
,
"implementation_version"
.=
implementationVersion
rep
,
"language_info"
.=
languageInfo
rep
,
"status"
.=
show
(
status
rep
)
]
toJSON
CommInfoReply
...
...
@@ -38,7 +40,9 @@ instance ToJSON Message where
,
commInfo
=
commInfo
}
=
object
[
"comms"
.=
Map
.
map
(
\
comm
->
object
[
"target_name"
.=
comm
])
commInfo
]
[
"comms"
.=
Map
.
map
(
\
comm
->
object
[
"target_name"
.=
comm
])
commInfo
,
"status"
.=
string
"ok"
]
toJSON
ExecuteRequest
{
getCode
=
code
...
...
@@ -76,9 +80,9 @@ instance ToJSON Message where
object
[
"execution_state"
.=
executionState
]
toJSON
PublishStream
{
streamType
=
streamType
,
streamContent
=
content
}
=
object
[
"data"
.=
content
,
"name"
.=
streamType
]
toJSON
PublishDisplayData
{
source
=
src
,
displayData
=
datas
}
=
toJSON
PublishDisplayData
{
displayData
=
datas
}
=
object
[
"
source"
.=
src
,
"
metadata"
.=
object
[]
,
"data"
.=
object
(
map
displayDataToJson
datas
)]
[
"metadata"
.=
object
[]
,
"data"
.=
object
(
map
displayDataToJson
datas
)]
toJSON
PublishOutput
{
executionCount
=
execCount
,
reprText
=
reprText
}
=
object
...
...
@@ -109,7 +113,9 @@ instance ToJSON Message where
]
toJSON
ShutdownReply
{
restartPending
=
restart
}
=
object
[
"restart"
.=
restart
]
object
[
"restart"
.=
restart
,
"status"
.=
string
"ok"
]
toJSON
ClearOutput
{
wait
=
wait
}
=
object
[
"wait"
.=
wait
]
...
...
@@ -132,7 +138,9 @@ instance ToJSON Message where
object
[
"comm_id"
.=
commUuid
req
,
"data"
.=
commData
req
]
toJSON
req
@
HistoryReply
{}
=
object
[
"history"
.=
map
tuplify
(
historyReply
req
)]
object
[
"history"
.=
map
tuplify
(
historyReply
req
)
,
"status"
.=
string
"ok"
]
where
tuplify
(
HistoryReplyElement
sess
linum
res
)
=
(
sess
,
linum
,
case
res
of
Left
inp
->
toJSON
inp
...
...
ipython-kernel/src/IHaskell/IPython/Types.hs
View file @
2e4b4d3e
...
...
@@ -276,6 +276,7 @@ data LanguageInfo =
,
languageVersion
::
String
-- ^ GHC 7.6.3
,
languageFileExtension
::
String
-- ^ .hs
,
languageCodeMirrorMode
::
String
-- ^ 'ihaskell'. can be 'null'
,
languagePygmentsLexer
::
String
}
deriving
(
Show
,
Eq
)
...
...
@@ -299,6 +300,7 @@ data Message =
,
implementation
::
String
-- ^ e.g. IHaskell
,
implementationVersion
::
String
-- ^ The version of the implementation
,
languageInfo
::
LanguageInfo
,
status
::
ExecuteReplyStatus
}
|
-- | A request from a frontend for information about the comms.
...
...
@@ -366,7 +368,6 @@ data Message =
|
PublishDisplayData
{
header
::
MessageHeader
,
source
::
String
-- ^ The name of the data source.
,
displayData
::
[
DisplayData
]
-- ^ A list of data representations.
}
|
...
...
main/Main.hs
View file @
2e4b4d3e
...
...
@@ -255,7 +255,13 @@ replyTo :: ZeroMQInterface -> Message -> MessageHeader -> KernelState -> Interpr
-- Reply to kernel info requests with a kernel info reply. No computation needs to be done, as a
-- kernel info reply is a static object (all info is hard coded into the representation of that
-- message type).
replyTo
_
KernelInfoRequest
{}
replyHeader
state
=
replyTo
interface
KernelInfoRequest
{}
replyHeader
state
=
do
let
send
msg
=
liftIO
$
writeChan
(
iopubChannel
interface
)
msg
-- Notify the frontend that the Kernel is idle
idleHeader
<-
liftIO
$
dupHeader
replyHeader
StatusMessage
send
$
PublishStatus
idleHeader
Idle
return
(
state
,
KernelInfoReply
{
header
=
replyHeader
...
...
@@ -268,7 +274,9 @@ replyTo _ KernelInfoRequest{} replyHeader state =
,
languageVersion
=
VERSION_ghc
,
languageFileExtension
=
".hs"
,
languageCodeMirrorMode
=
"ihaskell"
,
languagePygmentsLexer
=
"Haskell"
}
,
status
=
Ok
})
replyTo
_
CommInfoRequest
{}
replyHeader
state
=
...
...
src/IHaskell/Eval/Widgets.hs
View file @
2e4b4d3e
...
...
@@ -145,7 +145,7 @@ handleMessage send replyHeader state msg = do
DispMsg
widget
disp
->
do
dispHeader
<-
dupHeader
replyHeader
DisplayDataMessage
let
dmsg
=
WidgetDisplay
dispHeader
"haskell"
$
unwrap
disp
let
dmsg
=
WidgetDisplay
dispHeader
$
unwrap
disp
sendMessage
widget
(
toJSON
$
CustomContent
$
toJSON
dmsg
)
ClrOutput
widget
wait
->
do
...
...
@@ -170,11 +170,11 @@ handleMessage send replyHeader state msg = do
unwrap
(
Display
ddatas
)
=
ddatas
-- Override toJSON for PublishDisplayData for sending Display messages through [method .= custom]
data
WidgetDisplay
=
WidgetDisplay
MessageHeader
String
[
DisplayData
]
data
WidgetDisplay
=
WidgetDisplay
MessageHeader
[
DisplayData
]
instance
ToJSON
WidgetDisplay
where
toJSON
(
WidgetDisplay
replyHeader
source
ddata
)
=
let
pbval
=
toJSON
$
PublishDisplayData
replyHeader
source
ddata
toJSON
(
WidgetDisplay
replyHeader
ddata
)
=
let
pbval
=
toJSON
$
PublishDisplayData
replyHeader
ddata
in
toJSON
$
IPythonMessage
replyHeader
pbval
DisplayDataMessage
-- Override toJSON for ClearOutput
...
...
src/IHaskell/Publish.hs
View file @
2e4b4d3e
...
...
@@ -63,7 +63,7 @@ publishResult send replyHeader displayed updateNeeded pagerOutput usePager resul
sendOutput
(
ManyDisplay
manyOuts
)
=
mapM_
sendOutput
manyOuts
sendOutput
(
Display
outs
)
=
do
header
<-
dupHeader
replyHeader
DisplayDataMessage
send
$
PublishDisplayData
header
"haskell"
$
map
(
convertSvgToHtml
.
prependCss
)
outs
send
$
PublishDisplayData
header
$
map
(
convertSvgToHtml
.
prependCss
)
outs
convertSvgToHtml
(
DisplayData
MimeSvg
svg
)
=
html
$
makeSvgImg
$
base64
$
E
.
encodeUtf8
svg
convertSvgToHtml
x
=
x
...
...
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