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
704ac8cd
Commit
704ac8cd
authored
Jan 06, 2014
by
Eyal Dechter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added MonadIO (from transformers package) instance for Interpreter.
parent
1de89fb4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
+16
-10
Evaluate.hs
src/IHaskell/Eval/Evaluate.hs
+16
-10
No files found.
src/IHaskell/Eval/Evaluate.hs
View file @
704ac8cd
{-# LANGUAGE DoAndIfThenElse, NoOverloadedStrings #-}
{-# LANGUAGE DoAndIfThenElse, NoOverloadedStrings, TypeSynonymInstances #-}
{- | Description : Wrapper around GHC API, exposing a single `evaluate` interface that runs
a statement, declaration, import, or directive.
...
...
@@ -29,6 +30,8 @@ import Control.Monad (guard)
import
System.Process
import
System.Exit
import
Data.Maybe
(
fromJust
)
import
qualified
Control.Monad.IO.Class
as
MonadIO
(
MonadIO
,
liftIO
)
import
qualified
MonadUtils
as
MonadUtils
(
MonadIO
,
liftIO
)
import
NameSet
import
Name
...
...
@@ -81,6 +84,9 @@ write x = when debug $ liftIO $ hPutStrLn stderr $ "DEBUG: " ++ x
type
Interpreter
=
Ghc
instance
MonadIO
.
MonadIO
Interpreter
where
liftIO
=
MonadUtils
.
liftIO
globalImports
::
[
String
]
globalImports
=
[
"import IHaskell.Display"
...
...
@@ -405,8 +411,8 @@ evalCommand _ (Directive SetOpt option) state = do
setOpt
_
_
=
Nothing
evalCommand
publish
(
Directive
ShellCmd
(
'!'
:
cmd
))
state
=
wrapExecution
state
$
liftIO
$
case
words
cmd
of
evalCommand
publish
(
Directive
ShellCmd
(
'!'
:
cmd
))
state
=
wrapExecution
state
$
liftIO
$
case
words
cmd
of
"cd"
:
dirs
->
let
directory
=
unwords
dirs
in
do
setCurrentDirectory
directory
...
...
@@ -422,13 +428,13 @@ evalCommand publish (Directive ShellCmd ('!':cmd)) state = wrapExecution state $
std_err
=
UseHandle
handle
}
(
_
,
_
,
_
,
process
)
<-
createProcess
procSpec
-- Accumulate output from the process.
outputAccum
<-
liftIO
$
newMVar
""
-- Start a loop to publish intermediate results.
let
-- Compute how long to wait between reading pieces of the output.
let
-- Compute how long to wait between reading pieces of the output.
-- `threadDelay` takes an argument of microseconds.
ms
=
1000
delay
=
100
*
ms
...
...
@@ -457,7 +463,7 @@ evalCommand publish (Directive ShellCmd ('!':cmd)) state = wrapExecution state $
if
not
computationDone
then
do
-- Write to frontend and repeat.
readMVar
outputAccum
>>=
output
readMVar
outputAccum
>>=
output
loop
else
do
out
<-
readMVar
outputAccum
...
...
@@ -470,7 +476,7 @@ evalCommand publish (Directive ShellCmd ('!':cmd)) state = wrapExecution state $
html
$
printf
"<span class='mono'>%s</span>"
out
++
htmlErr
]
loop
-- This is taken largely from GHCi's info section in InteractiveUI.
evalCommand
_
(
Directive
GetHelp
_
)
state
=
do
...
...
@@ -687,7 +693,7 @@ evalCommand _ (Declaration decl) state = wrapExecution state $ do
names
<-
runDecls
decl
dflags
<-
getSessionDynFlags
let
boundNames
=
map
(
replace
":Interactive."
""
.
showPpr
dflags
)
names
let
boundNames
=
map
(
replace
":Interactive."
""
.
showPpr
dflags
)
names
nonDataNames
=
filter
(
not
.
isUpper
.
head
)
boundNames
-- Display the types of all bound names if the option is on.
...
...
@@ -981,7 +987,7 @@ formatType :: String -> [DisplayData]
formatType
typeStr
=
[
plain
typeStr
,
html
$
formatGetType
typeStr
]
displayError
::
ErrMsg
->
[
DisplayData
]
displayError
msg
=
[
plain
.
fixStdinError
.
typeCleaner
$
msg
,
html
$
formatError
msg
]
displayError
msg
=
[
plain
.
fixStdinError
.
typeCleaner
$
msg
,
html
$
formatError
msg
]
fixStdinError
::
ErrMsg
->
ErrMsg
fixStdinError
err
=
...
...
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