packages feed

ihaskell 0.8.2.0 → 0.8.3.0

raw patch · 8 files changed

+153/−135 lines, 8 filesdep −heredep ~haskell-src-extsdep ~ipython-kernel

Dependencies removed: here

Dependency ranges changed: haskell-src-exts, ipython-kernel

Files

− html/custom.css
@@ -1,96 +0,0 @@-/*-Custom IHaskell CSS.-*/--/* Styles used for the Hoogle display in the pager */-.hoogle-doc {-    display: block;-    padding-bottom: 1.3em;-    padding-left: 0.4em;-}-.hoogle-code {-    display: block;-    font-family: monospace;-    white-space: pre;-}-.hoogle-text {-    display: block;-}-.hoogle-name {-    color: green;-    font-weight: bold;-}-.hoogle-head {-    font-weight: bold;-}-.hoogle-sub {-    display: block;-    margin-left: 0.4em;-}-.hoogle-package {-    font-weight: bold;-    font-style: italic;-}-.hoogle-module {-    font-weight: bold;-}-.hoogle-class {-    font-weight: bold;-}--/* Styles used for basic displays */-.get-type {-    color: green;-    font-weight: bold;-    font-family: monospace;-    display: block;-    white-space: pre-wrap;-}--.show-type {-    color: green;-    font-weight: bold;-    font-family: monospace;-    margin-left: 1em;-}--.mono {-    font-family: monospace;-    display: block;-}--.err-msg {-    color: red;-    font-style: italic;-    font-family: monospace;-    white-space: pre;-    display: block;-}--#unshowable {-    color: red;-    font-weight: bold;-}--.err-msg.in.collapse {-  padding-top: 0.7em;-}--/* Code that will get highlighted before it is highlighted */-.highlight-code {-    white-space: pre;-    font-family: monospace;-}--/* Hlint styles */-.suggestion-warning { -    font-weight: bold;-    color: rgb(200, 130, 0);-}-.suggestion-error { -    font-weight: bold;-    color: red;-}-.suggestion-name {-    font-weight: bold;-}
ihaskell.cabal view
@@ -7,7 +7,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             0.8.2.0+version:             0.8.3.0  -- A short (one-line) description of the package. synopsis:            A Haskell backend kernel for the IPython project.@@ -44,7 +44,6 @@  data-files:      html/kernel.js-    html/custom.css     html/logo-64x64.png  flag binPkgDb@@ -68,9 +67,8 @@                        ghc-parser           >=0.1.7,                        ghc-paths            ==0.1.*,                        haskeline            -any,-                       here                 ==1.2.*,                        hlint                >=1.9 && <2.0,-                       haskell-src-exts     ==1.16.*,+                       haskell-src-exts     >=1.16 && < 1.18,                        http-client          == 0.4.*,                        http-client-tls      == 0.2.*,                        mtl                  >=2.1,@@ -114,6 +112,7 @@                    IHaskell.Flags                    IHaskell.Types                    IHaskell.BrokenPackages+                   IHaskell.CSS                    Paths_ihaskell   other-modules:                     IHaskellPrelude@@ -142,7 +141,6 @@                        transformers         -any,                        ghc                  >=7.6 || < 7.11,                        process              >=1.1,-                       here                 ==1.2.*,                        aeson                >=0.7 && < 0.11,                        bytestring           >=0.10,                        containers           >=0.5,@@ -180,9 +178,8 @@         ghc-parser >=0.1.7,         ghc-paths ==0.1.*,         haskeline -any,-        here ==1.2.*,         hlint >=1.9 && <2.0,-        haskell-src-exts ==1.16.*,+        haskell-src-exts     >=1.16 && < 1.18,         hspec -any,         HUnit -any,         mtl >=2.1,
main/Main.hs view
@@ -26,7 +26,6 @@ #endif import           System.Posix.Signals import qualified Data.Map as Map-import           Data.String.Here (hereFile) import qualified Data.Text.Encoding as E import           Data.List (break) @@ -103,6 +102,8 @@       kernelSpecOpts { kernelSpecGhcLibdir = libdir }     addFlag kernelSpecOpts (KernelspecInstallPrefix prefix) =       kernelSpecOpts { kernelSpecInstallPrefix = Just prefix }+    addFlag kernelSpecOpts KernelspecUseStack =+      kernelSpecOpts { kernelSpecUseStack = True }     addFlag kernelSpecOpts flag = error $ "Unknown flag" ++ show flag  -- | Run the IHaskell language kernel.@@ -112,6 +113,7 @@ runKernel kernelOpts profileSrc = do   let debug = kernelSpecDebug kernelOpts       libdir = kernelSpecGhcLibdir kernelOpts+      useStack = kernelSpecUseStack kernelOpts    -- Parse the profile file.   Just profile <- liftM decode $ LBS.readFile profileSrc@@ -121,22 +123,23 @@   Stdin.recordKernelProfile dir profile  #if MIN_VERSION_ghc(7,8,0)-  -- Detect if we have stack-  runResult <- try $ readProcessWithExitCode "stack" [] ""-  let stack = -        case runResult :: Either SomeException (ExitCode, String, String) of -          Left _ -> False-          Right (exitCode, stackStdout, _) -> exitCode == ExitSuccess && "The Haskell Tool Stack" `isInfixOf` stackStdout+  when useStack $ do+    -- Detect if we have stack+    runResult <- try $ readProcessWithExitCode "stack" [] ""+    let stack = +          case runResult :: Either SomeException (ExitCode, String, String) of +            Left _ -> False+            Right (exitCode, stackStdout, _) -> exitCode == ExitSuccess && "The Haskell Tool Stack" `isInfixOf` stackStdout -  -- If we're in a stack directory, use `stack` to set the environment-  -- We can't do this with base <= 4.6 because setEnv doesn't exist.-  when stack $ do-    stackEnv <- lines <$> readProcess "stack" ["exec", "env"] ""-    forM_ stackEnv $ \line ->-      let (var, val) = break (== '=') line-      in case tailMay val of-           Nothing -> return ()-           Just val' -> setEnv var val'+    -- If we're in a stack directory, use `stack` to set the environment+    -- We can't do this with base <= 4.6 because setEnv doesn't exist.+    when stack $ do+      stackEnv <- lines <$> readProcess "stack" ["exec", "env"] ""+      forM_ stackEnv $ \line ->+        let (var, val) = break (== '=') line+        in case tailMay val of+            Nothing -> return ()+            Just val' -> setEnv var val' #endif    -- Serve on all sockets and ports defined in the profile.@@ -302,6 +305,11 @@                      , status = Ok                      }) +-- Always assume that the code is complete, which allows for only+-- single line inputs for now.+replyTo _ IsCompleteRequest{} replyHeader state = do+  let reply = IsCompleteReply { header = replyHeader, reviewResult = CodeComplete }+  return (state, reply)  replyTo _ req@CompleteRequest{} replyHeader state = do   let code = getCode req
+ src/IHaskell/CSS.hs view
@@ -0,0 +1,96 @@+module IHaskell.CSS (ihaskellCSS) where++import           IHaskellPrelude++ihaskellCSS :: String+ihaskellCSS =+  unlines [ +  -- Custom IHaskell CSS+  "/* Styles used for the Hoogle display in the pager */"+  , ".hoogle-doc {"+  , "display: block;"+  , "padding-bottom: 1.3em;"+  , "padding-left: 0.4em;"+  , "}"+  , ".hoogle-code {"+  , "display: block;"+  , "font-family: monospace;"+  , "white-space: pre;"+  , "}"+  , ".hoogle-text {"+  , "display: block;"+  , "}"+  , ".hoogle-name {"+  , "color: green;"+  , "font-weight: bold;"+  , "}"+  , ".hoogle-head {"+  , "font-weight: bold;"+  , "}"+  , ".hoogle-sub {"+  , "display: block;"+  , "margin-left: 0.4em;"+  , "}"+  , ".hoogle-package {"+  , "font-weight: bold;"+  , "font-style: italic;"+  , "}"+  , ".hoogle-module {"+  , "font-weight: bold;"+  , "}"+  , ".hoogle-class {"+  , "font-weight: bold;"+  , "}"+  , +  -- Styles used for basic displays+  ".get-type {"+  , "color: green;"+  , "font-weight: bold;"+  , "font-family: monospace;"+  , "display: block;"+  , "white-space: pre-wrap;"+  , "}"+  , ".show-type {"+  , "color: green;"+  , "font-weight: bold;"+  , "font-family: monospace;"+  , "margin-left: 1em;"+  , "}"+  , ".mono {"+  , "font-family: monospace;"+  , "display: block;"+  , "}"+  , ".err-msg {"+  , "color: red;"+  , "font-style: italic;"+  , "font-family: monospace;"+  , "white-space: pre;"+  , "display: block;"+  , "}"+  , "#unshowable {"+  , "color: red;"+  , "font-weight: bold;"+  , "}"+  , ".err-msg.in.collapse {"+  , "padding-top: 0.7em;"+  , "}"+  , +  -- Code that will get highlighted before it is highlighted+  ".highlight-code {"+  , "white-space: pre;"+  , "font-family: monospace;"+  , "}"+  , +  -- Hlint styles+  ".suggestion-warning { "+  , "font-weight: bold;"+  , "color: rgb(200, 130, 0);"+  , "}"+  , ".suggestion-error { "+  , "font-weight: bold;"+  , "color: red;"+  , "}"+  , ".suggestion-name {"+  , "font-weight: bold;"+  , "}"+  ]
src/IHaskell/Eval/Lint.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE NoImplicitPrelude, FlexibleContexts, QuasiQuotes, ViewPatterns #-}+{-# LANGUAGE NoImplicitPrelude, FlexibleContexts, ViewPatterns #-}  module IHaskell.Eval.Lint (lint) where @@ -12,7 +12,6 @@ import           Prelude (head, tail, last) import           Control.Monad import           Data.List (findIndex)-import           Data.String.Here import           Data.Char import           Data.Monoid import           Data.Maybe (mapMaybe)@@ -188,16 +187,16 @@             _ -> "warning"      style :: String -> String -> String-    style cls thing = [i| <div class="suggestion-${cls}">${thing}</div> |]+    style =  printf "<div class=\"suggestion-${cls}\">%s</div>"      named :: String -> String-    named thing = [i| <div class="suggestion-name" style="clear:both;">${thing}</div> |]+    named = printf "<div class=\"suggestion-name\" style=\"clear:both;\">%s</div>"      styleId :: String -> String -> String -> String-    styleId cls id thing = [i| <div class="${cls}" id="${id}">${thing}</div> |]+    styleId = printf "<div class=\"%s\" id=\"%s\">%s</div>"      floating :: String -> String -> String-    floating dir thing = [i| <div class="suggestion-row" style="float: ${dir};">${thing}</div> |]+    floating = printf "<div class=\"suggestion-row\" style=\"float: %s;\">%s</div>"  showSuggestion :: String -> String showSuggestion = remove lintIdent . dropDo
src/IHaskell/Flags.hs view
@@ -38,6 +38,7 @@               | ConvertToFormat NotebookFormat               | ConvertLhsStyle (LhsStyle String)               | KernelspecInstallPrefix String+              | KernelspecUseStack   deriving (Eq, Show)  data LhsStyle string =@@ -100,6 +101,12 @@   where     addDebug (Args mode prev) = Args mode (KernelDebug : prev) +kernelStackFlag :: Flag Args+kernelStackFlag = flagNone ["stack"] addStack+                    "Inherit environment from `stack` when it is installed"+  where+    addStack (Args mode prev) = Args mode (KernelspecUseStack : prev)+ confFlag :: Flag Args confFlag = flagReq ["conf", "c"] (store ConfFile) "<rc.hs>"              "File with commands to execute at start; replaces ~/.ihaskell/rc.hs."@@ -118,11 +125,11 @@ installKernelSpec :: Mode Args installKernelSpec =   mode "install" (Args InstallKernelSpec []) "Install the Jupyter kernelspec." noArgs-    [ghcLibFlag, kernelDebugFlag, confFlag, installPrefixFlag, helpFlag]+    [ghcLibFlag, kernelDebugFlag, confFlag, installPrefixFlag, helpFlag, kernelStackFlag]  kernel :: Mode Args kernel = mode "kernel" (Args (Kernel Nothing) []) "Invoke the IHaskell kernel." kernelArg-           [ghcLibFlag, kernelDebugFlag, confFlag]+           [ghcLibFlag, kernelDebugFlag, confFlag, kernelStackFlag]   where     kernelArg = flagArg update "<json-kernel-file>"     update filename (Args _ flags) = Right $ Args (Kernel $ Just filename) flags
src/IHaskell/IPython.hs view
@@ -47,6 +47,7 @@          , kernelSpecDebug :: Bool                 -- ^ Spew debugging output?          , kernelSpecConfFile :: IO (Maybe String) -- ^ Filename of profile JSON file.          , kernelSpecInstallPrefix :: Maybe String+         , kernelSpecUseStack :: Bool              -- ^ Whether to use @stack@ environments.          }  defaultKernelSpecOptions :: KernelSpecOptions@@ -55,6 +56,7 @@   , kernelSpecDebug = False   , kernelSpecConfFile = defaultConfFile   , kernelSpecInstallPrefix = Nothing+  , kernelSpecUseStack = False   }  -- | The IPython kernel name.@@ -72,6 +74,13 @@       Nothing -> "ipython"       Just _  -> "jupyter" +locateIPython :: SH.Sh SH.FilePath+locateIPython = do+  mbinary <- SH.which "ipython"+  case mbinary of+    Nothing      -> SH.errorExit "The IPython binary could not be located"+    Just ipython -> return ipython+ -- | Run the IPython command with any arguments. The kernel is set to IHaskell. ipython :: Bool         -- ^ Whether to suppress output.         -> [Text]       -- ^ IPython command line arguments.@@ -181,6 +190,7 @@            Nothing   -> []            Just file -> ["--conf", file])         ++ ["--ghclib", kernelSpecGhcLibdir opts]+           ++ ["--stack" | kernelSpecUseStack opts]    let kernelSpec = KernelSpec         { kernelDisplayName = "Haskell"@@ -201,15 +211,17 @@       src <- liftIO $ Paths.getDataFileName $ "html/" ++ file       SH.cp (SH.fromText $ T.pack src) (tmp SH.</> kernelName SH.</> file) -    Just ipython <- SH.which "ipython"+    ipython <- locateIPython+     let replaceFlag = ["--replace" | replace]         installPrefixFlag = maybe ["--user"] (\prefix -> ["--prefix", T.pack prefix]) (kernelSpecInstallPrefix opts)         cmd = concat [["kernelspec", "install"], installPrefixFlag, [SH.toTextIgnore kernelDir], replaceFlag]+     SH.silently $ SH.run ipython cmd  kernelSpecCreated :: SH.Sh Bool kernelSpecCreated = do-  Just ipython <- SH.which "ipython"+  ipython <- locateIPython   out <- SH.silently $ SH.run ipython ["kernelspec", "list"]   let kernelspecs = map T.strip $ T.lines out   return $ T.pack kernelName `elem` kernelspecs
src/IHaskell/Publish.hs view
@@ -1,18 +1,13 @@-{-# LANGUAGE QuasiQuotes #-}- module IHaskell.Publish (publishResult) where  import           IHaskellPrelude -import           Data.String.Here (hereFile) import qualified Data.Text as T import qualified Data.Text.Encoding as E  import           IHaskell.Display import           IHaskell.Types--ihaskellCSS :: String-ihaskellCSS = [hereFile|html/custom.css|]+import           IHaskell.CSS (ihaskellCSS)  -- | Publish evaluation results, ignore any CommMsgs. This function can be used to create a function -- of type (EvaluationResult -> IO ()), which can be used to publish results to the frontend. The