ipython-kernel 0.6.1.3 → 0.7.0.0
raw patch · 4 files changed
+39/−19 lines, 4 files
Files
- ipython-kernel.cabal +1/−1
- src/IHaskell/IPython/EasyKernel.hs +10/−12
- src/IHaskell/IPython/Message/Writer.hs +15/−3
- src/IHaskell/IPython/Types.hs +13/−3
ipython-kernel.cabal view
@@ -1,5 +1,5 @@ name: ipython-kernel-version: 0.6.1.3+version: 0.7.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.
src/IHaskell/IPython/EasyKernel.hs view
@@ -70,11 +70,8 @@ data KernelConfig m output result = KernelConfig { - -- | The name of the language. This field is used to calculate the name of the profile,- -- so it should contain characters that are reasonable to have in file names.- languageName :: String- -- | The version of the language- , languageVersion :: [Int]+ -- | Info on the language of the kernel.+ kernelLanguageInfo :: LanguageInfo -- | Determine the source of a profile to install using 'installProfile'. The source should be a -- tarball whose contents will be unpacked directly into the profile directory. For example, the -- file whose name is @ipython_config.py@ in the tar file for a language named @lang@ will end up in@@ -122,7 +119,7 @@ where profDir = do home <- liftIO getHomeDirectory- return $ home </> ".ipython" </> ("profile_" ++ languageName config)+ return $ home </> ".ipython" </> ("profile_" ++ languageName (kernelLanguageInfo config)) isInstalled = do prof <- profDir dirThere <- liftIO $ doesDirectoryExist prof@@ -185,8 +182,9 @@ return KernelInfoReply { header = replyHeader- , language = languageName config- , versionList = languageVersion config+ , languageInfo = kernelLanguageInfo config+ , implementation = "ipython-kernel.EasyKernel"+ , implementationVersion = "0.0" } replyTo config _ interface ShutdownRequest { restartPending = pending } replyHeader = do liftIO $ writeChan (shellReplyChannel interface) $ ShutdownReply replyHeader pending@@ -206,10 +204,10 @@ sendOutput x = send $ PublishDisplayData outputHeader- (languageName config)+ (languageName $ kernelLanguageInfo config) (displayOutput config x) in run config code clearOutput sendOutput- liftIO . send $ PublishDisplayData outputHeader (languageName config) (displayResult config res)+ liftIO . send $ PublishDisplayData outputHeader (languageName $ kernelLanguageInfo config) (displayResult config res) idleHeader <- dupHeader replyHeader StatusMessage@@ -230,8 +228,8 @@ -- TODO: FIX error "Completion: Unimplemented for IPython 3.0" -replyTo _ _ _ InspectRequest{} _ = do- error $ "Inspection: Unimplemented for IPython 3.0"+replyTo _ _ _ InspectRequest{} _ =+ error "Inspection: Unimplemented for IPython 3.0" replyTo _ _ _ msg _ = do liftIO $ putStrLn "Unknown message: "
src/IHaskell/IPython/Message/Writer.hs view
@@ -16,11 +16,23 @@ import IHaskell.IPython.Types +instance ToJSON LanguageInfo where+ toJSON info = object+ [ "name" .= languageName info+ , "version" .= languageVersion info+ , "file_extension" .= languageFileExtension info+ , "codemirror_mode" .= languageCodeMirrorMode info+ ]+ -- Convert message bodies into JSON. instance ToJSON Message where- toJSON KernelInfoReply { versionList = vers, language = language } =- object ["protocol_version" .= string "5.0" -- current protocol version, major and minor- , "language_version" .= vers, "language" .= language]+ toJSON rep@KernelInfoReply{} =+ object+ [ "protocol_version" .= string "5.0" -- current protocol version, major and minor+ , "implementation" .= implementation rep+ , "implementation_version" .= implementationVersion rep+ , "language_info" .= languageInfo rep+ ] toJSON ExecuteReply { status = status, executionCounter = counter, pagerOutput = pager } = object
src/IHaskell/IPython/Types.hs view
@@ -24,6 +24,7 @@ ExecuteReplyStatus(..), HistoryAccessType(..), HistoryReplyElement(..),+ LanguageInfo(..), replyType, showMessageType, @@ -246,6 +247,15 @@ _ -> fail ("Unknown message type: " ++ show s) parseJSON _ = fail "Must be a string." +data LanguageInfo =+ LanguageInfo+ { languageName :: String -- ^ The language name, e.g. "haskell"+ , languageVersion :: String -- ^ GHC 7.6.3+ , languageFileExtension :: String -- ^ .hs+ , languageCodeMirrorMode :: String -- ^ 'ihaskell'. can be 'null'+ }+ deriving (Show, Eq)+ -- | A message used to communicate with the IPython frontend. data Message = -- | A request from a frontend for information about the kernel.@@ -254,9 +264,9 @@ -- | A response to a KernelInfoRequest. KernelInfoReply { header :: MessageHeader- , versionList :: [Int] -- ^ The version of the language, e.g. [7, 6, 3] for GHC- -- 7.6.3- , language :: String -- ^ The language name, e.g. "haskell"+ , implementation :: String -- ^ e.g. IHaskell+ , implementationVersion :: String -- ^ The version of the implementation+ , languageInfo :: LanguageInfo } | -- | A request from a frontend to execute some code.