ipython-kernel 0.8.0.0 → 0.8.1.0
raw patch · 7 files changed
+36/−29 lines, 7 files
Files
- examples/Calc.hs +2/−1
- examples/Simple.hs +16/−16
- ipython-kernel.cabal +1/−1
- src/IHaskell/IPython/EasyKernel.hs +5/−7
- src/IHaskell/IPython/Message/Parser.hs +4/−3
- src/IHaskell/IPython/Message/Writer.hs +6/−1
- src/IHaskell/IPython/Types.hs +2/−0
examples/Calc.hs view
@@ -265,4 +265,5 @@ _ -> do putStrLn "Usage:" putStrLn "simple-calc-example install -- set up the kernelspec"- putStrLn "simple-calc-example kernel FILE -- run a kernel with FILE for communication with the frontend"+ putStrLn+ "simple-calc-example kernel FILE -- run a kernel with FILE for communication with the frontend"
examples/Simple.hs view
@@ -2,13 +2,13 @@ import qualified Data.Text as T -import System.Environment (getArgs)+import System.Environment (getArgs) -import Text.Parsec-import Text.Parsec.String+import Text.Parsec+import Text.Parsec.String -import IHaskell.IPython.EasyKernel (easyKernel, installKernelspec, KernelConfig(..))-import IHaskell.IPython.Types+import IHaskell.IPython.EasyKernel (easyKernel, installKernelspec, KernelConfig(..))+import IHaskell.IPython.Types -- Define the actual language! data Expr = Plus Expr Expr@@ -47,12 +47,13 @@ char ',' y <- expr char ')'- return $ case func of- "plus" -> Plus x y- "minus" -> Minus x y- "times" -> Times x y- "div" -> Div x y- "exp" -> Exp x y+ return $+ case func of+ "plus" -> Plus x y+ "minus" -> Minus x y+ "times" -> Times x y+ "div" -> Div x y+ "exp" -> Exp x y languageConfig :: LanguageInfo languageConfig = LanguageInfo@@ -73,11 +74,10 @@ displayString str = [DisplayData PlainText (T.pack str)] languageCompletion :: Monad m => T.Text -> Int -> m (T.Text, [T.Text])-languageCompletion code pos = return $ +languageCompletion code pos = return $ let (before, _) = T.splitAt pos code word = last $ T.words $ T.map replace before in (word, map T.pack $ matches $ T.unpack word)- where matches :: String -> [String] matches word =@@ -92,7 +92,7 @@ replace '(' = ' ' replace ')' = ' ' replace ',' = ' '- replace x = x+ replace x = x languageInspect :: Monad m => T.Text -> Int -> m (Maybe [DisplayData]) languageInspect _ _ = return $@@ -120,7 +120,6 @@ Left err -> err Right expr -> show (eval expr), IHaskell.IPython.Types.Ok, "") - simpleConfig :: KernelConfig IO String String simpleConfig = KernelConfig { kernelLanguageInfo = languageConfig@@ -145,4 +144,5 @@ _ -> do putStrLn "Usage:" putStrLn "fun-calc-example install -- set up the kernelspec"- putStrLn "fun-calc-example kernel FILE -- run a kernel with FILE for communication with the frontend"+ putStrLn+ "fun-calc-example kernel FILE -- run a kernel with FILE for communication with the frontend"
ipython-kernel.cabal view
@@ -1,5 +1,5 @@ name: ipython-kernel-version: 0.8.0.0+version: 0.8.1.0 synopsis: A library for creating kernels for IPython frontends description: ipython-kernel is a library for communicating with frontends for the interactive IPython framework. It is used extensively in IHaskell, the interactive Haskell environment.
src/IHaskell/IPython/EasyKernel.hs view
@@ -11,17 +11,16 @@ -- -- = Kernel Specs ----- To run your kernel, you will need to install the kernelspec into the Jupyter namespace.--- If your kernel name is `kernel`, you will need to run the command:+-- To run your kernel, you will need to install the kernelspec into the Jupyter namespace. If your+-- kernel name is `kernel`, you will need to run the command: -- -- > kernel install -- -- This will inform Jupyter of the kernel so that it may be used. ----- == Further profile improvements--- Consult the IPython documentation along with the generated profile--- source code for further configuration of the frontend, including--- syntax highlighting, logos, help text, and so forth.+-- == Further profile improvements Consult the IPython documentation along with the generated+-- profile source code for further configuration of the frontend, including syntax highlighting,+-- logos, help text, and so forth. module IHaskell.IPython.EasyKernel (easyKernel, installKernelspec, KernelConfig(..)) where import Data.Aeson (decode, encode)@@ -99,7 +98,6 @@ installPrefixFlag = maybe ["--user"] (\prefix -> ["--prefix", prefix]) installPrefixMay cmd = concat [["kernelspec", "install"], installPrefixFlag, [kernelDir], replaceFlag] void $ rawSystem "ipython" cmd- where withTmpDir act = do tmp <- getTemporaryDirectory
src/IHaskell/IPython/Message/Parser.hs view
@@ -7,7 +7,7 @@ -- the low-level 0MQ interface. module IHaskell.IPython.Message.Parser (parseMessage) where -import Data.Aeson ((.:), decode, Result(..), Object)+import Data.Aeson ((.:), (.:?), (.!=), decode, Result(..), Object) import Control.Applicative ((<|>), (<$>), (<*>)) import Data.Aeson.Types (parse) import Data.ByteString@@ -159,9 +159,10 @@ commOpenParser :: LByteString -> Message commOpenParser = requestParser $ \obj -> do uuid <- obj .: "comm_id"- name <- obj .: "target_name"+ targetName <- obj .: "target_name"+ targetModule <- obj .:? "target_module" .!= "" value <- obj .: "data"- return $ CommOpen noHeader name uuid value+ return $ CommOpen noHeader targetName targetModule uuid value commDataParser :: LByteString -> Message commDataParser = requestParser $ \obj -> do
src/IHaskell/IPython/Message/Writer.hs view
@@ -97,7 +97,12 @@ object ["prompt" .= prompt] toJSON req@CommOpen{} =- object ["comm_id" .= commUuid req, "target_name" .= commTargetName req, "data" .= commData req]+ object+ [ "comm_id" .= commUuid req+ , "target_name" .= commTargetName req+ , "target_module" .= commTargetModule req+ , "data" .= commData req+ ] toJSON req@CommData{} = object ["comm_id" .= commUuid req, "data" .= commData req]
src/IHaskell/IPython/Types.hs view
@@ -375,6 +375,7 @@ CommOpen { header :: MessageHeader , commTargetName :: String+ , commTargetModule :: String , commUuid :: UUID , commData :: Value }@@ -438,6 +439,7 @@ replyType InspectRequestMessage = Just InspectReplyMessage replyType ShutdownRequestMessage = Just ShutdownReplyMessage replyType HistoryRequestMessage = Just HistoryReplyMessage+replyType CommOpenMessage = Just CommDataMessage replyType _ = Nothing -- | Data for display: a string with associated MIME type.