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
9f83db98
Commit
9f83db98
authored
Mar 17, 2014
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Progress on adding comms. Added things to Evaluate.hs; incomplete!!!
parent
3762c2ac
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
38 deletions
+72
-38
Parsec.hs
ihaskell-display/ihaskell-parsec/IHaskell/Display/Parsec.hs
+6
-0
Test.ipynb
notebooks/Test.ipynb
+22
-36
Display.hs
src/IHaskell/Display.hs
+3
-1
Evaluate.hs
src/IHaskell/Eval/Evaluate.hs
+40
-1
Types.hs
src/IHaskell/Types.hs
+1
-0
No files found.
ihaskell-display/ihaskell-parsec/IHaskell/Display/Parsec.hs
View file @
9f83db98
...
@@ -8,6 +8,7 @@ import Data.String.Here
...
@@ -8,6 +8,7 @@ import Data.String.Here
import
Text.Parsec.String
import
Text.Parsec.String
import
IHaskell.Display
import
IHaskell.Display
import
IHaskell.Display
(
IHaskellWidget
)
instance
IHaskellDisplay
(
Parser
a
)
where
instance
IHaskellDisplay
(
Parser
a
)
where
display
renderable
=
do
display
renderable
=
do
...
@@ -42,3 +43,8 @@ instance IHaskellDisplay (Parser a) where
...
@@ -42,3 +43,8 @@ instance IHaskellDisplay (Parser a) where
});
});
</script>
</script>
|]
|]
instance
IHaskellWidget
(
Parser
a
)
where
open
widget
value
publisher
=
return
()
comm
widget
value
publisher
=
return
()
close
widget
value
=
return
()
notebooks/Test.ipynb
View file @
9f83db98
...
@@ -16,32 +16,22 @@
...
@@ -16,32 +16,22 @@
"import Text.Parsec\n",
"import Text.Parsec\n",
"import Text.Parsec.String\n",
"import Text.Parsec.String\n",
"import Text.Parsec.Prim\n",
"import Text.Parsec.Prim\n",
"import Text.Parsec.Char\n",
"import Text.Parsec.Char"
"\n",
"oneOf \"Hello\"C :: Parser Char"
],
],
"language": "python",
"language": "python",
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [],
{
"prompt_number": 1
"html": [
},
"\n",
{
" <form><textarea id=\"text79438521894\">Hello!</textarea></form>\n",
"cell_type": "code",
" <script>\n",
"collapsed": false,
" var textarea = document.getElementById(\"text79438521894\");\n",
"input": [
" var editor = CodeMirror.fromTextArea(textarea);\n",
"oneOf \"Hello\" :: Parser Char"
" editor.on(\"change\", function() {\n",
" var text = editor.getDoc().getValue();\n",
" console.log(\"New text: \" + text);\n",
" });\n",
" </script>\n",
" "
],
"metadata": {},
"output_type": "display_data"
}
],
],
"prompt_number": 2
"language": "python",
"metadata": {},
"outputs": []
},
},
{
{
"cell_type": "code",
"cell_type": "code",
...
@@ -107,30 +97,26 @@
...
@@ -107,30 +97,26 @@
"cell_type": "code",
"cell_type": "code",
"collapsed": false,
"collapsed": false,
"input": [
"input": [
"
x
"
"
oneOf \"Hello\" :: Parser Char
"
],
],
"language": "python",
"language": "python",
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"html": [
"html": [
"\n",
"<span class='err-msg'>Not in scope: type constructor or class `Parser'<br/><br/><br/>Not in scope: `oneOf'</span>"
" <form><textarea id=\"text33712347157\">Hello!</textarea></form>\n",
" <script>\n",
" var textarea = document.getElementById(\"text33712347157\");\n",
" var editor = CodeMirror.fromTextArea(textarea);\n",
" editor.on(\"change\", function() {\n",
" var text = editor.textContent;\n",
" console.log(\"New text: \" + text);\n",
" });\n",
" </script>\n",
" "
],
],
"metadata": {},
"metadata": {},
"output_type": "display_data"
"output_type": "display_data",
"text": [
"Not in scope: type constructor or class `Parser'\n",
"\n",
"\n",
"Not in scope: `oneOf'"
]
}
}
],
],
"prompt_number":
4
"prompt_number":
1
},
},
{
{
"cell_type": "code",
"cell_type": "code",
...
...
src/IHaskell/Display.hs
View file @
9f83db98
{-# LANGUAGE NoImplicitPrelude, OverloadedStrings, FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude, OverloadedStrings, FlexibleInstances #-}
module
IHaskell.Display
(
module
IHaskell.Display
(
IHaskellDisplay
(
..
),
IHaskellDisplay
(
..
),
IHaskellWidget
(
..
),
plain
,
html
,
png
,
jpg
,
svg
,
latex
,
plain
,
html
,
png
,
jpg
,
svg
,
latex
,
serializeDisplay
,
serializeDisplay
,
Width
,
Height
,
Base64
(
..
),
Width
,
Height
,
Base64
(
..
),
...
@@ -10,7 +11,8 @@ module IHaskell.Display (
...
@@ -10,7 +11,8 @@ module IHaskell.Display (
printDisplay
,
printDisplay
,
-- Internal only use
-- Internal only use
displayFromChan
displayFromChan
,
Widget
(
..
),
)
where
)
where
import
ClassyPrelude
import
ClassyPrelude
...
...
src/IHaskell/Eval/Evaluate.hs
View file @
9f83db98
...
@@ -69,6 +69,7 @@ import IHaskell.Display
...
@@ -69,6 +69,7 @@ import IHaskell.Display
import
qualified
IHaskell.Eval.Hoogle
as
Hoogle
import
qualified
IHaskell.Eval.Hoogle
as
Hoogle
import
IHaskell.Eval.Util
import
IHaskell.Eval.Util
import
IHaskell.BrokenPackages
import
IHaskell.BrokenPackages
import
qualified
IPython.Message.UUID
as
UUID
import
Paths_ihaskell
(
version
)
import
Paths_ihaskell
(
version
)
import
Data.Version
(
versionBranch
)
import
Data.Version
(
versionBranch
)
...
@@ -680,8 +681,21 @@ evalCommand output (Expression expr) state = do
...
@@ -680,8 +681,21 @@ evalCommand output (Expression expr) state = do
let
displayExpr
=
printf
"(IHaskell.Display.display (%s))"
expr
::
String
let
displayExpr
=
printf
"(IHaskell.Display.display (%s))"
expr
::
String
canRunDisplay
<-
attempt
$
exprType
displayExpr
canRunDisplay
<-
attempt
$
exprType
displayExpr
-- Check if this is a widget.
let
widgetExpr
=
printf
"(IHaskell.Display.Widget (%s))"
expr
::
String
isWidget
<-
attempt
$
exprType
displayExpr
if
canRunDisplay
if
canRunDisplay
then
useDisplay
displayExpr
then
do
-- Use the display. As a result, `it` is set to the output.
out
<-
useDisplay
displayExpr
-- Register the `it` object as a widget.
newState
<-
if
isWidget
then
registerWidget
out
else
return
state
return
out
{
evalState
=
newState
}
else
do
else
do
-- Evaluate this expression as though it's just a statement.
-- Evaluate this expression as though it's just a statement.
-- The output is bound to 'it', so we can then use it.
-- The output is bound to 'it', so we can then use it.
...
@@ -756,6 +770,31 @@ evalCommand output (Expression expr) state = do
...
@@ -756,6 +770,31 @@ evalCommand output (Expression expr) state = do
then
display
::
Display
then
display
::
Display
else
removeSvg
display
else
removeSvg
display
registerWidget
state
evalOut
=
when
(
evalStatus
evalOut
==
Success
)
$
do
element
<-
dynCompileExpr
"IHaskell.Display.Widget it"
case
fromDynamic
element
of
Nothing
->
error
"Expecting widget"
Just
widget
->
do
-- Stick the widget in the kernel state.
uuid
<-
UUID
.
random
let
newComms
=
Map
.
insert
uuid
widget
$
openComms
state
newState
=
state
{
openComms
=
newComms
}
-- Start the comm.
startComm
uuid
widget
-- HOW DO WE START A COMM?
-- 1. Add field to EvalOut
-- that describes commes to start
-- 2. Add method to IHaskellWidget that describes the
-- target_name.
-- 3. Store UUID and target_name in EvalOut field.
-- 4. When EvalOut is returned, have Main.hs start the comm.
-- 5. Have JS receive the comm and create a widget, just like
-- it does in the real IPython example.
return
newState
isIO
expr
=
attempt
$
exprType
$
printf
"((
\\
x -> x) :: IO a -> IO a) (%s)"
expr
isIO
expr
=
attempt
$
exprType
$
printf
"((
\\
x -> x) :: IO a -> IO a) (%s)"
expr
postprocessShowError
::
EvalOut
->
EvalOut
postprocessShowError
::
EvalOut
->
EvalOut
...
...
src/IHaskell/Types.hs
View file @
9f83db98
...
@@ -97,6 +97,7 @@ class IHaskellDisplay a => IHaskellWidget a where
...
@@ -97,6 +97,7 @@ class IHaskellDisplay a => IHaskellWidget a where
->
IO
()
->
IO
()
data
Widget
=
forall
a
.
IHaskellWidget
a
=>
Widget
a
data
Widget
=
forall
a
.
IHaskellWidget
a
=>
Widget
a
deriving
Typeable
instance
Show
Widget
where
instance
Show
Widget
where
show
_
=
"<Widget>"
show
_
=
"<Widget>"
...
...
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