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
be3d44eb
Commit
be3d44eb
authored
Sep 12, 2015
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #569 from sumitsahrawat/widgets-4.0
Make widget messages match with IPywidgets
parents
fe02d7db
3d08910f
Changes
37
Show whitespace changes
Inline
Side-by-side
Showing
37 changed files
with
136 additions
and
123 deletions
+136
-123
CheckBox.hs
...ell-widgets/src/IHaskell/Display/Widgets/Bool/CheckBox.hs
+1
-3
ToggleButton.hs
...widgets/src/IHaskell/Display/Widgets/Bool/ToggleButton.hs
+1
-3
Box.hs
.../ihaskell-widgets/src/IHaskell/Display/Widgets/Box/Box.hs
+1
-2
FlexBox.hs
...skell-widgets/src/IHaskell/Display/Widgets/Box/FlexBox.hs
+1
-2
Accordion.hs
...skell/Display/Widgets/Box/SelectionContainer/Accordion.hs
+1
-3
Tab.hs
...rc/IHaskell/Display/Widgets/Box/SelectionContainer/Tab.hs
+1
-2
Button.hs
...y/ihaskell-widgets/src/IHaskell/Display/Widgets/Button.hs
+1
-3
Common.hs
...y/ihaskell-widgets/src/IHaskell/Display/Widgets/Common.hs
+2
-0
BoundedFloatText.hs
...ll/Display/Widgets/Float/BoundedFloat/BoundedFloatText.hs
+1
-5
FloatProgress.hs
...skell/Display/Widgets/Float/BoundedFloat/FloatProgress.hs
+4
-6
FloatSlider.hs
...Haskell/Display/Widgets/Float/BoundedFloat/FloatSlider.hs
+1
-3
FloatRangeSlider.hs
...splay/Widgets/Float/BoundedFloatRange/FloatRangeSlider.hs
+1
-5
FloatText.hs
...l-widgets/src/IHaskell/Display/Widgets/Float/FloatText.hs
+1
-3
Image.hs
...ay/ihaskell-widgets/src/IHaskell/Display/Widgets/Image.hs
+3
-3
BoundedIntText.hs
...IHaskell/Display/Widgets/Int/BoundedInt/BoundedIntText.hs
+1
-5
IntProgress.hs
...rc/IHaskell/Display/Widgets/Int/BoundedInt/IntProgress.hs
+4
-4
IntSlider.hs
.../src/IHaskell/Display/Widgets/Int/BoundedInt/IntSlider.hs
+1
-3
IntRangeSlider.hs
...ell/Display/Widgets/Int/BoundedIntRange/IntRangeSlider.hs
+1
-5
IntText.hs
...skell-widgets/src/IHaskell/Display/Widgets/Int/IntText.hs
+1
-2
Output.hs
...y/ihaskell-widgets/src/IHaskell/Display/Widgets/Output.hs
+1
-2
Dropdown.hs
...idgets/src/IHaskell/Display/Widgets/Selection/Dropdown.hs
+1
-3
RadioButtons.hs
...ts/src/IHaskell/Display/Widgets/Selection/RadioButtons.hs
+1
-3
Select.hs
...-widgets/src/IHaskell/Display/Widgets/Selection/Select.hs
+1
-2
SelectMultiple.hs
.../src/IHaskell/Display/Widgets/Selection/SelectMultiple.hs
+1
-5
ToggleButtons.hs
...s/src/IHaskell/Display/Widgets/Selection/ToggleButtons.hs
+1
-5
Singletons.hs
...askell-widgets/src/IHaskell/Display/Widgets/Singletons.hs
+2
-0
HTML.hs
...skell-widgets/src/IHaskell/Display/Widgets/String/HTML.hs
+1
-2
Latex.hs
...kell-widgets/src/IHaskell/Display/Widgets/String/Latex.hs
+1
-2
Text.hs
...skell-widgets/src/IHaskell/Display/Widgets/String/Text.hs
+1
-2
TextArea.hs
...l-widgets/src/IHaskell/Display/Widgets/String/TextArea.hs
+1
-3
Types.hs
...ay/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs
+28
-11
Parser.hs
ipython-kernel/src/IHaskell/IPython/Message/Parser.hs
+4
-3
Writer.hs
ipython-kernel/src/IHaskell/IPython/Message/Writer.hs
+6
-1
Types.hs
ipython-kernel/src/IHaskell/IPython/Types.hs
+2
-0
Main.hs
main/Main.hs
+39
-0
Widgets.hs
src/IHaskell/Eval/Widgets.hs
+8
-12
Types.hs
src/IHaskell/Types.hs
+9
-5
No files found.
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Bool/CheckBox.hs
View file @
be3d44eb
...
@@ -40,11 +40,9 @@ mkCheckBox = do
...
@@ -40,11 +40,9 @@ mkCheckBox = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.Checkbox"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the image widget
-- Return the image widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Bool/ToggleButton.hs
View file @
be3d44eb
...
@@ -45,11 +45,9 @@ mkToggleButton = do
...
@@ -45,11 +45,9 @@ mkToggleButton = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.ToggleButton"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the image widget
-- Return the image widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/Box.hs
View file @
be3d44eb
...
@@ -40,10 +40,9 @@ mkBox = do
...
@@ -40,10 +40,9 @@ mkBox = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
box
=
IPythonWidget
uuid
stateIO
let
box
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.Box"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
box
initData
$
toJSON
widgetState
widgetSendOpen
box
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
box
return
box
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/FlexBox.hs
View file @
be3d44eb
...
@@ -46,10 +46,9 @@ mkFlexBox = do
...
@@ -46,10 +46,9 @@ mkFlexBox = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
box
=
IPythonWidget
uuid
stateIO
let
box
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.FlexBox"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
box
initData
$
toJSON
widgetState
widgetSendOpen
box
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
box
return
box
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/SelectionContainer/Accordion.hs
View file @
be3d44eb
...
@@ -41,11 +41,9 @@ mkAccordion = do
...
@@ -41,11 +41,9 @@ mkAccordion = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
box
=
IPythonWidget
uuid
stateIO
let
box
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.Accordion"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
box
initData
$
toJSON
widgetState
widgetSendOpen
box
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
box
return
box
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/SelectionContainer/Tab.hs
View file @
be3d44eb
...
@@ -41,10 +41,9 @@ mkTabWidget = do
...
@@ -41,10 +41,9 @@ mkTabWidget = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
box
=
IPythonWidget
uuid
stateIO
let
box
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.Tab"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
box
initData
$
toJSON
widgetState
widgetSendOpen
box
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
box
return
box
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Button.hs
View file @
be3d44eb
...
@@ -49,10 +49,8 @@ mkButton = do
...
@@ -49,10 +49,8 @@ mkButton = do
let
button
=
IPythonWidget
uuid
stateIO
let
button
=
IPythonWidget
uuid
stateIO
let
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.Button"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
button
initData
$
toJSON
buttonState
widgetSendOpen
button
$
toJSON
buttonState
-- Return the button widget
-- Return the button widget
return
button
return
button
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Common.hs
View file @
be3d44eb
...
@@ -18,6 +18,8 @@ import qualified IHaskell.Display.Widgets.Singletons as S
...
@@ -18,6 +18,8 @@ import qualified IHaskell.Display.Widgets.Singletons as S
pattern
ViewModule
=
S
.
SViewModule
pattern
ViewModule
=
S
.
SViewModule
pattern
ViewName
=
S
.
SViewName
pattern
ViewName
=
S
.
SViewName
pattern
ModelModule
=
S
.
SModelModule
pattern
ModelName
=
S
.
SModelName
pattern
MsgThrottle
=
S
.
SMsgThrottle
pattern
MsgThrottle
=
S
.
SMsgThrottle
pattern
Version
=
S
.
SVersion
pattern
Version
=
S
.
SVersion
pattern
DisplayHandler
=
S
.
SDisplayHandler
pattern
DisplayHandler
=
S
.
SDisplayHandler
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloat/BoundedFloatText.hs
View file @
be3d44eb
...
@@ -42,13 +42,9 @@ mkBoundedFloatText = do
...
@@ -42,13 +42,9 @@ mkBoundedFloatText = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.BoundedFloatText"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloat/FloatProgress.hs
View file @
be3d44eb
...
@@ -38,19 +38,17 @@ mkFloatProgress = do
...
@@ -38,19 +38,17 @@ mkFloatProgress = do
uuid
<-
U
.
random
uuid
<-
U
.
random
let
boundedFloatAttrs
=
defaultBoundedFloatWidget
"ProgressView"
let
boundedFloatAttrs
=
defaultBoundedFloatWidget
"ProgressView"
progressAttrs
=
(
BarStyle
=::
DefaultBar
)
:&
RNil
progressAttrs
=
(
Orientation
=::
HorizontalOrientation
)
:&
(
BarStyle
=::
DefaultBar
)
:&
RNil
widgetState
=
WidgetState
$
boundedFloatAttrs
<+>
progressAttrs
widgetState
=
WidgetState
$
boundedFloatAttrs
<+>
progressAttrs
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.FloatProgress"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloat/FloatSlider.hs
View file @
be3d44eb
...
@@ -47,11 +47,9 @@ mkFloatSlider = do
...
@@ -47,11 +47,9 @@ mkFloatSlider = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.FloatSlider"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloatRange/FloatRangeSlider.hs
View file @
be3d44eb
...
@@ -50,13 +50,9 @@ mkFloatRangeSlider = do
...
@@ -50,13 +50,9 @@ mkFloatRangeSlider = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.FloatRangeSlider"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/FloatText.hs
View file @
be3d44eb
...
@@ -41,11 +41,9 @@ mkFloatText = do
...
@@ -41,11 +41,9 @@ mkFloatText = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.FloatText"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Image.hs
View file @
be3d44eb
...
@@ -38,6 +38,8 @@ mkImageWidget = do
...
@@ -38,6 +38,8 @@ mkImageWidget = do
let
dom
=
defaultDOMWidget
"ImageView"
let
dom
=
defaultDOMWidget
"ImageView"
img
=
(
ImageFormat
=::
PNG
)
img
=
(
ImageFormat
=::
PNG
)
:&
(
Width
=:+
0
)
:&
(
Height
=:+
0
)
:&
(
B64Value
=::
mempty
)
:&
(
B64Value
=::
mempty
)
:&
RNil
:&
RNil
widgetState
=
WidgetState
(
dom
<+>
img
)
widgetState
=
WidgetState
(
dom
<+>
img
)
...
@@ -46,10 +48,8 @@ mkImageWidget = do
...
@@ -46,10 +48,8 @@ mkImageWidget = do
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
let
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.Image"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the image widget
-- Return the image widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/BoundedIntText.hs
View file @
be3d44eb
...
@@ -41,13 +41,9 @@ mkBoundedIntText = do
...
@@ -41,13 +41,9 @@ mkBoundedIntText = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.BoundedIntText"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/IntProgress.hs
View file @
be3d44eb
...
@@ -38,17 +38,17 @@ mkIntProgress = do
...
@@ -38,17 +38,17 @@ mkIntProgress = do
uuid
<-
U
.
random
uuid
<-
U
.
random
let
boundedIntAttrs
=
defaultBoundedIntWidget
"ProgressView"
let
boundedIntAttrs
=
defaultBoundedIntWidget
"ProgressView"
progressAttrs
=
(
BarStyle
=::
DefaultBar
)
:&
RNil
progressAttrs
=
(
Orientation
=::
HorizontalOrientation
)
:&
(
BarStyle
=::
DefaultBar
)
:&
RNil
widgetState
=
WidgetState
$
boundedIntAttrs
<+>
progressAttrs
widgetState
=
WidgetState
$
boundedIntAttrs
<+>
progressAttrs
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.IntProgress"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/IntSlider.hs
View file @
be3d44eb
...
@@ -47,11 +47,9 @@ mkIntSlider = do
...
@@ -47,11 +47,9 @@ mkIntSlider = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.IntSlider"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedIntRange/IntRangeSlider.hs
View file @
be3d44eb
...
@@ -48,13 +48,9 @@ mkIntRangeSlider = do
...
@@ -48,13 +48,9 @@ mkIntRangeSlider = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.IntRangeSlider"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/IntText.hs
View file @
be3d44eb
...
@@ -41,10 +41,9 @@ mkIntText = do
...
@@ -41,10 +41,9 @@ mkIntText = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.IntText"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Output.hs
View file @
be3d44eb
...
@@ -45,10 +45,9 @@ mkOutputWidget = do
...
@@ -45,10 +45,9 @@ mkOutputWidget = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the image widget
-- Return the image widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/Dropdown.hs
View file @
be3d44eb
...
@@ -41,11 +41,9 @@ mkDropdown = do
...
@@ -41,11 +41,9 @@ mkDropdown = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.Dropdown"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/RadioButtons.hs
View file @
be3d44eb
...
@@ -39,11 +39,9 @@ mkRadioButtons = do
...
@@ -39,11 +39,9 @@ mkRadioButtons = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.RadioButtons"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/Select.hs
View file @
be3d44eb
...
@@ -39,10 +39,9 @@ mkSelect = do
...
@@ -39,10 +39,9 @@ mkSelect = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.Select"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/SelectMultiple.hs
View file @
be3d44eb
...
@@ -40,13 +40,9 @@ mkSelectMultiple = do
...
@@ -40,13 +40,9 @@ mkSelectMultiple = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.SelectMultiple"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/ToggleButtons.hs
View file @
be3d44eb
...
@@ -44,13 +44,9 @@ mkToggleButtons = do
...
@@ -44,13 +44,9 @@ mkToggleButtons = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.ToggleButtons"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Singletons.hs
View file @
be3d44eb
...
@@ -16,6 +16,8 @@ singletons
...
@@ -16,6 +16,8 @@ singletons
data Field = ViewModule
data Field = ViewModule
| ViewName
| ViewName
| ModelModule
| ModelName
| MsgThrottle
| MsgThrottle
| Version
| Version
| DisplayHandler
| DisplayHandler
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/HTML.hs
View file @
be3d44eb
...
@@ -37,10 +37,9 @@ mkHTMLWidget = do
...
@@ -37,10 +37,9 @@ mkHTMLWidget = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.HTML"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/Latex.hs
View file @
be3d44eb
...
@@ -37,10 +37,9 @@ mkLatexWidget = do
...
@@ -37,10 +37,9 @@ mkLatexWidget = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.Latex"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/Text.hs
View file @
be3d44eb
...
@@ -41,10 +41,9 @@ mkTextWidget = do
...
@@ -41,10 +41,9 @@ mkTextWidget = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.Text"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/TextArea.hs
View file @
be3d44eb
...
@@ -41,11 +41,9 @@ mkTextArea = do
...
@@ -41,11 +41,9 @@ mkTextArea = do
stateIO
<-
newIORef
widgetState
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
uuid
stateIO
let
widget
=
IPythonWidget
uuid
stateIO
initData
=
object
[
"model_name"
.=
str
"WidgetModel"
,
"widget_class"
.=
str
"IPython.Textarea"
]
-- Open a comm for this widget, and store it in the kernel state
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
initData
$
toJSON
widgetState
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
-- Return the widget
return
widget
return
widget
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs
View file @
be3d44eb
...
@@ -57,7 +57,7 @@ module IHaskell.Display.Widgets.Types where
...
@@ -57,7 +57,7 @@ module IHaskell.Display.Widgets.Types where
-- To know more about the IPython messaging specification (as implemented in this package) take a
-- To know more about the IPython messaging specification (as implemented in this package) take a
-- look at the supplied MsgSpec.md.
-- look at the supplied MsgSpec.md.
--
--
-- Widgets are not able to do console input, the reason for that can
also
be found in the messaging
-- Widgets are not able to do console input, the reason for that can be found in the messaging
-- specification
-- specification
import
Control.Monad
(
unless
,
join
,
when
,
void
,
mapM_
)
import
Control.Monad
(
unless
,
join
,
when
,
void
,
mapM_
)
import
Control.Applicative
((
<$>
))
import
Control.Applicative
((
<$>
))
...
@@ -89,8 +89,8 @@ import qualified IHaskell.Display.Widgets.Singletons as S
...
@@ -89,8 +89,8 @@ import qualified IHaskell.Display.Widgets.Singletons as S
import
IHaskell.Display.Widgets.Common
import
IHaskell.Display.Widgets.Common
-- Classes from IPython's widget hierarchy. Defined as such to reduce code duplication.
-- Classes from IPython's widget hierarchy. Defined as such to reduce code duplication.
type
WidgetClass
=
'[
S
.
ViewModule
,
S
.
ViewName
,
S
.
M
sgThrottle
,
S
.
Version
,
type
WidgetClass
=
'[
S
.
ViewModule
,
S
.
ViewName
,
S
.
M
odelModule
,
S
.
ModelName
,
S
.
DisplayHandler
]
S
.
MsgThrottle
,
S
.
Version
,
S
.
DisplayHandler
]
type
DOMWidgetClass
=
WidgetClass
:++
'[
S
.
Visible
,
S
.
CSS
,
S
.
DOMClasses
,
S
.
Width
,
S
.
Height
,
S
.
Padding
,
type
DOMWidgetClass
=
WidgetClass
:++
'[
S
.
Visible
,
S
.
CSS
,
S
.
DOMClasses
,
S
.
Width
,
S
.
Height
,
S
.
Padding
,
S
.
Margin
,
S
.
Color
,
S
.
BackgroundColor
,
S
.
BorderColor
,
S
.
BorderWidth
,
S
.
Margin
,
S
.
Color
,
S
.
BackgroundColor
,
S
.
BorderColor
,
S
.
BorderWidth
,
...
@@ -104,7 +104,7 @@ type BoolClass = DOMWidgetClass :++ '[S.BoolValue, S.Disabled, S.Description, S.
...
@@ -104,7 +104,7 @@ type BoolClass = DOMWidgetClass :++ '[S.BoolValue, S.Disabled, S.Description, S.
type
SelectionClass
=
DOMWidgetClass
:++
'[
S
.
Options
,
S
.
SelectedValue
,
S
.
SelectedLabel
,
S
.
Disabled
,
type
SelectionClass
=
DOMWidgetClass
:++
'[
S
.
Options
,
S
.
SelectedValue
,
S
.
SelectedLabel
,
S
.
Disabled
,
S
.
Description
,
S
.
SelectionHandler
]
S
.
Description
,
S
.
SelectionHandler
]
type
MultipleSelectionClass
=
DOMWidgetClass
:++
'[
S
.
Options
,
S
.
Selected
Labels
,
S
.
SelectedValue
s
,
S
.
Disabled
,
type
MultipleSelectionClass
=
DOMWidgetClass
:++
'[
S
.
Options
,
S
.
Selected
Values
,
S
.
SelectedLabel
s
,
S
.
Disabled
,
S
.
Description
,
S
.
SelectionHandler
]
S
.
Description
,
S
.
SelectionHandler
]
type
IntClass
=
DOMWidgetClass
:++
'[
S
.
IntValue
,
S
.
Disabled
,
S
.
Description
,
S
.
ChangeHandler
]
type
IntClass
=
DOMWidgetClass
:++
'[
S
.
IntValue
,
S
.
Disabled
,
S
.
Description
,
S
.
ChangeHandler
]
...
@@ -132,6 +132,8 @@ type SelectionContainerClass = BoxClass :++ '[S.Titles, S.SelectedIndex, S.Chang
...
@@ -132,6 +132,8 @@ type SelectionContainerClass = BoxClass :++ '[S.Titles, S.SelectedIndex, S.Chang
type
family
FieldType
(
f
::
Field
)
::
*
where
type
family
FieldType
(
f
::
Field
)
::
*
where
FieldType
S
.
ViewModule
=
Text
FieldType
S
.
ViewModule
=
Text
FieldType
S
.
ViewName
=
Text
FieldType
S
.
ViewName
=
Text
FieldType
S
.
ModelModule
=
Text
FieldType
S
.
ModelName
=
Text
FieldType
S
.
MsgThrottle
=
Integer
FieldType
S
.
MsgThrottle
=
Integer
FieldType
S
.
Version
=
Integer
FieldType
S
.
Version
=
Integer
FieldType
S
.
DisplayHandler
=
IO
()
FieldType
S
.
DisplayHandler
=
IO
()
...
@@ -237,7 +239,9 @@ data WidgetType = ButtonType
...
@@ -237,7 +239,9 @@ data WidgetType = ButtonType
|
TextAreaType
|
TextAreaType
|
CheckBoxType
|
CheckBoxType
|
ToggleButtonType
|
ToggleButtonType
|
DropdownType
|
-- TODO: Add 'Valid' widget
DropdownType
|
RadioButtonsType
|
RadioButtonsType
|
SelectType
|
SelectType
|
ToggleButtonsType
|
ToggleButtonsType
...
@@ -252,7 +256,9 @@ data WidgetType = ButtonType
...
@@ -252,7 +256,9 @@ data WidgetType = ButtonType
|
FloatSliderType
|
FloatSliderType
|
FloatProgressType
|
FloatProgressType
|
FloatRangeSliderType
|
FloatRangeSliderType
|
BoxType
|
-- TODO: Add Proxy and PlaceProxy
BoxType
|
FlexBoxType
|
FlexBoxType
|
AccordionType
|
AccordionType
|
TabType
|
TabType
...
@@ -265,7 +271,7 @@ type family WidgetFields (w :: WidgetType) :: [Field] where
...
@@ -265,7 +271,7 @@ type family WidgetFields (w :: WidgetType) :: [Field] where
'[
S
.
Description
,
S
.
Tooltip
,
S
.
Disabled
,
S
.
Icon
,
S
.
ButtonStyle
,
'[
S
.
Description
,
S
.
Tooltip
,
S
.
Disabled
,
S
.
Icon
,
S
.
ButtonStyle
,
S
.
ClickHandler
]
S
.
ClickHandler
]
WidgetFields
ImageType
=
WidgetFields
ImageType
=
DOMWidgetClass
:++
'[
S
.
ImageFormat
,
S
.
B64Value
]
DOMWidgetClass
:++
'[
S
.
ImageFormat
,
S
.
Width
,
S
.
Height
,
S
.
B64Value
]
WidgetFields
OutputType
=
DOMWidgetClass
WidgetFields
OutputType
=
DOMWidgetClass
WidgetFields
HTMLType
=
StringClass
WidgetFields
HTMLType
=
StringClass
WidgetFields
LatexType
=
StringClass
WidgetFields
LatexType
=
StringClass
...
@@ -286,7 +292,8 @@ type family WidgetFields (w :: WidgetType) :: [Field] where
...
@@ -286,7 +292,8 @@ type family WidgetFields (w :: WidgetType) :: [Field] where
WidgetFields
IntSliderType
=
WidgetFields
IntSliderType
=
BoundedIntClass
:++
BoundedIntClass
:++
'[
S
.
Orientation
,
S
.
ShowRange
,
S
.
ReadOut
,
S
.
SliderColor
]
'[
S
.
Orientation
,
S
.
ShowRange
,
S
.
ReadOut
,
S
.
SliderColor
]
WidgetFields
IntProgressType
=
BoundedIntClass
:++
'[
S
.
BarStyle
]
WidgetFields
IntProgressType
=
BoundedIntClass
:++
'[
S
.
Orientation
,
S
.
BarStyle
]
WidgetFields
IntRangeSliderType
=
WidgetFields
IntRangeSliderType
=
BoundedIntRangeClass
:++
BoundedIntRangeClass
:++
'[
S
.
Orientation
,
S
.
ShowRange
,
S
.
ReadOut
,
S
.
SliderColor
]
'[
S
.
Orientation
,
S
.
ShowRange
,
S
.
ReadOut
,
S
.
SliderColor
]
...
@@ -296,7 +303,7 @@ type family WidgetFields (w :: WidgetType) :: [Field] where
...
@@ -296,7 +303,7 @@ type family WidgetFields (w :: WidgetType) :: [Field] where
BoundedFloatClass
:++
BoundedFloatClass
:++
'[
S
.
Orientation
,
S
.
ShowRange
,
S
.
ReadOut
,
S
.
SliderColor
]
'[
S
.
Orientation
,
S
.
ShowRange
,
S
.
ReadOut
,
S
.
SliderColor
]
WidgetFields
FloatProgressType
=
WidgetFields
FloatProgressType
=
BoundedFloatClass
:++
'[
S
.
BarStyle
]
BoundedFloatClass
:++
'[
S
.
Orientation
,
S
.
BarStyle
]
WidgetFields
FloatRangeSliderType
=
WidgetFields
FloatRangeSliderType
=
BoundedFloatRangeClass
:++
BoundedFloatRangeClass
:++
'[
S
.
Orientation
,
S
.
ShowRange
,
S
.
ReadOut
,
S
.
SliderColor
]
'[
S
.
Orientation
,
S
.
ShowRange
,
S
.
ReadOut
,
S
.
SliderColor
]
...
@@ -339,6 +346,12 @@ instance ToPairs (Attr S.ViewModule) where
...
@@ -339,6 +346,12 @@ instance ToPairs (Attr S.ViewModule) where
instance
ToPairs
(
Attr
S
.
ViewName
)
where
instance
ToPairs
(
Attr
S
.
ViewName
)
where
toPairs
x
=
[
"_view_name"
.=
toJSON
x
]
toPairs
x
=
[
"_view_name"
.=
toJSON
x
]
instance
ToPairs
(
Attr
S
.
ModelModule
)
where
toPairs
x
=
[
"_model_module"
.=
toJSON
x
]
instance
ToPairs
(
Attr
S
.
ModelName
)
where
toPairs
x
=
[
"_model_name"
.=
toJSON
x
]
instance
ToPairs
(
Attr
S
.
MsgThrottle
)
where
instance
ToPairs
(
Attr
S
.
MsgThrottle
)
where
toPairs
x
=
[
"msg_throttle"
.=
toJSON
x
]
toPairs
x
=
[
"msg_throttle"
.=
toJSON
x
]
...
@@ -591,6 +604,8 @@ reflect = fromSing
...
@@ -591,6 +604,8 @@ reflect = fromSing
defaultWidget
::
FieldType
S
.
ViewName
->
Rec
Attr
WidgetClass
defaultWidget
::
FieldType
S
.
ViewName
->
Rec
Attr
WidgetClass
defaultWidget
viewName
=
(
ViewModule
=::
""
)
defaultWidget
viewName
=
(
ViewModule
=::
""
)
:&
(
ViewName
=::
viewName
)
:&
(
ViewName
=::
viewName
)
:&
(
ModelModule
=::
""
)
:&
(
ModelName
=::
"WidgetModel"
)
:&
(
MsgThrottle
=:+
3
)
:&
(
MsgThrottle
=:+
3
)
:&
(
Version
=::
0
)
:&
(
Version
=::
0
)
:&
(
DisplayHandler
=::
return
()
)
:&
(
DisplayHandler
=::
return
()
)
...
@@ -656,8 +671,8 @@ defaultMultipleSelectionWidget :: FieldType S.ViewName -> Rec Attr MultipleSelec
...
@@ -656,8 +671,8 @@ defaultMultipleSelectionWidget :: FieldType S.ViewName -> Rec Attr MultipleSelec
defaultMultipleSelectionWidget
viewName
=
defaultDOMWidget
viewName
<+>
mulSelAttrs
defaultMultipleSelectionWidget
viewName
=
defaultDOMWidget
viewName
<+>
mulSelAttrs
where
where
mulSelAttrs
=
(
Options
=::
OptionLabels
[]
)
mulSelAttrs
=
(
Options
=::
OptionLabels
[]
)
:&
(
SelectedLabels
=::
[]
)
:&
(
SelectedValues
=::
[]
)
:&
(
SelectedValues
=::
[]
)
:&
(
SelectedLabels
=::
[]
)
:&
(
Disabled
=::
False
)
:&
(
Disabled
=::
False
)
:&
(
Description
=::
""
)
:&
(
Description
=::
""
)
:&
(
SelectionHandler
=::
return
()
)
:&
(
SelectionHandler
=::
return
()
)
...
@@ -739,8 +754,10 @@ defaultBoundedFloatRangeWidget viewName = defaultFloatRangeWidget viewName <+> b
...
@@ -739,8 +754,10 @@ defaultBoundedFloatRangeWidget viewName = defaultFloatRangeWidget viewName <+> b
-- | A record representing a widget of the _Box class from IPython
-- | A record representing a widget of the _Box class from IPython
defaultBoxWidget
::
FieldType
S
.
ViewName
->
Rec
Attr
BoxClass
defaultBoxWidget
::
FieldType
S
.
ViewName
->
Rec
Attr
BoxClass
defaultBoxWidget
viewName
=
d
efaultDOMWidget
viewName
<+>
boxAttrs
defaultBoxWidget
viewName
=
d
omAttrs
<+>
boxAttrs
where
where
defaultDOM
=
defaultDOMWidget
viewName
domAttrs
=
rput
(
ModelName
=::
"BoxModel"
)
defaultDOM
boxAttrs
=
(
Children
=::
[]
)
boxAttrs
=
(
Children
=::
[]
)
:&
(
OverflowX
=::
DefaultOverflow
)
:&
(
OverflowX
=::
DefaultOverflow
)
:&
(
OverflowY
=::
DefaultOverflow
)
:&
(
OverflowY
=::
DefaultOverflow
)
...
...
ipython-kernel/src/IHaskell/IPython/Message/Parser.hs
View file @
be3d44eb
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
-- the low-level 0MQ interface.
-- the low-level 0MQ interface.
module
IHaskell.IPython.Message.Parser
(
parseMessage
)
where
module
IHaskell.IPython.Message.Parser
(
parseMessage
)
where
import
Data.Aeson
((
.:
),
decode
,
Result
(
..
),
Object
)
import
Data.Aeson
((
.:
),
(
.:?
),
(
.!=
),
decode
,
Result
(
..
),
Object
)
import
Control.Applicative
((
<|>
),
(
<$>
),
(
<*>
))
import
Control.Applicative
((
<|>
),
(
<$>
),
(
<*>
))
import
Data.Aeson.Types
(
parse
)
import
Data.Aeson.Types
(
parse
)
import
Data.ByteString
import
Data.ByteString
...
@@ -159,9 +159,10 @@ inputReplyParser = requestParser $ \obj -> do
...
@@ -159,9 +159,10 @@ inputReplyParser = requestParser $ \obj -> do
commOpenParser
::
LByteString
->
Message
commOpenParser
::
LByteString
->
Message
commOpenParser
=
requestParser
$
\
obj
->
do
commOpenParser
=
requestParser
$
\
obj
->
do
uuid
<-
obj
.:
"comm_id"
uuid
<-
obj
.:
"comm_id"
name
<-
obj
.:
"target_name"
targetName
<-
obj
.:
"target_name"
targetModule
<-
obj
.:?
"target_module"
.!=
""
value
<-
obj
.:
"data"
value
<-
obj
.:
"data"
return
$
CommOpen
noHeader
nam
e
uuid
value
return
$
CommOpen
noHeader
targetName
targetModul
e
uuid
value
commDataParser
::
LByteString
->
Message
commDataParser
::
LByteString
->
Message
commDataParser
=
requestParser
$
\
obj
->
do
commDataParser
=
requestParser
$
\
obj
->
do
...
...
ipython-kernel/src/IHaskell/IPython/Message/Writer.hs
View file @
be3d44eb
...
@@ -97,7 +97,12 @@ instance ToJSON Message where
...
@@ -97,7 +97,12 @@ instance ToJSON Message where
object
[
"prompt"
.=
prompt
]
object
[
"prompt"
.=
prompt
]
toJSON
req
@
CommOpen
{}
=
toJSON
req
@
CommOpen
{}
=
object
[
"comm_id"
.=
commUuid
req
,
"target_name"
.=
commTargetName
req
,
"data"
.=
commData
req
]
object
[
"comm_id"
.=
commUuid
req
,
"target_name"
.=
commTargetName
req
,
"target_module"
.=
commTargetModule
req
,
"data"
.=
commData
req
]
toJSON
req
@
CommData
{}
=
toJSON
req
@
CommData
{}
=
object
[
"comm_id"
.=
commUuid
req
,
"data"
.=
commData
req
]
object
[
"comm_id"
.=
commUuid
req
,
"data"
.=
commData
req
]
...
...
ipython-kernel/src/IHaskell/IPython/Types.hs
View file @
be3d44eb
...
@@ -375,6 +375,7 @@ data Message =
...
@@ -375,6 +375,7 @@ data Message =
CommOpen
CommOpen
{
header
::
MessageHeader
{
header
::
MessageHeader
,
commTargetName
::
String
,
commTargetName
::
String
,
commTargetModule
::
String
,
commUuid
::
UUID
,
commUuid
::
UUID
,
commData
::
Value
,
commData
::
Value
}
}
...
@@ -438,6 +439,7 @@ replyType CompleteRequestMessage = Just CompleteReplyMessage
...
@@ -438,6 +439,7 @@ replyType CompleteRequestMessage = Just CompleteReplyMessage
replyType
InspectRequestMessage
=
Just
InspectReplyMessage
replyType
InspectRequestMessage
=
Just
InspectReplyMessage
replyType
ShutdownRequestMessage
=
Just
ShutdownReplyMessage
replyType
ShutdownRequestMessage
=
Just
ShutdownReplyMessage
replyType
HistoryRequestMessage
=
Just
HistoryReplyMessage
replyType
HistoryRequestMessage
=
Just
HistoryReplyMessage
replyType
CommOpenMessage
=
Just
CommDataMessage
replyType
_
=
Nothing
replyType
_
=
Nothing
-- | Data for display: a string with associated MIME type.
-- | Data for display: a string with associated MIME type.
...
...
main/Main.hs
View file @
be3d44eb
...
@@ -14,6 +14,7 @@ import qualified Data.ByteString.Char8 as CBS
...
@@ -14,6 +14,7 @@ import qualified Data.ByteString.Char8 as CBS
-- Standard library imports.
-- Standard library imports.
import
Control.Concurrent
(
threadDelay
)
import
Control.Concurrent
(
threadDelay
)
import
Control.Concurrent.Chan
import
Control.Concurrent.Chan
import
Control.Arrow
(
second
)
import
Data.Aeson
import
Data.Aeson
import
System.Directory
import
System.Directory
import
System.Process
(
readProcess
,
readProcessWithExitCode
)
import
System.Process
(
readProcess
,
readProcessWithExitCode
)
...
@@ -333,6 +334,44 @@ replyTo _ HistoryRequest{} replyHeader state = do
...
@@ -333,6 +334,44 @@ replyTo _ HistoryRequest{} replyHeader state = do
}
}
return
(
state
,
reply
)
return
(
state
,
reply
)
-- Accomodating the workaround for retrieving list of open comms from the kernel
--
-- The main idea is that the frontend opens a comm at kernel startup, whose target is a widget that
-- sends back the list of live comms and commits suicide.
--
-- The message needs to be written to the iopub channel, and not returned from here. If returned,
-- the same message also gets written to the shell channel, which causes issues due to two messages
-- having the same identifiers in their headers.
--
-- Sending the message only on the shell_reply channel doesn't work, so we send it as a comm message
-- on the iopub channel and return the SendNothing message.
replyTo
interface
open
@
CommOpen
{}
replyHeader
state
=
do
let
send
msg
=
liftIO
$
writeChan
(
iopubChannel
interface
)
msg
incomingUuid
=
commUuid
open
target
=
commTargetName
open
targetMatches
=
target
==
"ipython.widget"
valueMatches
=
commData
open
==
object
[
"widget_class"
.=
"ipywidgets.CommInfo"
]
commMap
=
openComms
state
uuidTargetPairs
=
map
(
second
targetName
)
$
Map
.
toList
commMap
pairProcessor
(
x
,
y
)
=
T
.
pack
(
UUID
.
uuidToString
x
)
.=
object
[
"target_name"
.=
T
.
pack
y
]
currentComms
=
object
$
map
pairProcessor
$
(
incomingUuid
,
"comm"
)
:
uuidTargetPairs
replyValue
=
object
[
"method"
.=
"custom"
,
"content"
.=
object
[
"comms"
.=
currentComms
]
]
msg
=
CommData
replyHeader
(
commUuid
open
)
replyValue
-- To the iopub channel you go
when
(
targetMatches
&&
valueMatches
)
$
send
msg
return
(
state
,
SendNothing
)
-- TODO: What else can be implemented?
-- TODO: What else can be implemented?
replyTo
_
message
_
state
=
do
replyTo
_
message
_
state
=
do
liftIO
$
hPutStrLn
stderr
$
"Unimplemented message: "
++
show
message
liftIO
$
hPutStrLn
stderr
$
"Unimplemented message: "
++
show
message
...
...
src/IHaskell/Eval/Widgets.hs
View file @
be3d44eb
...
@@ -52,9 +52,8 @@ widgetSend :: IHaskellWidget a
...
@@ -52,9 +52,8 @@ widgetSend :: IHaskellWidget a
widgetSend
msgType
widget
value
=
queue
$
msgType
(
Widget
widget
)
value
widgetSend
msgType
widget
value
=
queue
$
msgType
(
Widget
widget
)
value
-- | Send a message to open a comm
-- | Send a message to open a comm
widgetSendOpen
::
IHaskellWidget
a
=>
a
->
Value
->
Value
->
IO
()
widgetSendOpen
::
IHaskellWidget
a
=>
a
->
Value
->
IO
()
widgetSendOpen
widget
initVal
stateVal
=
widgetSendOpen
=
widgetSend
Open
queue
$
Open
(
Widget
widget
)
initVal
stateVal
-- | Send a state update message
-- | Send a state update message
widgetSendUpdate
::
IHaskellWidget
a
=>
a
->
Value
->
IO
()
widgetSendUpdate
::
IHaskellWidget
a
=>
a
->
Value
->
IO
()
...
@@ -93,8 +92,9 @@ handleMessage :: (Message -> IO ())
...
@@ -93,8 +92,9 @@ handleMessage :: (Message -> IO ())
->
IO
KernelState
->
IO
KernelState
handleMessage
send
replyHeader
state
msg
=
do
handleMessage
send
replyHeader
state
msg
=
do
case
msg
of
case
msg
of
Open
widget
initVal
stateVal
->
do
Open
widget
value
->
do
let
target
=
targetName
widget
let
target_name
=
targetName
widget
target_module
=
targetModule
widget
uuid
=
getCommUUID
widget
uuid
=
getCommUUID
widget
present
=
isJust
$
Map
.
lookup
uuid
oldComms
present
=
isJust
$
Map
.
lookup
uuid
oldComms
...
@@ -109,12 +109,9 @@ handleMessage send replyHeader state msg = do
...
@@ -109,12 +109,9 @@ handleMessage send replyHeader state msg = do
if
present
if
present
then
return
state
then
return
state
else
do
else
do
-- Send the comm open
-- Send the comm open
, with the initial state
header
<-
dupHeader
replyHeader
CommOpenMessage
header
<-
dupHeader
replyHeader
CommOpenMessage
send
$
CommOpen
header
target
uuid
initVal
send
$
CommOpen
header
target_name
target_module
uuid
value
-- Initial state update
communicate
.
toJSON
$
UpdateState
stateVal
-- Send anything else the widget requires.
-- Send anything else the widget requires.
open
widget
communicate
open
widget
communicate
...
@@ -123,8 +120,7 @@ handleMessage send replyHeader state msg = do
...
@@ -123,8 +120,7 @@ handleMessage send replyHeader state msg = do
return
newState
return
newState
Close
widget
value
->
do
Close
widget
value
->
do
let
target
=
targetName
widget
let
uuid
=
getCommUUID
widget
uuid
=
getCommUUID
widget
present
=
isJust
$
Map
.
lookup
uuid
oldComms
present
=
isJust
$
Map
.
lookup
uuid
oldComms
newComms
=
Map
.
delete
uuid
$
openComms
state
newComms
=
Map
.
delete
uuid
$
openComms
state
...
...
src/IHaskell/Types.hs
View file @
be3d44eb
...
@@ -65,11 +65,15 @@ class IHaskellDisplay a where
...
@@ -65,11 +65,15 @@ class IHaskellDisplay a where
-- | Display as an interactive widget.
-- | Display as an interactive widget.
class
IHaskellDisplay
a
=>
IHaskellWidget
a
where
class
IHaskellDisplay
a
=>
IHaskellWidget
a
where
-- |
Output target name for this widget. The actual input parameter should be ignored. By default
-- |
Target name for this widget. The actual input parameter should be ignored. By default evaluate
--
evaluate
to "ipython.widget", which is used by IPython for its backbone widgets.
-- to "ipython.widget", which is used by IPython for its backbone widgets.
targetName
::
a
->
String
targetName
::
a
->
String
targetName
_
=
"ipython.widget"
targetName
_
=
"ipython.widget"
-- | Target module for this widget. Evaluates to an empty string by default.
targetModule
::
a
->
String
targetModule
_
=
""
-- | Get the uuid for comm associated with this widget. The widget is responsible for storing the
-- | Get the uuid for comm associated with this widget. The widget is responsible for storing the
-- UUID during initialization.
-- UUID during initialization.
getCommUUID
::
a
->
UUID
getCommUUID
::
a
->
UUID
...
@@ -102,6 +106,7 @@ instance IHaskellDisplay Widget where
...
@@ -102,6 +106,7 @@ instance IHaskellDisplay Widget where
instance
IHaskellWidget
Widget
where
instance
IHaskellWidget
Widget
where
targetName
(
Widget
widget
)
=
targetName
widget
targetName
(
Widget
widget
)
=
targetName
widget
targetModule
(
Widget
widget
)
=
targetModule
widget
getCommUUID
(
Widget
widget
)
=
getCommUUID
widget
getCommUUID
(
Widget
widget
)
=
getCommUUID
widget
open
(
Widget
widget
)
=
open
widget
open
(
Widget
widget
)
=
open
widget
comm
(
Widget
widget
)
=
comm
widget
comm
(
Widget
widget
)
=
comm
widget
...
@@ -185,11 +190,10 @@ data LintStatus = LintOn
...
@@ -185,11 +190,10 @@ data LintStatus = LintOn
deriving
(
Eq
,
Show
)
deriving
(
Eq
,
Show
)
-- | Send JSON objects with specific formats
-- | Send JSON objects with specific formats
data
WidgetMsg
=
Open
Widget
Value
Value
data
WidgetMsg
=
Open
Widget
Value
|
|
-- ^ Cause the interpreter to open a new comm, and register the associated widget in
-- ^ Cause the interpreter to open a new comm, and register the associated widget in
-- the kernelState. Also sends a Value with comm_open, and then sends an initial
-- the kernelState. Also sends an initial state Value with comm_open.
-- state update Value.
Update
Widget
Value
Update
Widget
Value
|
|
-- ^ Cause the interpreter to send a comm_msg containing a state update for the
-- ^ Cause the interpreter to send a comm_msg containing a state update for the
...
...
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