ipython-kernel 0.8.4.0 → 0.9.0.0
raw patch · 8 files changed
+98/−41 lines, 8 filesdep ~SHAdep ~aesondep ~basesetup-changed
Dependency ranges changed: SHA, aeson, base, bytestring, cereal, containers, directory, filepath, mtl, parsec, process, temporary, text, transformers, unordered-containers, uuid, zeromq4-haskell
Files
- Setup.hs +3/−0
- examples/Calc.hs +4/−0
- examples/Simple.hs +4/−0
- ipython-kernel.cabal +29/−29
- src/IHaskell/IPython/EasyKernel.hs +19/−2
- src/IHaskell/IPython/Message/Parser.hs +6/−0
- src/IHaskell/IPython/Message/Writer.hs +15/−9
- src/IHaskell/IPython/Types.hs +18/−1
+ Setup.hs view
@@ -0,0 +1,3 @@+import Distribution.Simple++main = defaultMain
examples/Calc.hs view
@@ -233,6 +233,10 @@ , inspectInfo = langInfo , run = parseAndRun , debug = False+ , kernelBanner = "Expanded Hutton's Razor"+ , kernelProtocolVersion = "5.0"+ , kernelImplName = "expanded_huttons_razor"+ , kernelImplVersion = "0.0" } where displayRes (Left err) =
examples/Simple.hs view
@@ -130,6 +130,10 @@ , inspectInfo = languageInspect , run = languageRun , debug = False+ , kernelBanner = "Simple Arithmetic Expressions"+ , kernelProtocolVersion = "5.0"+ , kernelImplName = "funcalc"+ , kernelImplVersion = "0.0" } main :: IO ()
ipython-kernel.cabal view
@@ -1,5 +1,5 @@ name: ipython-kernel-version: 0.8.4.0+version: 0.9.0.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.@@ -34,34 +34,34 @@ other-extensions: OverloadedStrings hs-source-dirs: src default-language: Haskell2010- build-depends: base >=4.6 && < 4.9,- aeson >=0.6 && < 0.12,- bytestring >=0.10,- cereal >=0.3,- containers >=0.5,- directory >=1.1,- temporary >=1.2,- filepath >=1.2,- process >=1.1,- mtl >=2.1,- text >=0.11,- transformers >=0.3,- unordered-containers >= 0.2.5,- uuid >=1.3,- zeromq4-haskell >=0.1,- SHA >=1.6+ build-depends: base >=4.6 && <5,+ aeson ,+ bytestring ,+ cereal ,+ containers ,+ directory ,+ temporary ,+ filepath ,+ process ,+ mtl ,+ text ,+ transformers ,+ unordered-containers,+ uuid ,+ zeromq4-haskell ,+ SHA -- Example program executable simple-calc-example hs-source-dirs: examples main-is: Calc.hs build-depends: ipython-kernel,- base >=4.6 && <4.9,- filepath >=1.2,- mtl >=2.1,- parsec >=3.1,- text >=0.11,- transformers >=0.3+ base ,+ filepath ,+ mtl ,+ parsec ,+ text ,+ transformers if !flag(examples) buildable: False@@ -70,12 +70,12 @@ hs-source-dirs: examples main-is: Simple.hs build-depends: ipython-kernel,- base >=4.6 && <4.9,- filepath >=1.2,- mtl >=2.1,- parsec >=3.1,- text >=0.11,- transformers >=0.3+ base ,+ filepath ,+ mtl ,+ parsec ,+ text ,+ transformers if !flag(examples) buildable: False
src/IHaskell/IPython/EasyKernel.hs view
@@ -77,6 +77,14 @@ -- should be handled by defining an appropriate error constructor in your result type. , run :: T.Text -> IO () -> (output -> IO ()) -> m (result, ExecuteReplyStatus, String) , debug :: Bool -- ^ Whether to print extra debugging information to+ -- | A One-line description of the kernel+ , kernelBanner :: String+ -- | The version of the messaging specification used by the kernel+ , kernelProtocolVersion :: String+ -- | Name of the kernel implementation+ , kernelImplName :: String+ -- | Version of the kernel implementation+ , kernelImplVersion :: String } -- Install the kernelspec, using the `writeKernelspec` field of the kernel configuration.@@ -160,9 +168,18 @@ KernelInfoReply { header = replyHeader , languageInfo = kernelLanguageInfo config- , implementation = "ipython-kernel.EasyKernel"- , implementationVersion = "0.0"+ , implementation = kernelImplName config+ , implementationVersion = kernelImplVersion config+ , banner = kernelBanner config+ , protocolVersion = kernelProtocolVersion config }++replyTo config _ _ CommInfoRequest{} replyHeader =+ return+ CommInfoReply+ { header = replyHeader+ , commInfo = Map.empty }+ replyTo config _ interface ShutdownRequest { restartPending = pending } replyHeader = do liftIO $ writeChan (shellReplyChannel interface) $ ShutdownReply replyHeader pending liftIO exitSuccess
src/IHaskell/IPython/Message/Parser.hs view
@@ -90,6 +90,7 @@ parser InputReplyMessage = inputReplyParser parser CommOpenMessage = commOpenParser parser CommDataMessage = commDataParser+parser CommInfoRequestMessage = commInfoRequestParser parser CommCloseMessage = commCloseParser parser HistoryRequestMessage = historyRequestParser parser StatusMessage = statusMessageParser@@ -103,6 +104,11 @@ -- body. kernelInfoRequestParser :: LByteString -> Message kernelInfoRequestParser _ = KernelInfoRequest { header = noHeader }++-- | Parse a comm info request. A comm info request has no auxiliary information, so ignore the+-- body.+commInfoRequestParser :: LByteString -> Message+commInfoRequestParser _ = CommInfoRequest { header = noHeader } -- | Parse an execute_input response. Fields used are: executeInputParser :: LByteString -> Message
src/IHaskell/IPython/Message/Writer.hs view
@@ -11,6 +11,7 @@ import Data.Map (Map) import Data.Monoid (mempty) import Data.Text (Text, pack)+import qualified Data.Map as Map import IHaskell.IPython.Types instance ToJSON LanguageInfo where@@ -32,12 +33,18 @@ , "language_info" .= languageInfo rep ] + toJSON CommInfoReply+ { header = header+ , commInfo = commInfo+ } =+ object+ [ "comms" .= Map.map (\comm -> object ["target_name" .= comm]) commInfo ]+ toJSON ExecuteRequest { getCode = code , getSilent = silent , getStoreHistory = storeHistory , getAllowStdin = allowStdin- , getUserVariables = userVariables , getUserExpressions = userExpressions } = object@@ -45,7 +52,6 @@ , "silent" .= silent , "store_history" .= storeHistory , "allow_stdin" .= allowStdin- , "user_variables" .= userVariables , "user_expressions" .= userExpressions ] @@ -56,16 +62,16 @@ , "payload" .= if null pager then []- else map mkObj pager- , "user_variables" .= emptyMap+ else mkPayload pager , "user_expressions" .= emptyMap ] where- mkObj o = object- [ "source" .= string "page"- , "line" .= Number 0- , "data" .= object [displayDataToJson o]- ]+ mkPayload o = [ object+ [ "source" .= string "page"+ , "start" .= Number 0+ , "data" .= object (map displayDataToJson o)+ ]+ ] toJSON PublishStatus { executionState = executionState } = object ["execution_state" .= executionState] toJSON PublishStream { streamType = streamType, streamContent = content } =
src/IHaskell/IPython/Types.hs view
@@ -193,6 +193,8 @@ | InputReplyMessage | CommOpenMessage | CommDataMessage+ | CommInfoRequestMessage+ | CommInfoReplyMessage | CommCloseMessage | HistoryRequestMessage | HistoryReplyMessage@@ -224,6 +226,8 @@ showMessageType InputReplyMessage = "input_reply" showMessageType CommOpenMessage = "comm_open" showMessageType CommDataMessage = "comm_msg"+showMessageType CommInfoRequestMessage = "comm_info_request"+showMessageType CommInfoReplyMessage = "comm_info_reply" showMessageType CommCloseMessage = "comm_close" showMessageType HistoryRequestMessage = "history_request" showMessageType HistoryReplyMessage = "history_reply"@@ -256,6 +260,8 @@ "input_reply" -> return InputReplyMessage "comm_open" -> return CommOpenMessage "comm_msg" -> return CommDataMessage+ "comm_info_request" -> return CommInfoRequestMessage+ "comm_info_reply" -> return CommInfoReplyMessage "comm_close" -> return CommCloseMessage "history_request" -> return HistoryRequestMessage "history_reply" -> return HistoryReplyMessage@@ -288,12 +294,22 @@ KernelInfoReply { header :: MessageHeader , protocolVersion :: String -- ^ current protocol version, major and minor- , banner :: String -- ^ Kernel information description e.g. (IHaskell 0.8.3.0 GHC 7.10.2)+ , banner :: String -- ^ Kernel information description e.g. (IHaskell 0.8.3.0 GHC+ -- 7.10.2) , implementation :: String -- ^ e.g. IHaskell , implementationVersion :: String -- ^ The version of the implementation , languageInfo :: LanguageInfo } |+ -- | A request from a frontend for information about the comms.+ CommInfoRequest { header :: MessageHeader }+ |+ -- | A response to a CommInfoRequest.+ CommInfoReply+ { header :: MessageHeader+ , commInfo :: Map String String -- ^ A dictionary of the comms, indexed by uuids.+ }+ | -- | A request from a frontend to execute some code. ExecuteInput { header :: MessageHeader@@ -518,6 +534,7 @@ replyType ShutdownRequestMessage = Just ShutdownReplyMessage replyType HistoryRequestMessage = Just HistoryReplyMessage replyType CommOpenMessage = Just CommDataMessage+replyType CommInfoRequestMessage = Just CommInfoReplyMessage replyType _ = Nothing -- | Data for display: a string with associated MIME type.