Commit 957de8ff authored by Andrew Gibiansky's avatar Andrew Gibiansky

upgraded everything to aeson >= 0.7, which required fairly major changes

parent 95e15aff
......@@ -60,8 +60,8 @@ library
build-depends: base ==4.6.*,
here,
classy-prelude >=0.7,
aeson,
aeson-pretty,
aeson >= 0.7,
aeson-pretty >= 0.7,
chunked-data >=0.1,
ihaskell >= 0.3
......
......@@ -54,7 +54,7 @@ library
default-language: Haskell2010
build-depends:
base ==4.6.*,
aeson >=0.6.1,
aeson >=0.7,
base64-bytestring >=1.0,
bytestring >=0.10,
cereal ==0.3.*,
......@@ -134,7 +134,7 @@ executable IHaskell
default-language: Haskell2010
build-depends:
base ==4.6.*,
aeson >=0.6,
aeson >=0.7,
base64-bytestring >=1.0,
bytestring >=0.10,
cereal ==0.3.*,
......@@ -177,7 +177,7 @@ Test-Suite hspec
default-language: Haskell2010
build-depends:
base ==4.6.*,
aeson >=0.6,
aeson >=0.7,
base64-bytestring >=1.0,
bytestring >=0.10,
cereal ==0.3.*,
......
......@@ -27,7 +27,7 @@ library
hs-source-dirs: src
default-language: Haskell2010
build-depends: base >=4.6 && <4.7,
aeson >=0.6 && <0.7,
aeson >=0.7,
bytestring >=0.10,
cereal ==0.3.*,
containers >=0.5,
......
......@@ -10,8 +10,10 @@ import Data.Aeson ((.:), decode, Result(..), Object)
import Control.Applicative ((<|>))
import Data.Aeson.Types (parse)
import Data.ByteString
import qualified Data.ByteString.Lazy as Lazy
import Data.Map (Map)
import qualified Data.ByteString.Lazy as Lazy
import qualified Data.ByteString.Char8 as Char
import qualified Data.Map as Map
import IPython.Types
......@@ -43,10 +45,10 @@ parseHeader :: [ByteString] -- ^ The list of identifiers.
parseHeader idents headerData parentHeader metadata = MessageHeader {
identifiers = idents,
parentHeader = parentResult,
metadata = metadataMap,
metadata = Map.map Char.pack $ Map.mapKeys Char.pack metadataMap,
messageId = messageUUID,
sessionId = sessionUUID,
username = username,
username = Char.pack username,
msgType = messageType
} where
-- Decode the header data and the parent header data into JSON objects.
......@@ -65,7 +67,7 @@ parseHeader idents headerData parentHeader metadata = MessageHeader {
return (messType, username, message, session)
-- Get metadata as a simple map.
Just metadataMap = decode $ Lazy.fromStrict metadata :: Maybe (Map ByteString ByteString)
Just metadataMap = decode $ Lazy.fromStrict metadata :: Maybe (Map String String)
noHeader :: MessageHeader
noHeader = error "No header created"
......@@ -106,7 +108,7 @@ executeRequestParser content =
Success (code, silent, storeHistory, allowStdin) = parse parser decoded in
ExecuteRequest {
header = noHeader,
getCode = code,
getCode = Char.pack code,
getSilent = silent,
getAllowStdin = allowStdin,
getStoreHistory = storeHistory,
......@@ -121,7 +123,7 @@ completeRequestParser content = parsed
code <- obj .: "block" <|> return ""
codeLine <- obj .: "line"
pos <- obj .: "cursor_pos"
return $ CompleteRequest noHeader code codeLine pos
return $ CompleteRequest noHeader (Char.pack code) (Char.pack codeLine) pos
Just decoded = decode content
......
......@@ -11,6 +11,8 @@ import Data.Map (Map)
import Data.Text (Text, pack)
import Data.Monoid (mempty)
import qualified Data.ByteString.Char8 as Char
import IPython.Types
......@@ -101,7 +103,7 @@ instance ToJSON StreamType where
-- | Convert a MIME type and value into a JSON dictionary pair.
displayDataToJson :: DisplayData -> (Text, Value)
displayDataToJson (DisplayData mimeType dataStr) = pack (show mimeType) .= dataStr
displayDataToJson (DisplayData mimeType dataStr) = pack (show mimeType) .= Char.unpack dataStr
----- Constants -----
......
......@@ -73,7 +73,7 @@ instance FromJSON Profile where
<*> v .: "hb_port"
<*> v .: "shell_port"
<*> v .: "iopub_port"
<*> v .: "key"
<*> (Char.pack <$> v .: "key")
parseJSON _ = fail "Expecting JSON object."
instance ToJSON Profile where
......@@ -85,7 +85,7 @@ instance ToJSON Profile where
"hb_port" .= hbPort profile,
"shell_port" .= shellPort profile,
"iopub_port" .= iopubPort profile,
"key" .= key profile
"key" .= Char.unpack (key profile)
]
instance FromJSON Transport where
......@@ -119,7 +119,7 @@ instance ToJSON MessageHeader where
toJSON header = object [
"msg_id" .= messageId header,
"session" .= sessionId header,
"username" .= username header,
"username" .= Char.unpack (username header),
"msg_type" .= showMessageType (msgType header)
]
......@@ -269,15 +269,15 @@ data Message
| CompleteReply {
header :: MessageHeader,
completionMatches :: [ByteString],
completionMatchedText :: ByteString,
completionText :: ByteString,
completionMatches :: [String],
completionMatchedText :: String,
completionText :: String,
completionStatus :: Bool
}
| ObjectInfoRequest {
header :: MessageHeader,
objectName :: ByteString, -- ^ Name of object being searched for.
objectName :: String, -- ^ Name of object being searched for.
detailLevel :: Int -- ^ Level of detail desired (defaults to 0).
-- 0 is equivalent to foo?, 1 is equivalent
-- to foo??.
......@@ -285,10 +285,10 @@ data Message
| ObjectInfoReply {
header :: MessageHeader,
objectName :: ByteString, -- ^ Name of object which was searched for.
objectFound :: Bool, -- ^ Whether the object was found.
objectTypeString :: ByteString, -- ^ Object type.
objectDocString :: ByteString
objectName :: String, -- ^ Name of object which was searched for.
objectFound :: Bool, -- ^ Whether the object was found.
objectTypeString :: String, -- ^ Object type.
objectDocString :: String
}
| ShutdownRequest {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -7,6 +7,8 @@ import Text.Parsec
import Text.Parsec.String
import Control.Applicative hiding ((<|>), many)
import Data.String.Utils (startswith)
import Shelly
data BrokenPackage = BrokenPackage {
......@@ -22,7 +24,12 @@ getBrokenPackages = shellyNoDir $ do
silently $ errExit False $ run "ghc-pkg" ["check"]
checkOut <- lastStderr
return $ case parse (many check) "ghc-pkg output" $ unpack checkOut of
-- Get rid of extraneous things
let rightStart str = startswith "There are problems" str ||
startswith " dependency" str
ghcPkgOutput = unlines . filter rightStart . lines $ unpack checkOut
return $ case parse (many check) "ghc-pkg output" ghcPkgOutput of
Left err -> []
Right pkgs -> map show pkgs
......
......@@ -103,6 +103,7 @@ instance MonadIO.MonadIO Interpreter where
globalImports :: [String]
globalImports =
[ "import IHaskell.Display()"
, "import qualified IHaskell.Display"
, "import qualified IPython.Stdin"
, "import qualified System.Posix.IO as IHaskellIO"
, "import qualified System.IO as IHaskellSysIO"
......@@ -193,6 +194,8 @@ initializeImports = do
displayImports = map toImportStmt displayPackages
liftIO $ print displayImports
-- Import implicit prelude.
importDecl <- parseImportDecl "import Prelude"
let implicitPrelude = importDecl { ideclImplicit = True }
......
......@@ -10,7 +10,6 @@ module IHaskell.Eval.Parser (
layoutChunks,
parseDirective,
getModuleName,
unloc,
Located(..),
) where
......
......@@ -322,20 +322,21 @@ replyTo interface req@ExecuteRequest{ getCode = code } replyHeader state = do
replyTo _ req@CompleteRequest{} replyHeader state = do
(matchedText, completions) <- complete (Chars.unpack $ getCodeLine req) (getCursorPos req)
let line = Chars.unpack $ getCodeLine req
(matchedText, completions) <- complete line (getCursorPos req)
let reply = CompleteReply replyHeader (map Chars.pack completions) (Chars.pack matchedText) (getCodeLine req) True
let reply = CompleteReply replyHeader completions matchedText line True
return (state, reply)
-- | Reply to the object_info_request message. Given an object name, return
-- | the associated type calculated by GHC.
replyTo _ ObjectInfoRequest{objectName=oname} replyHeader state = do
docs <- info $ Chars.unpack oname
replyTo _ ObjectInfoRequest{objectName = oname} replyHeader state = do
docs <- info oname
let reply = ObjectInfoReply {
header = replyHeader,
objectName = oname,
objectFound = strip docs /= "",
objectTypeString = Chars.pack docs,
objectDocString = Chars.pack docs
objectTypeString = docs,
objectDocString = docs
}
return (state, reply)
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