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
70f414f9
Commit
70f414f9
authored
Jan 06, 2014
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding fix for #87, closes #87
parent
c83f42be
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
7 deletions
+41
-7
build.sh
build.sh
+3
-0
custom.js
profile/static/custom/custom.js
+3
-0
Evaluate.hs
src/IHaskell/Eval/Evaluate.hs
+35
-7
No files found.
build.sh
View file @
70f414f9
...
...
@@ -11,3 +11,6 @@ do
cabal
install
||
return
1
cd
..
done
# Remove my profile
rm
-rf
~/.ipython/profile_haskell
profile/static/custom/custom.js
View file @
70f414f9
...
...
@@ -39,6 +39,9 @@ $([IPython.events]).on('app_initialized.NotebookApp', function(){
$
([
IPython
.
events
]).
on
(
'shell_reply.Kernel'
,
function
()
{
// Add logic here that should be run once per reply.
// Highlight things with a .highlight-code class
// The id is the mode with with to highlight
$
(
'.highlight-code'
).
each
(
function
()
{
var
$this
=
$
(
this
),
$code
=
$this
.
html
(),
...
...
src/IHaskell/Eval/Evaluate.hs
View file @
70f414f9
...
...
@@ -84,7 +84,7 @@ globalImports :: [String]
globalImports
=
[
"import IHaskell.Display"
,
"import Control.Applicative ((<$>))"
,
"import GHC.IO.Handle (hDuplicateTo, hDuplicate)"
,
"import GHC.IO.Handle (hDuplicateTo, hDuplicate
, hClose
)"
,
"import System.Posix.IO"
,
"import System.Posix.Files"
,
"import System.IO"
...
...
@@ -100,6 +100,11 @@ interpret action = runGhc (Just libdir) $ do
void
$
setSessionDynFlags
$
dflags
{
hscTarget
=
HscInterpreted
,
ghcLink
=
LinkInMemory
}
initializeImports
-- Close stdin so it can't be used.
-- Otherwise it'll block the kernel forever.
runStmt
"System.IO.hClose System.IO.stdin"
RunToCompletion
initializeItVariable
-- Run the rest of the interpreter
...
...
@@ -550,7 +555,7 @@ evalCommand output (Statement stmt) state = wrapExecution state $ do
return
$
name
++
" :: "
++
theType
let
joined
=
unlines
types
htmled
=
formatGetType
joined
htmled
=
unlines
$
map
formatGetType
types
return
$
case
output
of
[]
->
[
html
htmled
]
...
...
@@ -558,7 +563,7 @@ evalCommand output (Statement stmt) state = wrapExecution state $ do
-- Return plain and html versions.
-- Previously there was only a plain version.
[
Display
PlainText
text
]
->
[
plain
$
joined
++
"n"
++
text
,
[
plain
$
joined
++
"
\
n
"
++
text
,
html
$
htmled
++
mono
text
]
RunException
exception
->
throw
exception
...
...
@@ -676,10 +681,23 @@ evalCommand output (Expression expr) state = do
evalCommand
_
(
Declaration
decl
)
state
=
wrapExecution
state
$
do
write
$
"Declaration:
\n
"
++
decl
runDecls
decl
names
<-
runDecls
decl
dflags
<-
getSessionDynFlags
let
boundNames
=
map
(
replace
":Interactive."
""
.
showPpr
dflags
)
names
nonDataNames
=
filter
(
not
.
isUpper
.
head
)
boundNames
-- Do not display any output
return
[]
-- Display the types of all bound names if the option is on.
-- This is similar to GHCi :set +t.
if
not
$
useShowTypes
state
then
return
[]
else
do
-- Get all the type strings.
types
<-
forM
nonDataNames
$
\
name
->
do
theType
<-
showSDocUnqual
dflags
.
ppr
<$>
exprType
name
return
$
name
++
" :: "
++
theType
return
[
html
$
unlines
$
map
formatGetType
types
]
evalCommand
_
(
TypeSignature
sig
)
state
=
wrapExecution
state
$
-- We purposefully treat this as a "success" because that way execution
...
...
@@ -888,6 +906,7 @@ formatErrorWithClass cls =
printf
"<span class='%s'>%s</span>"
cls
.
replace
"
\n
"
"<br/>"
.
fixLineWrapping
.
fixStdinError
.
replace
useDashV
""
.
rstrip
.
typeCleaner
...
...
@@ -935,7 +954,16 @@ formatType :: String -> [DisplayData]
formatType
typeStr
=
[
plain
typeStr
,
html
$
formatGetType
typeStr
]
displayError
::
ErrMsg
->
[
DisplayData
]
displayError
msg
=
[
plain
.
typeCleaner
$
msg
,
html
$
formatError
msg
]
displayError
msg
=
[
plain
.
fixStdinError
.
typeCleaner
$
msg
,
html
$
formatError
msg
]
fixStdinError
::
ErrMsg
->
ErrMsg
fixStdinError
err
=
if
isStdinErr
err
then
"<stdin> is not available in IHaskell. Use special `inputLine` instead of `getLine`."
else
err
where
isStdinErr
err
=
startswith
"<stdin>"
err
&&
"illegal operation (handle is closed)"
`
isInfixOf
`
err
mono
::
String
->
String
mono
=
printf
"<span class='mono'>%s</span>"
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