ihaskell 0.9.0.2 → 0.9.0.3
raw patch · 10 files changed
+76/−14 lines, 10 filesdep ~basedep ~ghc-boot
Dependency ranges changed: base, ghc-boot
Files
- ihaskell.cabal +3/−3
- main/Main.hs +4/−0
- src/IHaskell/Convert/IpynbToLhs.hs +0/−1
- src/IHaskell/Eval/Hoogle.hs +8/−0
- src/IHaskell/Eval/Parser.hs +6/−2
- src/IHaskell/Eval/Util.hs +38/−2
- src/IHaskell/Flags.hs +1/−1
- src/IHaskell/Types.hs +8/−4
- src/IHaskellPrelude.hs +2/−1
- src/tests/IHaskell/Test/Eval.hs +6/−0
ihaskell.cabal view
@@ -7,7 +7,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.9.0.2+version: 0.9.0.3 -- A short (one-line) description of the package. synopsis: A Haskell backend kernel for the IPython project.@@ -92,7 +92,7 @@ build-depends: bin-package-db if impl(ghc >= 8.0)- build-depends: ghc-boot >=8.0 && <8.3+ build-depends: ghc-boot >=8.0 && <8.5 exposed-modules: IHaskell.Display IHaskell.Convert@@ -134,7 +134,7 @@ default-language: Haskell2010 build-depends: ihaskell -any,- base >=4.6 && < 4.11,+ base >=4.6 && < 4.12, text >=0.11, transformers -any, ghc >=7.6 || < 7.11,
main/Main.hs view
@@ -52,7 +52,11 @@ import Paths_ihaskell(version) -- GHC API imports.+#if MIN_VERSION_ghc(8,4,0)+import GHC hiding (extensions, language, convert)+#else import GHC hiding (extensions, language)+#endif -- | Compute the GHC API version number using the dist/build/autogen/cabal_macros.h ghcVersionInts :: [Int]
src/IHaskell/Convert/IpynbToLhs.hs view
@@ -11,7 +11,6 @@ import qualified Data.ByteString.Char8 as CBS import Data.Aeson (decode, Object, Value(Array, Object, String))-import Data.Monoid ((<>), Monoid(mempty)) import Data.Vector (Vector) import Data.HashMap.Strict (lookup)
src/IHaskell/Eval/Hoogle.hs view
@@ -179,6 +179,12 @@ span "hoogle-class" (link loc $ extractData string) ++ packageSub package + | "newtype" `isPrefixOf` string =+ let package = extractPackageName loc+ in nwt ++ " " +++ span "hoogle-class" (link loc $ extractNewtype string) +++ packageSub package+ | otherwise = let [name, args] = split "::" string package = extractPackageName loc@@ -194,10 +200,12 @@ extractModule = strip . replace "module" "" extractClass = strip . replace "class" "" extractData = strip . replace "data" ""+ extractNewtype = strip . replace "newtype" "" pkg = span "hoogle-head" "package" mod = span "hoogle-head" "module" cls = span "hoogle-head" "class" dat = span "hoogle-head" "data"+ nwt = span "hoogle-head" "newtype" unicodeReplace :: String -> String unicodeReplace =
src/IHaskell/Eval/Parser.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE NoImplicitPrelude, OverloadedStrings #-}+{-# LANGUAGE CPP, NoImplicitPrelude, OverloadedStrings #-} module IHaskell.Eval.Parser ( parseString,@@ -26,7 +26,11 @@ import Prelude (head, tail) import Control.Monad (msum) +#if MIN_VERSION_ghc(8,4,0)+import GHC hiding (Located, Parsed)+#else import GHC hiding (Located)+#endif import Language.Haskell.GHC.Parser import IHaskell.Eval.Util@@ -284,7 +288,7 @@ -- | Parse a module and return the name declared in the 'module X where' line. That line is -- required, and if it does not exist, this will error. Names with periods in them are returned--- piece y piece.+-- piece by piece. getModuleName :: GhcMonad m => String -> m [String] getModuleName moduleSrc = do flags <- getSessionDynFlags
src/IHaskell/Eval/Util.hs view
@@ -59,6 +59,10 @@ import StringUtils (replace) +#if MIN_VERSION_ghc(8,4,0)+import CmdLineParser (warnMsg)+#endif+ #if MIN_VERSION_ghc(8,0,1) import GHC.LanguageExtensions @@ -128,7 +132,11 @@ is_on = test f dflags quiet = not show_all && test f default_dflags == is_on +#if MIN_VERSION_ghc(8,4,0)+ default_dflags = defaultDynFlags (settings dflags) (llvmTargets dflags)+#else default_dflags = defaultDynFlags (settings dflags)+#endif fstr, fnostr :: String -> O.SDoc fstr str = O.text "-f" O.<> O.text str@@ -176,7 +184,11 @@ quiet = not show_all && test f default_dflags == is_on default_dflags =+#if MIN_VERSION_ghc(8,4,0)+ defaultDynFlags (settings dflags) (llvmTargets dflags) `lang_set`+#else defaultDynFlags (settings dflags) `lang_set`+#endif case language dflags of Nothing -> Just Haskell2010 other -> other@@ -211,7 +223,11 @@ -- Create the parse errors. let noParseErrs = map (("Could not parse: " ++) . unLoc) unrecognized+#if MIN_VERSION_ghc(8,4,0)+ allWarns = map (unLoc . warnMsg) warnings +++#else allWarns = map unLoc warnings +++#endif ["-package not supported yet" | packageFlags flags /= packageFlags flags'] warnErrs = map ("Warning: " ++) allWarns return $ noParseErrs ++ warnErrs@@ -311,18 +327,30 @@ where -- Check whether an import is the same as another import (same module).+#if MIN_VERSION_ghc(8,4,0)+ importOf :: ImportDecl GhcPs -> InteractiveImport -> Bool+#else importOf :: ImportDecl RdrName -> InteractiveImport -> Bool+#endif importOf _ (IIModule _) = False importOf imp (IIDecl decl) = ((==) `on` (unLoc . ideclName)) decl imp && not (ideclQualified decl) -- Check whether an import is an *implicit* import of something.+#if MIN_VERSION_ghc(8,4,0)+ implicitImportOf :: ImportDecl GhcPs -> InteractiveImport -> Bool+#else implicitImportOf :: ImportDecl RdrName -> InteractiveImport -> Bool+#endif implicitImportOf _ (IIModule _) = False implicitImportOf imp (IIDecl decl) = ideclImplicit decl && imp `importOf` IIDecl decl -- Check whether an import is hidden.+#if MIN_VERSION_ghc(8,4,0)+ isHiddenImport :: ImportDecl GhcPs -> Bool+#else isHiddenImport :: ImportDecl RdrName -> Bool+#endif isHiddenImport imp = case ideclHiding imp of Just (True, _) -> True@@ -420,13 +448,21 @@ getInfo' = getInfo #endif -#if MIN_VERSION_ghc(7,8,0)+#if MIN_VERSION_ghc(8,4,0)+ getType (theType, _, _, _, _) = theType+#elif MIN_VERSION_ghc(7,8,0) getType (theType, _, _, _) = theType #else getType (theType, _, _) = theType #endif -#if MIN_VERSION_ghc(7,8,0)+#if MIN_VERSION_ghc(8,4,0)+ printInfo (thing, fixity, classInstances, famInstances, _) =+ pprTyThingInContextLoc thing O.$$+ showFixity thing fixity O.$$+ O.vcat (map GHC.pprInstance classInstances) O.$$+ O.vcat (map GHC.pprFamInst famInstances)+#elif MIN_VERSION_ghc(7,8,0) printInfo (thing, fixity, classInstances, famInstances) = pprTyThingInContextLoc thing O.$$ showFixity thing fixity O.$$
src/IHaskell/Flags.hs view
@@ -12,7 +12,7 @@ help, ) where -import IHaskellPrelude+import IHaskellPrelude hiding (Arg(..)) import qualified Data.Text as T import qualified Data.Text.Lazy as LT import qualified Data.ByteString as BS
src/IHaskell/Types.hs view
@@ -49,6 +49,7 @@ import Data.Aeson.Types (emptyObject) import qualified Data.ByteString.Char8 as Char import Data.Function (on)+import Data.Semigroup import Data.Serialize import GHC.Generics @@ -127,12 +128,15 @@ instance Serialize Display +instance Semigroup Display where+ ManyDisplay a <> ManyDisplay b = ManyDisplay (a ++ b)+ ManyDisplay a <> b = ManyDisplay (a ++ [b])+ a <> ManyDisplay b = ManyDisplay (a : b)+ a <> b = ManyDisplay [a, b]+ instance Monoid Display where mempty = Display []- ManyDisplay a `mappend` ManyDisplay b = ManyDisplay (a ++ b)- ManyDisplay a `mappend` b = ManyDisplay (a ++ [b])- a `mappend` ManyDisplay b = ManyDisplay (a : b)- a `mappend` b = ManyDisplay [a, b]+ mappend = (<>) -- | All state stored in the kernel between executions. data KernelState =
src/IHaskellPrelude.hs view
@@ -67,7 +67,8 @@ import Prelude -import Data.Monoid as X+import Data.Semigroup as X+import Data.Monoid as X hiding ((<>), First(..), Last(..)) import Data.Tuple as X import Control.Monad as X import Data.Maybe as X
src/tests/IHaskell/Test/Eval.hs view
@@ -102,6 +102,12 @@ testEval :: Spec testEval = describe "Code Evaluation" $ do+ it "gets rid of the test failure with Nix" $+ let+ throwAway string _ =+ evaluationComparing (const $ shouldBe True True) string+ in throwAway "True" ["True"]+ it "evaluates expressions" $ do "3" `becomes` ["3"] "3+5" `becomes` ["8"]