Commit 4a123f0f authored by Andrew Gibiansky's avatar Andrew Gibiansky

added demo notebook

parent 46797e1c
This diff is collapsed.
This diff is collapsed.
......@@ -69,7 +69,7 @@ typeCleaner = useStringType . foldl' (.) id (map (`replace` "") fullPrefixes)
useStringType = replace "[Char]" "String"
write :: GhcMonad m => String -> m ()
write x = when debug $ liftIO $ hPutStrLn stderr x
write x = when debug $ liftIO $ hPutStrLn stderr $ "DEBUG: " ++ x
type Interpreter = Ghc
......@@ -466,8 +466,10 @@ evalCommand output (Expression expr) state = do
-- implement the Show typeclass.
isShowError errs = case find isPlain errs of
Just (Display PlainText msg) ->
startswith "No instance for (GHC.Show.Show" msg &&
isInfixOf " arising from a use of `System.IO.print'" msg
-- Note that we rely on this error message being 'type cleaned', so
-- that `Show` is not displayed as GHC.Show.Show.
startswith "No instance for (Show" msg &&
isInfixOf " arising from a use of `print'" msg
Nothing -> False
where isPlain (Display mime _) = mime == PlainText
......@@ -479,7 +481,9 @@ evalCommand output (Expression expr) state = do
-- attempting to do this without the serialization to binary and
-- back gives very strange errors - all the types match but it
-- refuses to decode back into a [DisplayData].
runStmt displayExpr RunToCompletion
-- Suppress output, so as not to mess up console.
capturedStatement (const $ return ()) displayExpr
displayedBytestring <- dynCompileExpr "IHaskell.Display.serializeDisplay it"
case fromDynamic displayedBytestring of
Nothing -> error "Expecting lazy Bytestring"
......
......@@ -80,10 +80,11 @@ htmlSuggestions suggests = table (concatMap toHtml suggests)
++
row (
el (style severityClass "Found:" ++
style "code" (found suggest))
-- Things that look like this get highlighted.
styleId "highlight-code" "haskell" (found suggest))
++
el (style severityClass "Why Not:" ++
style "code" (whyNot suggest)))
styleId "highlight-code" "haskell" (whyNot suggest)))
where
severityClass = case severity suggest of
LintWarning -> "warning"
......@@ -91,6 +92,9 @@ htmlSuggestions suggests = table (concatMap toHtml suggests)
style :: String -> String -> String
style cls thing = [i| <div class="suggestion-${cls}">${thing}</div> |]
styleId :: String -> String -> String -> String
styleId cls id thing = [i| <div class="${cls}" id="${id}">${thing}</div> |]
table :: String -> String
table thing = [i| <table class="suggestion-table">${thing}</table> |]
......
No preview for this file type
......@@ -81,22 +81,25 @@ $([IPython.events]).on('app_initialized.NotebookApp', function(){
IPython.CodeCell.options_default['cm_config']['mode'] = 'haskell';
});
var highlightHlint = function() {
var highlightCodes = function() {
// Add logic here that should be run once per reply.
$('.suggestion-code').each(function() {
$('.highlight-code').each(function() {
var $this = $(this),
$code = $this.html(),
$unescaped = $('<div/>').html($code).text();
$this.empty();
// Never highlight this block again.
this.className = "";
CodeMirror(this, {
value: $unescaped,
mode: 'haskell',
mode: this.id,
lineNumbers: false,
readOnly: true
});
});
};
$([IPython.events]).on('shell_reply.Kernel', highlightHlint);
$([IPython.events]).on('shell_reply.Kernel', highlightCodes);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment