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
b04c7f62
Commit
b04c7f62
authored
Dec 10, 2013
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
something work i think (???)
parent
67e98e69
Changes
12
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
246 additions
and
374 deletions
+246
-374
IHaskell.cabal
IHaskell.cabal
+1
-4
Config.hs
IHaskell/Config.hs
+1
-0
Display.hs
IHaskell/Display.hs
+1
-0
Completion.hs
IHaskell/Eval/Completion.hs
+1
-0
Evaluate.hs
IHaskell/Eval/Evaluate.hs
+17
-23
Info.hs
IHaskell/Eval/Info.hs
+1
-0
Parser.hs
IHaskell/Eval/Parser.hs
+192
-328
IPython.hs
IHaskell/IPython.hs
+11
-8
UUID.hs
IHaskell/Message/UUID.hs
+1
-0
Writer.hs
IHaskell/Message/Writer.hs
+2
-0
ZeroMQ.hs
IHaskell/ZeroMQ.hs
+1
-0
rundoctests.hs
rundoctests.hs
+17
-11
No files found.
IHaskell.cabal
View file @
b04c7f62
...
...
@@ -93,9 +93,6 @@ executable IHaskell
extensions: DoAndIfThenElse
NoImplicitPrelude
OverloadedStrings
-- Other library packages from which modules are imported.
build-depends: base ==4.6.*,
...
...
@@ -126,5 +123,5 @@ Test-Suite doctests
Type: exitcode-stdio-1.0
Ghc-Options: -threaded
Main-Is: rundoctests.hs
Build-Depends: base, doctest >= 0.8, process
Build-Depends: base, doctest >= 0.8, process
, text ==0.11.*, shelly ==1.3.*, MissingH ==1.2.*
IHaskell/Config.hs
View file @
b04c7f62
{-# LANGUAGE NoImplicitPrelude, OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
-- | Description : IPython configuration files are compiled-into IHaskell
module
IHaskell.Config
(
ipython
,
notebook
,
console
,
qtconsole
,
customjs
,
notebookJavascript
)
where
...
...
IHaskell/Display.hs
View file @
b04c7f62
{-# LANGUAGE NoImplicitPrelude, OverloadedStrings #-}
{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}
module
IHaskell.Display
(
IHaskellDisplay
(
..
),
...
...
IHaskell/Eval/Completion.hs
View file @
b04c7f62
{-# LANGUAGE NoImplicitPrelude, OverloadedStrings #-}
{- | Description : generates tab-completion options
context-insensitive completion for what is probably
...
...
IHaskell/Eval/Evaluate.hs
View file @
b04c7f62
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude, OverloadedStrings #-}
{- | Description : Wrapper around GHC API, exposing a single `evaluate` interface that runs
a statement, declaration, import, or directive.
...
...
@@ -35,6 +34,7 @@ import Module
import
qualified
System.IO.Strict
as
StrictIO
import
IHaskell.Types
import
IHaskell.Eval.Parser
data
ErrorOccurred
=
Success
|
Failure
...
...
@@ -79,21 +79,8 @@ makeWrapperStmts = (fileName, initStmts, postStmts)
write
::
GhcMonad
m
=>
String
->
m
()
write
x
=
when
debug
$
liftIO
$
hPutStrLn
stderr
x
type
LineNumber
=
Int
type
ColumnNumber
=
Int
type
Interpreter
=
Ghc
data
DirectiveType
=
GetType
String
deriving
Show
data
Command
=
Directive
DirectiveType
|
Import
String
|
Declaration
String
|
Statement
String
|
ParseError
LineNumber
ColumnNumber
String
deriving
Show
globalImports
::
[
String
]
globalImports
=
[
"import Prelude"
...
...
@@ -152,9 +139,11 @@ evaluate :: Int -- ^ The execution counter of this evaluat
->
Interpreter
[
DisplayData
]
-- ^ All of the output.
evaluate
execCount
code
|
strip
code
==
""
=
return
[]
|
otherwise
=
joinDisplays
<$>
runUntilFailure
(
parseCommands
(
strip
code
)
++
[
storeItCommand
execCount
])
|
otherwise
=
do
cmds
<-
parseCommands
(
strip
code
)
joinDisplays
<$>
runUntilFailure
(
cmds
++
[
storeItCommand
execCount
])
where
runUntilFailure
::
[
Co
mmand
]
->
Interpreter
[
DisplayData
]
runUntilFailure
::
[
Co
deBlock
]
->
Interpreter
[
DisplayData
]
runUntilFailure
[]
=
return
[]
runUntilFailure
(
cmd
:
rest
)
=
do
(
success
,
result
)
<-
evalCommand
cmd
...
...
@@ -178,8 +167,12 @@ joinDisplays displays =
_
->
joinedPlains
:
other
parseCommands
::
GhcMonad
m
=>
String
-- ^ Code containing commands.
->
m
[
CodeBlock
]
-- ^ Commands contained in code string.
parseCommands
=
parseCell
{-
parseCommands :: String -- ^ Code containing commands.
->
[
Co
mmand
]
-- ^ Commands contained in code string.
-> [Co
deBlock
] -- ^ Commands contained in code string.
parseCommands code = joinMultilineDeclarations $ concatMap makeCommands pieces
where
-- Group the text into different pieces.
...
...
@@ -246,20 +239,21 @@ parseCommands code = joinMultilineDeclarations $ concatMap makeCommands pieces
':':'t':' ':expr -> Directive (GetType expr)
other -> ParseError 0 0 $ "Unknown command: " ++ other ++ "."
joinMultilineDeclarations
::
[
Co
mmand
]
->
[
Command
]
joinMultilineDeclarations :: [Co
deBlock] -> [CodeBlock
]
joinMultilineDeclarations = map joinCommands . groupBy declaringSameFunction
where
joinCommands
::
[
Co
mmand
]
->
Command
joinCommands :: [Co
deBlock] -> CodeBlock
joinCommands [x] = x
joinCommands commands = Declaration . unlines $ map getDeclarationText commands
where
getDeclarationText (Declaration text) = text
declaringSameFunction
::
Co
mmand
->
Command
->
Bool
declaringSameFunction :: Co
deBlock -> CodeBlock
-> Bool
declaringSameFunction (Declaration first) (Declaration second) = declared first == declared second
where declared :: String -> String
declared = takeWhile (`notElem` (" \t\n:" :: String)) . strip
declaringSameFunction _ _ = False
-}
wrapExecution
::
Interpreter
[
DisplayData
]
->
Interpreter
(
ErrorOccurred
,
[
DisplayData
])
wrapExecution
exec
=
ghandle
handler
$
exec
>>=
\
res
->
...
...
@@ -270,7 +264,7 @@ wrapExecution exec = ghandle handler $ exec >>= \res ->
-- | Return the display data for this command, as well as whether it
-- resulted in an error.
evalCommand
::
Co
mmand
->
Interpreter
(
ErrorOccurred
,
[
DisplayData
])
evalCommand
::
Co
deBlock
->
Interpreter
(
ErrorOccurred
,
[
DisplayData
])
evalCommand
(
Import
importStr
)
=
wrapExecution
$
do
write
$
"Import: "
++
importStr
importDecl
<-
parseImportDecl
importStr
...
...
@@ -278,7 +272,7 @@ evalCommand (Import importStr) = wrapExecution $ do
setContext
$
IIDecl
importDecl
:
context
return
[]
evalCommand
(
Directive
(
GetType
expr
)
)
=
wrapExecution
$
do
evalCommand
(
Directive
GetType
expr
)
=
wrapExecution
$
do
result
<-
exprType
expr
dflags
<-
getSessionDynFlags
return
[
Display
MimeHtml
$
printf
"<span style='font-weight: bold; color: green;'>%s</span>"
$
showSDocUnqual
dflags
$
ppr
result
]
...
...
IHaskell/Eval/Info.hs
View file @
b04c7f62
{-# LANGUAGE NoImplicitPrelude, OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoImplicitPrelude #-}
{- | Description : Inspect type and function information and documentation.
...
...
IHaskell/Eval/Parser.hs
View file @
b04c7f62
This diff is collapsed.
Click to expand it.
IHaskell/IPython.hs
View file @
b04c7f62
{-# LANGUAGE NoImplicitPrelude, OverloadedStrings #-}
-- | Description : Shell scripting wrapper using @Shelly@ for the @notebook@, @setup@, and
-- @console@ commands.
module
IHaskell.IPython
(
runIHaskell
,
setupIPythonProfile
,
ipythonVersion
ipythonVersion
,
parseVersion
)
where
import
ClassyPrelude
...
...
@@ -19,6 +21,10 @@ import qualified System.IO.Strict as StrictIO
import
qualified
IHaskell.Config
as
Config
-- $setup
-- >>> import ClassyPrelude
-- >>> import IHaskell.IPython
-- | Run IPython with any arguments.
ipython
::
Bool
-- ^ Whether to suppress output.
->
[
Text
]
-- ^ IPython command line arguments.
...
...
@@ -44,13 +50,10 @@ ipythonVersion = shelly $ do
[
major
,
minor
,
patch
]
<-
parseVersion
<$>
ipython
True
[
"--version"
]
return
(
major
,
minor
,
patch
)
{- |
>>> parseVersion `map` ["2.0.0-dev", "2.0.0-alpha", "12.5.10"]
[[2,0,0],[2,0,0],[12,5,10]]
-}
-- | Parse an IPython version string into a list of integers.
--
-- >>> parseVersion `map` ["2.0.0-dev", "2.0.0-alpha", "12.5.10"]
-- [[2,0,0],[2,0,0],[12,5,10]]
parseVersion
::
String
->
[
Int
]
parseVersion
versionStr
=
map
read'
$
split
"."
versionStr
where
read'
x
=
case
reads
x
of
...
...
IHaskell/Message/UUID.hs
View file @
b04c7f62
{-# LANGUAGE NoImplicitPrelude, OverloadedStrings #-}
-- | Description : UUID generator and data structure
--
-- Generate, parse, and pretty print UUIDs for use with IPython.
...
...
IHaskell/Message/Writer.hs
View file @
b04c7f62
{-# LANGUAGE NoImplicitPrelude, OverloadedStrings #-}
{-# LANGUAGE CPP #-}
-- | Description : @ToJSON@ for Messages
--
...
...
@@ -18,6 +19,7 @@ ghcVersionInts :: [Int]
ghcVersionInts
=
ints
.
map
read
.
words
.
map
dotToSpace
$
(
VERSION_ghc
::
String
)
where
dotToSpace
'.'
=
' '
dotToSpace
x
=
x
--ghcVersionInts = [7,6,3]
-- Convert message bodies into JSON.
instance
ToJSON
Message
where
...
...
IHaskell/ZeroMQ.hs
View file @
b04c7f62
{-# LANGUAGE NoImplicitPrelude, OverloadedStrings #-}
-- | Description : Low-level ZeroMQ communication wrapper.
--
-- The "ZeroMQ" module abstracts away the low-level 0MQ based interface with IPython,
...
...
rundoctests.hs
View file @
b04c7f62
{-# LANGUAGE OverloadedStrings #-}
import
System.Process
import
System.Exit
import
System.IO
import
Test.DocTest
import
Data.Char
import
System.Environment
import
Data.String.Utils
-- | tests that all the >>> comments are followed by correct output. Easiest is to
--
...
...
@@ -18,17 +17,24 @@ import System.Environment
-- > runghc examples/rundoctests.hs Data/HList/File1.hs Data/HList/File2.hs
--
-- you need Cabal >= 1.18 since that's around when cabal repl got added.
main
::
IO
()
main
=
do
as
<-
getArgs
o
<-
readProcess
"cabal"
[
"repl"
,
"--ghc-options"
,
"-v0 -w"
]
":show packages
\n
:show language"
let
flags
=
words
$
unlines
$
filter
((
==
"-"
)
.
take
1
.
dropWhile
isSpace
)
$
lines
o
-- Get files to run on.
args
<-
getArgs
let
files
=
case
as
of
-- Get flags via cabal repl.
let
cabalCmds
=
unlines
[
":show packages"
,
":show language"
]
cabalOpts
=
[
"repl"
,
"--ghc-options"
,
"-v0 -w"
]
options
<-
readProcess
"cabal"
cabalOpts
cabalCmds
let
extraFlags
=
[
"-fobject-code"
,
"-XNoImplicitPrelude"
]
flags
=
words
(
unlines
$
filter
(
startswith
"-"
.
strip
)
$
lines
options
)
++
extraFlags
let
files
=
case
args
of
[]
->
[
"Main.hs"
]
_
->
as
_
->
args
putStrLn
"Testing:
\n
--------"
mapM_
putStrLn
files
putStr
"
\n
"
doctest
$
"-i."
:
"-idist/build/autogen"
:
"-optP-include"
:
...
...
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