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
a43bbb90
Commit
a43bbb90
authored
Mar 20, 2015
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Completing reformatting and adding it to test suite
parent
2f060497
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
317 additions
and
331 deletions
+317
-331
.travis.yml
.travis.yml
+1
-0
Convert.hs
src/IHaskell/Convert.hs
+1
-1
Args.hs
src/IHaskell/Convert/Args.hs
+0
-1
IpynbToLhs.hs
src/IHaskell/Convert/IpynbToLhs.hs
+1
-2
LhsToIpynb.hs
src/IHaskell/Convert/LhsToIpynb.hs
+0
-1
Display.hs
src/IHaskell/Display.hs
+0
-2
Completion.hs
src/IHaskell/Eval/Completion.hs
+9
-7
Evaluate.hs
src/IHaskell/Eval/Evaluate.hs
+237
-243
Hoogle.hs
src/IHaskell/Eval/Hoogle.hs
+6
-7
Lint.hs
src/IHaskell/Eval/Lint.hs
+0
-1
Parser.hs
src/IHaskell/Eval/Parser.hs
+3
-5
Util.hs
src/IHaskell/Eval/Util.hs
+5
-4
Flags.hs
src/IHaskell/Flags.hs
+1
-1
IPython.hs
src/IHaskell/IPython.hs
+0
-1
Types.hs
src/IHaskell/Types.hs
+11
-13
Main.hs
src/Main.hs
+37
-40
verify_formatting.py
verify_formatting.py
+5
-2
No files found.
.travis.yml
View file @
a43bbb90
...
@@ -48,6 +48,7 @@ script:
...
@@ -48,6 +48,7 @@ script:
-
travis_retry cabal configure --enable-tests
-
travis_retry cabal configure --enable-tests
-
travis_retry cabal test --show-details=always
-
travis_retry cabal test --show-details=always
-
./verify_formatting.py
-
cabal sdist
-
cabal sdist
# The following scriptlet checks that the resulting source distribution can be built & installed
# The following scriptlet checks that the resulting source distribution can be built & installed
...
...
src/IHaskell/Convert.hs
View file @
a43bbb90
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
module
IHaskell.Convert
(
convert
)
where
module
IHaskell.Convert
(
convert
)
where
import
Control.Monad.Identity
(
Identity
(
Identity
),
unless
,
when
)
import
Control.Monad.Identity
(
Identity
(
Identity
),
unless
,
when
)
import
IHaskell.Convert.Args
(
ConvertSpec
(
ConvertSpec
,
convertInput
,
convertLhsStyle
,
convertOutput
,
convertOverwriteFiles
,
convertToIpynb
),
fromJustConvertSpec
,
toConvertSpec
)
import
IHaskell.Convert.Args
(
ConvertSpec
(
..
),
fromJustConvertSpec
,
toConvertSpec
)
import
IHaskell.Convert.IpynbToLhs
(
ipynbToLhs
)
import
IHaskell.Convert.IpynbToLhs
(
ipynbToLhs
)
import
IHaskell.Convert.LhsToIpynb
(
lhsToIpynb
)
import
IHaskell.Convert.LhsToIpynb
(
lhsToIpynb
)
import
IHaskell.Flags
(
Argument
)
import
IHaskell.Flags
(
Argument
)
...
...
src/IHaskell/Convert/Args.hs
View file @
a43bbb90
...
@@ -50,7 +50,6 @@ isFormatSpec (ConvertToFormat _) = True
...
@@ -50,7 +50,6 @@ isFormatSpec (ConvertToFormat _) = True
isFormatSpec
(
ConvertFromFormat
_
)
=
True
isFormatSpec
(
ConvertFromFormat
_
)
=
True
isFormatSpec
_
=
False
isFormatSpec
_
=
False
toConvertSpec
::
[
Argument
]
->
ConvertSpec
Maybe
toConvertSpec
::
[
Argument
]
->
ConvertSpec
Maybe
toConvertSpec
args
=
mergeArgs
otherArgs
(
mergeArgs
formatSpecArgs
initialConvertSpec
)
toConvertSpec
args
=
mergeArgs
otherArgs
(
mergeArgs
formatSpecArgs
initialConvertSpec
)
where
where
...
...
src/IHaskell/Convert/IpynbToLhs.hs
View file @
a43bbb90
...
@@ -13,8 +13,7 @@ import qualified Data.Text.Lazy as T (concat, fromStrict, Text, unlines)
...
@@ -13,8 +13,7 @@ import qualified Data.Text.Lazy as T (concat, fromStrict, Text, unlines)
import
qualified
Data.Text.Lazy.IO
as
T
(
writeFile
)
import
qualified
Data.Text.Lazy.IO
as
T
(
writeFile
)
import
Data.Vector
(
Vector
)
import
Data.Vector
(
Vector
)
import
qualified
Data.Vector
as
V
(
map
,
mapM
,
toList
)
import
qualified
Data.Vector
as
V
(
map
,
mapM
,
toList
)
import
IHaskell.Flags
(
LhsStyle
(
lhsBeginCode
,
lhsBeginOutput
,
lhsCodePrefix
,
lhsEndCode
,
import
IHaskell.Flags
(
LhsStyle
(
..
))
lhsEndOutput
,
lhsOutputPrefix
))
ipynbToLhs
::
LhsStyle
T
.
Text
ipynbToLhs
::
LhsStyle
T
.
Text
->
FilePath
-- ^ the filename of an ipython notebook
->
FilePath
-- ^ the filename of an ipython notebook
...
...
src/IHaskell/Convert/LhsToIpynb.hs
View file @
a43bbb90
...
@@ -41,7 +41,6 @@ isEmptyMD :: (Eq a, Monoid a) => CellLine a -> Bool
...
@@ -41,7 +41,6 @@ isEmptyMD :: (Eq a, Monoid a) => CellLine a -> Bool
isEmptyMD
(
MarkdownLine
a
)
=
a
==
mempty
isEmptyMD
(
MarkdownLine
a
)
=
a
==
mempty
isEmptyMD
_
=
False
isEmptyMD
_
=
False
untag
::
CellLine
t
->
t
untag
::
CellLine
t
->
t
untag
(
CodeLine
a
)
=
a
untag
(
CodeLine
a
)
=
a
untag
(
OutputLine
a
)
=
a
untag
(
OutputLine
a
)
=
a
...
...
src/IHaskell/Display.hs
View file @
a43bbb90
...
@@ -86,8 +86,6 @@ instance IHaskellDisplay a => IHaskellDisplay [a] where
...
@@ -86,8 +86,6 @@ instance IHaskellDisplay a => IHaskellDisplay [a] where
displays
<-
mapM
display
disps
displays
<-
mapM
display
disps
return
$
ManyDisplay
displays
return
$
ManyDisplay
displays
-- | Encode many displays into a single one. All will be output.
-- | Encode many displays into a single one. All will be output.
many
::
[
Display
]
->
Display
many
::
[
Display
]
->
Display
many
=
ManyDisplay
many
=
ManyDisplay
...
...
src/IHaskell/Eval/Completion.hs
View file @
a43bbb90
...
@@ -60,6 +60,7 @@ data CompletionType = Empty
...
@@ -60,6 +60,7 @@ data CompletionType = Empty
extName
(
FlagSpec
{
flagSpecName
=
name
})
=
name
extName
(
FlagSpec
{
flagSpecName
=
name
})
=
name
#
else
#
else
extName
(
name
,
_
,
_
)
=
name
extName
(
name
,
_
,
_
)
=
name
exposedName
=
id
exposedName
=
id
#
endif
#
endif
complete
::
String
->
Int
->
Interpreter
(
String
,
[
String
])
complete
::
String
->
Int
->
Interpreter
(
String
,
[
String
])
...
@@ -250,13 +251,14 @@ completionTarget code cursor = expandCompletionPiece pieceToComplete
...
@@ -250,13 +251,14 @@ completionTarget code cursor = expandCompletionPiece pieceToComplete
where
where
pieceToComplete
=
map
fst
<$>
find
(
elem
cursor
.
map
snd
)
pieces
pieceToComplete
=
map
fst
<$>
find
(
elem
cursor
.
map
snd
)
pieces
pieces
=
splitAlongCursor
$
split
splitter
$
zip
code
[
1
..
]
pieces
=
splitAlongCursor
$
split
splitter
$
zip
code
[
1
..
]
splitter
=
defaultSplitter
{
splitter
=
defaultSplitter
-- Split using only the characters, which are the first elements of
{
-- the (char, index) tuple
-- Split using only the characters, which are the first elements of the (char, index) tuple
delimiter
=
Delimiter
[
uncurry
isDelim
],
delimiter
=
Delimiter
[
uncurry
isDelim
]
-- Condense multiple delimiters into one and then drop
-- Condense multiple delimiters into one and then drop them.
-- them.
,
condensePolicy
=
Condense
condensePolicy
=
Condense
,
delimPolicy
=
Drop
}
,
delimPolicy
=
Drop
}
isDelim
::
Char
->
Int
->
Bool
isDelim
::
Char
->
Int
->
Bool
isDelim
char
idx
=
char
`
elem
`
neverIdent
||
isSymbol
char
isDelim
char
idx
=
char
`
elem
`
neverIdent
||
isSymbol
char
...
...
src/IHaskell/Eval/Evaluate.hs
View file @
a43bbb90
This diff is collapsed.
Click to expand it.
src/IHaskell/Eval/Hoogle.hs
View file @
a43bbb90
...
@@ -64,7 +64,7 @@ query str = do
...
@@ -64,7 +64,7 @@ query str = do
-- | Copied from the HTTP package.
-- | Copied from the HTTP package.
urlEncode
::
String
->
String
urlEncode
::
String
->
String
urlEncode
[]
=
[]
urlEncode
[]
=
[]
urlEncode
(
ch
:
t
)
urlEncode
(
ch
:
t
)
|
(
isAscii
ch
&&
isAlphaNum
ch
)
||
ch
`
P
.
elem
`
"-_.~"
=
ch
:
urlEncode
t
|
(
isAscii
ch
&&
isAlphaNum
ch
)
||
ch
`
P
.
elem
`
"-_.~"
=
ch
:
urlEncode
t
|
not
(
isAscii
ch
)
=
P
.
foldr
escape
(
urlEncode
t
)
(
eightBs
[]
(
P
.
fromEnum
ch
))
|
not
(
isAscii
ch
)
=
P
.
foldr
escape
(
urlEncode
t
)
(
eightBs
[]
(
P
.
fromEnum
ch
))
...
@@ -128,7 +128,6 @@ render HTML = renderHtml
...
@@ -128,7 +128,6 @@ render HTML = renderHtml
-- | Render a Hoogle result to plain text.
-- | Render a Hoogle result to plain text.
renderPlain
::
HoogleResult
->
String
renderPlain
::
HoogleResult
->
String
renderPlain
(
NoResult
res
)
=
renderPlain
(
NoResult
res
)
=
"No response available: "
++
res
"No response available: "
++
res
...
@@ -220,13 +219,13 @@ renderDocs doc =
...
@@ -220,13 +219,13 @@ renderDocs doc =
let
groups
=
groupBy
bothAreCode
$
lines
doc
let
groups
=
groupBy
bothAreCode
$
lines
doc
nonull
=
filter
(
not
.
null
.
strip
)
nonull
=
filter
(
not
.
null
.
strip
)
bothAreCode
s1
s2
=
bothAreCode
s1
s2
=
startswith
">"
(
strip
s1
)
&&
startswith
">"
(
strip
s1
)
&&
startswith
">"
(
strip
s2
)
startswith
">"
(
strip
s2
)
isCode
(
s
:
_
)
=
startswith
">"
$
strip
s
isCode
(
s
:
_
)
=
startswith
">"
$
strip
s
makeBlock
lines
=
makeBlock
lines
=
if
isCode
lines
if
isCode
lines
then
div
"hoogle-code"
$
unlines
$
nonull
lines
then
div
"hoogle-code"
$
unlines
$
nonull
lines
else
div
"hoogle-text"
$
unlines
$
nonull
lines
else
div
"hoogle-text"
$
unlines
$
nonull
lines
in
div
"hoogle-doc"
$
unlines
$
map
makeBlock
groups
in
div
"hoogle-doc"
$
unlines
$
map
makeBlock
groups
extractPackageName
::
String
->
Maybe
String
extractPackageName
::
String
->
Maybe
String
...
...
src/IHaskell/Eval/Lint.hs
View file @
a43bbb90
...
@@ -194,7 +194,6 @@ htmlSuggestions = concatMap toHtml
...
@@ -194,7 +194,6 @@ htmlSuggestions = concatMap toHtml
floating
::
String
->
String
->
String
floating
::
String
->
String
->
String
floating
dir
thing
=
[
i
|
<div class="suggestion-row" style="float: ${dir};">${thing}</div>
|]
floating
dir
thing
=
[
i
|
<div class="suggestion-row" style="float: ${dir};">${thing}</div>
|]
showSuggestion
::
String
->
String
showSuggestion
::
String
->
String
showSuggestion
=
remove
lintIdent
.
dropDo
showSuggestion
=
remove
lintIdent
.
dropDo
where
where
...
...
src/IHaskell/Eval/Parser.hs
View file @
a43bbb90
...
@@ -225,7 +225,6 @@ joinFunctions blocks =
...
@@ -225,7 +225,6 @@ joinFunctions blocks =
conjoin
::
[
CodeBlock
]
->
CodeBlock
conjoin
::
[
CodeBlock
]
->
CodeBlock
conjoin
=
Declaration
.
intercalate
"
\n
"
.
map
str
conjoin
=
Declaration
.
intercalate
"
\n
"
.
map
str
-- | Parse a pragma of the form {-# LANGUAGE ... #-}
-- | Parse a pragma of the form {-# LANGUAGE ... #-}
parsePragma
::
String
-- ^ Pragma string.
parsePragma
::
String
-- ^ Pragma string.
->
Int
-- ^ Line number at which the directive appears.
->
Int
-- ^ Line number at which the directive appears.
...
@@ -245,7 +244,6 @@ parsePragma ('{':'-':'#':pragma) line =
...
@@ -245,7 +244,6 @@ parsePragma ('{':'-':'#':pragma) line =
parseDirective
::
String
-- ^ Directive string.
parseDirective
::
String
-- ^ Directive string.
->
Int
-- ^ Line number at which the directive appears.
->
Int
-- ^ Line number at which the directive appears.
->
CodeBlock
-- ^ Directive code block or a parse error.
->
CodeBlock
-- ^ Directive code block or a parse error.
parseDirective
(
':'
:
'!'
:
directive
)
line
=
Directive
ShellCmd
$
'!'
:
directive
parseDirective
(
':'
:
'!'
:
directive
)
line
=
Directive
ShellCmd
$
'!'
:
directive
parseDirective
(
':'
:
directive
)
line
=
parseDirective
(
':'
:
directive
)
line
=
case
find
rightDirective
directives
of
case
find
rightDirective
directives
of
...
@@ -254,9 +252,9 @@ parseDirective (':':directive) line =
...
@@ -254,9 +252,9 @@ parseDirective (':':directive) line =
_
:
restLine
=
words
directive
_
:
restLine
=
words
directive
Nothing
->
Nothing
->
let
directiveStart
=
let
directiveStart
=
case
words
directive
of
case
words
directive
of
[]
->
""
[]
->
""
first
:
_
->
first
first
:
_
->
first
in
ParseError
(
Loc
line
1
)
$
"Unknown directive: '"
++
directiveStart
++
"'."
in
ParseError
(
Loc
line
1
)
$
"Unknown directive: '"
++
directiveStart
++
"'."
where
where
rightDirective
(
_
,
dirname
)
=
rightDirective
(
_
,
dirname
)
=
...
...
src/IHaskell/Eval/Util.hs
View file @
a43bbb90
...
@@ -72,12 +72,11 @@ extensionFlag ext =
...
@@ -72,12 +72,11 @@ extensionFlag ext =
-- Check if a FlagSpec matches "No<ExtensionName>". In that case, we disable the extension.
-- Check if a FlagSpec matches "No<ExtensionName>". In that case, we disable the extension.
flagMatchesNo
ext
fs
=
ext
==
"No"
++
flagSpecName
fs
flagMatchesNo
ext
fs
=
ext
==
"No"
++
flagSpecName
fs
#
if
!
MIN_VERSION_ghc
(
7
,
10
,
0
)
#
if
!
MIN_VERSION_ghc
(
7
,
10
,
0
)
flagSpecName
(
name
,
_
,
_
)
=
name
flagSpecName
(
name
,
_
,
_
)
=
name
flagSpecFlag
(
_
,
flag
,
_
)
=
flag
flagSpecFlag
(
_
,
flag
,
_
)
=
flag
#
endif
#
endif
-- | Pretty-print dynamic flags (taken from 'InteractiveUI' module of `ghc-bin`)
-- | Pretty-print dynamic flags (taken from 'InteractiveUI' module of `ghc-bin`)
pprDynFlags
::
Bool
-- ^ Whether to include flags which are on by default
pprDynFlags
::
Bool
-- ^ Whether to include flags which are on by default
->
DynFlags
->
DynFlags
...
@@ -111,17 +110,20 @@ pprDynFlags show_all dflags =
...
@@ -111,17 +110,20 @@ pprDynFlags show_all dflags =
default_dflags
=
defaultDynFlags
(
settings
dflags
)
default_dflags
=
defaultDynFlags
(
settings
dflags
)
fstr
str
=
text
"-f"
<>
text
str
fstr
str
=
text
"-f"
<>
text
str
fnostr
str
=
text
"-fno-"
<>
text
str
fnostr
str
=
text
"-fno-"
<>
text
str
(
ghciFlags
,
others
)
=
partition
(
\
f
->
flagSpecFlag
f
`
elem
`
flgs
)
DynFlags
.
fFlags
(
ghciFlags
,
others
)
=
partition
(
\
f
->
flagSpecFlag
f
`
elem
`
flgs
)
DynFlags
.
fFlags
flgs
=
concat
[
flgs1
,
flgs2
,
flgs3
]
flgs
=
concat
[
flgs1
,
flgs2
,
flgs3
]
flgs1
=
[
Opt_PrintExplicitForalls
]
flgs1
=
[
Opt_PrintExplicitForalls
]
#
if
MIN_VERSION_ghc
(
7
,
8
,
0
)
#
if
MIN_VERSION_ghc
(
7
,
8
,
0
)
flgs2
=
[
Opt_PrintExplicitKinds
]
flgs2
=
[
Opt_PrintExplicitKinds
]
#
else
#
else
flgs2
=
[]
flgs2
=
[]
#
endif
#
endif
flgs3
=
[
Opt_PrintBindResult
,
Opt_BreakOnException
,
Opt_BreakOnError
,
Opt_PrintEvldWithShow
]
flgs3
=
[
Opt_PrintBindResult
,
Opt_BreakOnException
,
Opt_BreakOnError
,
Opt_PrintEvldWithShow
]
-- | Pretty-print the base language and active options (taken from `InteractiveUI` module of
-- | Pretty-print the base language and active options (taken from `InteractiveUI` module of
-- `ghc-bin`)
-- `ghc-bin`)
...
@@ -319,7 +321,6 @@ cleanUpDuplicateInstances = modifySession $ \hscEnv ->
...
@@ -319,7 +321,6 @@ cleanUpDuplicateInstances = modifySession $ \hscEnv ->
#
else
#
else
instEq
_
_
=
False
instEq
_
_
=
False
#
endif
#
endif
-- | Get the type of an expression and convert it to a string.
-- | Get the type of an expression and convert it to a string.
getType
::
GhcMonad
m
=>
String
->
m
String
getType
::
GhcMonad
m
=>
String
->
m
String
getType
expr
=
do
getType
expr
=
do
...
...
src/IHaskell/Flags.hs
View file @
a43bbb90
...
@@ -44,7 +44,6 @@ data LhsStyle string =
...
@@ -44,7 +44,6 @@ data LhsStyle string =
}
}
deriving
(
Eq
,
Functor
,
Show
)
deriving
(
Eq
,
Functor
,
Show
)
data
NotebookFormat
=
LhsMarkdown
data
NotebookFormat
=
LhsMarkdown
|
IpynbFile
|
IpynbFile
deriving
(
Eq
,
Show
)
deriving
(
Eq
,
Show
)
...
@@ -155,6 +154,7 @@ convert = mode "convert" (Args ConvertLhs []) description unnamedArg convertFlag
...
@@ -155,6 +154,7 @@ convert = mode "convert" (Args ConvertLhs []) description unnamedArg convertFlag
lhsStyleBird
,
lhsStyleTex
::
LhsStyle
String
lhsStyleBird
,
lhsStyleTex
::
LhsStyle
String
lhsStyleBird
=
LhsStyle
"> "
"
\n
<< "
""
""
""
""
lhsStyleBird
=
LhsStyle
"> "
"
\n
<< "
""
""
""
""
lhsStyleTex
=
LhsStyle
""
""
"
\\
begin{code}"
"
\\
end{code}"
"
\\
begin{verbatim}"
"
\\
end{verbatim}"
lhsStyleTex
=
LhsStyle
""
""
"
\\
begin{code}"
"
\\
end{code}"
"
\\
begin{verbatim}"
"
\\
end{verbatim}"
ihaskellArgs
::
Mode
Args
ihaskellArgs
::
Mode
Args
...
...
src/IHaskell/IPython.hs
View file @
a43bbb90
...
@@ -196,7 +196,6 @@ subHome path = shelly $ do
...
@@ -196,7 +196,6 @@ subHome path = shelly $ do
home
<-
unpack
<$>
fromMaybe
"~"
<$>
get_env
"HOME"
home
<-
unpack
<$>
fromMaybe
"~"
<$>
get_env
"HOME"
return
$
replace
"~"
home
path
return
$
replace
"~"
home
path
-- | Get the path to an executable. If it doensn't exist, fail with an error message complaining
-- | Get the path to an executable. If it doensn't exist, fail with an error message complaining
-- about it.
-- about it.
path
::
Text
->
Sh
FilePath
path
::
Text
->
Sh
FilePath
...
...
src/IHaskell/Types.hs
View file @
a43bbb90
...
@@ -41,8 +41,8 @@ import IHaskell.IPython.Kernel
...
@@ -41,8 +41,8 @@ import IHaskell.IPython.Kernel
-- | A class for displayable Haskell types.
-- | A class for displayable Haskell types.
--
--
-- IHaskell's displaying of results behaves as if these two
-- IHaskell's displaying of results behaves as if these two
overlapping/undecidable instances also
--
overlapping/undecidable instances also
existed:
-- existed:
--
--
-- > instance (Show a) => IHaskellDisplay a
-- > instance (Show a) => IHaskellDisplay a
-- > instance Show a where shows _ = id
-- > instance Show a where shows _ = id
...
@@ -51,12 +51,10 @@ class IHaskellDisplay a where
...
@@ -51,12 +51,10 @@ 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.
-- | Output target name for this widget. The actual input parameter should be ignored.
-- The actual input parameter should be ignored.
targetName
::
a
->
String
targetName
::
a
->
String
-- | Called when the comm is opened. Allows additional messages to be sent
-- | Called when the comm is opened. Allows additional messages to be sent after comm open.
-- after comm open.
open
::
a
-- ^ Widget to open a comm port with.
open
::
a
-- ^ Widget to open a comm port with.
->
(
Value
->
IO
()
)
-- ^ Way to respond to the message.
->
(
Value
->
IO
()
)
-- ^ Way to respond to the message.
->
IO
()
->
IO
()
...
@@ -76,7 +74,7 @@ class IHaskellDisplay a => IHaskellWidget a where
...
@@ -76,7 +74,7 @@ class IHaskellDisplay a => IHaskellWidget a where
close
_
_
=
return
()
close
_
_
=
return
()
data
Widget
=
forall
a
.
IHaskellWidget
a
=>
Widget
a
data
Widget
=
forall
a
.
IHaskellWidget
a
=>
Widget
a
deriving
Typeable
deriving
Typeable
instance
IHaskellDisplay
Widget
where
instance
IHaskellDisplay
Widget
where
display
(
Widget
widget
)
=
display
widget
display
(
Widget
widget
)
=
display
widget
...
@@ -90,20 +88,20 @@ instance IHaskellWidget Widget where
...
@@ -90,20 +88,20 @@ instance IHaskellWidget Widget where
instance
Show
Widget
where
instance
Show
Widget
where
show
_
=
"<Widget>"
show
_
=
"<Widget>"
-- | Wrapper for ipython-kernel's DisplayData which allows sending multiple results from the same
-- | Wrapper for ipython-kernel's DisplayData which allows sending multiple results from the same
-- expression.
-- expression.
data
Display
=
Display
[
DisplayData
]
data
Display
=
Display
[
DisplayData
]
|
ManyDisplay
[
Display
]
|
ManyDisplay
[
Display
]
deriving
(
Show
,
Typeable
,
Generic
)
deriving
(
Show
,
Typeable
,
Generic
)
instance
Serialize
Display
instance
Serialize
Display
instance
Monoid
Display
where
instance
Monoid
Display
where
mempty
=
Display
[]
mempty
=
Display
[]
ManyDisplay
a
`
mappend
`
ManyDisplay
b
=
ManyDisplay
(
a
++
b
)
ManyDisplay
a
`
mappend
`
ManyDisplay
b
=
ManyDisplay
(
a
++
b
)
ManyDisplay
a
`
mappend
`
b
=
ManyDisplay
(
a
++
[
b
])
ManyDisplay
a
`
mappend
`
b
=
ManyDisplay
(
a
++
[
b
])
a
`
mappend
`
ManyDisplay
b
=
ManyDisplay
(
a
:
b
)
a
`
mappend
`
ManyDisplay
b
=
ManyDisplay
(
a
:
b
)
a
`
mappend
`
b
=
ManyDisplay
[
a
,
b
]
a
`
mappend
`
b
=
ManyDisplay
[
a
,
b
]
instance
Semigroup
Display
where
instance
Semigroup
Display
where
a
<>
b
=
a
`
mappend
`
b
a
<>
b
=
a
`
mappend
`
b
...
...
src/Main.hs
View file @
a43bbb90
...
@@ -196,7 +196,6 @@ createReplyHeader parent = do
...
@@ -196,7 +196,6 @@ createReplyHeader parent = do
-- | Compute a reply to a message.
-- | Compute a reply to a message.
replyTo
::
ZeroMQInterface
->
Message
->
MessageHeader
->
KernelState
->
Interpreter
(
KernelState
,
Message
)
replyTo
::
ZeroMQInterface
->
Message
->
MessageHeader
->
KernelState
->
Interpreter
(
KernelState
,
Message
)
-- Reply to kernel info requests with a kernel info reply. No computation needs to be done, as a
-- Reply to kernel info requests with a kernel info reply. No computation needs to be done, as a
-- kernel info reply is a static object (all info is hard coded into the representation of that
-- kernel info reply is a static object (all info is hard coded into the representation of that
-- message type).
-- message type).
...
@@ -214,32 +213,29 @@ replyTo interface ShutdownRequest { restartPending = restartPending } replyHeade
...
@@ -214,32 +213,29 @@ replyTo interface ShutdownRequest { restartPending = restartPending } replyHeade
writeChan
(
shellReplyChannel
interface
)
$
ShutdownReply
replyHeader
restartPending
writeChan
(
shellReplyChannel
interface
)
$
ShutdownReply
replyHeader
restartPending
exitSuccess
exitSuccess
-- Reply to an execution request. The reply itself does not require
-- Reply to an execution request. The reply itself does not require computation, but this causes
-- computation, but this causes messages to be sent to the IOPub socket
-- messages to be sent to the IOPub socket with the output of the code in the execution request.
-- with the output of the code in the execution request.
replyTo
interface
req
@
ExecuteRequest
{
getCode
=
code
}
replyHeader
state
=
do
replyTo
interface
req
@
ExecuteRequest
{
getCode
=
code
}
replyHeader
state
=
do
-- Convenience function to send a message to the IOPub socket.
-- Convenience function to send a message to the IOPub socket.
let
send
msg
=
liftIO
$
writeChan
(
iopubChannel
interface
)
msg
let
send
msg
=
liftIO
$
writeChan
(
iopubChannel
interface
)
msg
-- Log things so that we can use stdin.
-- Log things so that we can use stdin.
dir
<-
liftIO
getIHaskellDir
dir
<-
liftIO
getIHaskellDir
liftIO
$
Stdin
.
recordParentHeader
dir
$
header
req
liftIO
$
Stdin
.
recordParentHeader
dir
$
header
req
-- Notify the frontend that the kernel is busy computing.
-- Notify the frontend that the kernel is busy computing. All the headers are copies of the reply
-- All the headers are copies of the reply header with a different
-- header with a different message type, because this preserves the session ID, parent header, and
-- message type, because this preserves the session ID, parent header,
-- other important information.
-- and other important information.
busyHeader
<-
liftIO
$
dupHeader
replyHeader
StatusMessage
busyHeader
<-
liftIO
$
dupHeader
replyHeader
StatusMessage
send
$
PublishStatus
busyHeader
Busy
send
$
PublishStatus
busyHeader
Busy
-- Construct a function for publishing output as this is going.
-- Construct a function for publishing output as this is going. This function accepts a boolean
-- This function accepts a boolean indicating whether this is the final
-- indicating whether this is the final output and the thing to display. Store the final outputs in
-- output and the thing to display. Store the final outputs in a list so
-- a list so that when we receive an updated non-final output, we can clear the entire output and
-- that when we receive an updated non-final output, we can clear the
-- re-display with the updated output.
-- entire output and re-display with the updated output.
displayed
<-
liftIO
$
newMVar
[]
displayed
<-
liftIO
$
newMVar
[]
updateNeeded
<-
liftIO
$
newMVar
False
updateNeeded
<-
liftIO
$
newMVar
False
pagerOutput
<-
liftIO
$
newMVar
""
pagerOutput
<-
liftIO
$
newMVar
""
let
clearOutput
=
do
let
clearOutput
=
do
header
<-
dupHeader
replyHeader
ClearOutputMessage
header
<-
dupHeader
replyHeader
ClearOutputMessage
send
$
ClearOutput
header
True
send
$
ClearOutput
header
True
...
@@ -253,7 +249,7 @@ replyTo interface req@ExecuteRequest{ getCode = code } replyHeader state = do
...
@@ -253,7 +249,7 @@ replyTo interface req@ExecuteRequest{ getCode = code } replyHeader state = do
convertSvgToHtml
x
=
x
convertSvgToHtml
x
=
x
makeSvgImg
base64data
=
unpack
$
"<img src=
\"
data:image/svg+xml;base64,"
++
base64data
++
"
\"
/>"
makeSvgImg
base64data
=
unpack
$
"<img src=
\"
data:image/svg+xml;base64,"
++
base64data
++
"
\"
/>"
prependCss
(
DisplayData
MimeHtml
html
)
=
prependCss
(
DisplayData
MimeHtml
html
)
=
DisplayData
MimeHtml
$
concat
[
"<style>"
,
pack
ihaskellCSS
,
"</style>"
,
html
]
DisplayData
MimeHtml
$
concat
[
"<style>"
,
pack
ihaskellCSS
,
"</style>"
,
html
]
prependCss
x
=
x
prependCss
x
=
x
...
@@ -271,9 +267,10 @@ replyTo interface req@ExecuteRequest{ getCode = code } replyHeader state = do
...
@@ -271,9 +267,10 @@ replyTo interface req@ExecuteRequest{ getCode = code } replyHeader state = do
publish
::
EvaluationResult
->
IO
()
publish
::
EvaluationResult
->
IO
()
publish
result
=
do
publish
result
=
do
let
final
=
case
result
of
let
final
=
IntermediateResult
{}
->
False
case
result
of
FinalResult
{}
->
True
IntermediateResult
{}
->
False
FinalResult
{}
->
True
outs
=
outputs
result
outs
=
outputs
result
-- If necessary, clear all previous output and redraw.
-- If necessary, clear all previous output and redraw.
...
@@ -286,12 +283,11 @@ replyTo interface req@ExecuteRequest{ getCode = code } replyHeader state = do
...
@@ -286,12 +283,11 @@ replyTo interface req@ExecuteRequest{ getCode = code } replyHeader state = do
-- Draw this message.
-- Draw this message.
sendOutput
outs
sendOutput
outs
-- If this is the final message, add it to the list of completed
-- If this is the final message, add it to the list of completed messages. If it isn't, make sure we
-- messages. If it isn't, make sure we clear it later by marking
-- clear it later by marking update needed as true.
-- update needed as true.
modifyMVar_
updateNeeded
(
const
$
return
$
not
final
)
modifyMVar_
updateNeeded
(
const
$
return
$
not
final
)
when
final
$
do
when
final
$
do
modifyMVar_
displayed
(
return
.
(
outs
:
))
modifyMVar_
displayed
(
return
.
(
outs
:
))
-- Start all comms that need to be started.
-- Start all comms that need to be started.
mapM_
startComm
$
startComms
result
mapM_
startComm
$
startComms
result
...
@@ -300,8 +296,8 @@ replyTo interface req@ExecuteRequest{ getCode = code } replyHeader state = do
...
@@ -300,8 +296,8 @@ replyTo interface req@ExecuteRequest{ getCode = code } replyHeader state = do
let
pager
=
pagerOut
result
let
pager
=
pagerOut
result
unless
(
null
pager
)
$
unless
(
null
pager
)
$
if
usePager
state
if
usePager
state
then
modifyMVar_
pagerOutput
(
return
.
(
++
pager
++
"
\n
"
))
then
modifyMVar_
pagerOutput
(
return
.
(
++
pager
++
"
\n
"
))
else
sendOutput
$
Display
[
html
pager
]
else
sendOutput
$
Display
[
html
pager
]
let
execCount
=
getExecutionCounter
state
let
execCount
=
getExecutionCounter
state
-- Let all frontends know the execution count and code that's about to run
-- Let all frontends know the execution count and code that's about to run
...
@@ -317,14 +313,15 @@ replyTo interface req@ExecuteRequest{ getCode = code } replyHeader state = do
...
@@ -317,14 +313,15 @@ replyTo interface req@ExecuteRequest{ getCode = code } replyHeader state = do
-- Take pager output if we're using the pager.
-- Take pager output if we're using the pager.
pager
<-
if
usePager
state
pager
<-
if
usePager
state
then
liftIO
$
readMVar
pagerOutput
then
liftIO
$
readMVar
pagerOutput
else
return
""
else
return
""
return
(
updatedState
,
ExecuteReply
{
return
header
=
replyHeader
,
(
updatedState
,
ExecuteReply
pagerOutput
=
pager
,
{
header
=
replyHeader
executionCounter
=
execCount
,
,
pagerOutput
=
pager
status
=
Ok
,
executionCounter
=
execCount
})
,
status
=
Ok
})
replyTo
_
req
@
CompleteRequest
{}
replyHeader
state
=
do
replyTo
_
req
@
CompleteRequest
{}
replyHeader
state
=
do
...
@@ -352,11 +349,11 @@ replyTo _ ObjectInfoRequest { objectName = oname } replyHeader state = do
...
@@ -352,11 +349,11 @@ replyTo _ ObjectInfoRequest { objectName = oname } replyHeader state = do
-- TODO: Implement history_reply.
-- TODO: Implement history_reply.
replyTo
_
HistoryRequest
{}
replyHeader
state
=
do
replyTo
_
HistoryRequest
{}
replyHeader
state
=
do
let
reply
=
HistoryReply
{
let
reply
=
HistoryReply
header
=
replyHeader
,
{
header
=
replyHeader
-- FIXME
-- FIXME
historyReply
=
[]
,
historyReply
=
[]
}
}
return
(
state
,
reply
)
return
(
state
,
reply
)
handleComm
::
(
Message
->
IO
()
)
->
KernelState
->
Message
->
MessageHeader
->
IO
KernelState
handleComm
::
(
Message
->
IO
()
)
->
KernelState
->
Message
->
MessageHeader
->
IO
KernelState
...
...
verify_formatting.py
View file @
a43bbb90
...
@@ -14,6 +14,11 @@ def hindent(contents):
...
@@ -14,6 +14,11 @@ def hindent(contents):
def
diff
(
src1
,
src2
):
def
diff
(
src1
,
src2
):
# Ignore trailing newlines
if
src1
[
-
1
]
==
"
\n
"
:
src1
=
src1
[:
-
1
]
if
src2
[
-
1
]
==
"
\n
"
:
src2
=
src2
[:
-
1
]
with
open
(
".tmp1"
,
"w"
)
as
f1
:
with
open
(
".tmp1"
,
"w"
)
as
f1
:
f1
.
write
(
src1
)
f1
.
write
(
src1
)
...
@@ -40,8 +45,6 @@ for root, dirnames, filenames in os.walk("src"):
...
@@ -40,8 +45,6 @@ for root, dirnames, filenames in os.walk("src"):
for
filename
in
filenames
:
for
filename
in
filenames
:
if
filename
.
endswith
(
".hs"
):
if
filename
.
endswith
(
".hs"
):
sources
.
append
(
os
.
path
.
join
(
root
,
filename
))
sources
.
append
(
os
.
path
.
join
(
root
,
filename
))
break
break
hindent_outputs
=
{}
hindent_outputs
=
{}
...
...
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