packages feed

ghcid 0.7.7 → 0.8

raw patch · 6 files changed

+35/−16 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Language.Haskell.Ghcid: [ghciErrorCmd] :: GhciError -> String
+ Language.Haskell.Ghcid: [ghciErrorLastStdErr] :: GhciError -> Maybe String
+ Language.Haskell.Ghcid: [ghciErrorMsg] :: GhciError -> String
- Language.Haskell.Ghcid: UnexpectedExit :: String -> String -> GhciError
+ Language.Haskell.Ghcid: UnexpectedExit :: String -> String -> Maybe String -> GhciError

Files

CHANGES.txt view
@@ -1,5 +1,8 @@ Changelog for ghcid (* = breaking change) +0.8, released 2019-12-04+*   Add an extra field to GhciError+    #288, include the last line of stderr in shutdown messages 0.7.7, released 2019-11-24     #287, only lint reloaded files 0.7.6, released 2019-10-13
README.md view
@@ -1,6 +1,6 @@ # ghcid [![Hackage version](https://img.shields.io/hackage/v/ghcid.svg?label=Hackage)](https://hackage.haskell.org/package/ghcid) [![Stackage version](https://www.stackage.org/package/ghcid/badge/nightly?label=Stackage)](https://www.stackage.org/package/ghcid) [![Linux build status](https://img.shields.io/travis/ndmitchell/ghcid/master.svg?label=Linux%20build)](https://travis-ci.org/ndmitchell/ghcid) [![Windows build status](https://img.shields.io/appveyor/ci/ndmitchell/ghcid/master.svg?label=Windows%20build)](https://ci.appveyor.com/project/ndmitchell/ghcid) -Either "GHCi as a daemon" or "GHC + a bit of an IDE". To a first approximation, it opens `ghci` and runs `:reload` whenever your source code changes, formatting the output to fit a fixed height console. Unlike other Haskell development tools, `ghcid` is intended to be _incredibly simple_. In particular, it doesn't integrate with any editors, doesn't depend on GHC the library and doesn't start web servers.+Either "GHCi as a daemon" or "GHC + a bit of an IDE". To a first approximation, it opens `ghci` and runs `:reload` whenever your source code changes, formatting the output to fit a fixed height console. Unlike other Haskell development tools, `ghcid` is intended to be _incredibly simple_. In particular, it doesn't integrate with any editors, doesn't provide access to the `ghci` it starts, doesn't depend on GHC the library and doesn't start web servers.  _Acknowledgements:_ This project incorporates significant work from [JPMoresmau](https://github.com/JPMoresmau), who is listed as a co-author. 
ghcid.cabal view
@@ -1,7 +1,7 @@ cabal-version:      >= 1.18 build-type:         Simple name:               ghcid-version:            0.7.7+version:            0.8 license:            BSD3 license-file:       LICENSE category:           Development
src/Ghcid.hs view
@@ -181,10 +181,19 @@     ,termWrap :: WordWrap     } +-- | On the 'UnexpectedExit' exception exit with a nice error message.+handleErrors :: IO () -> IO ()+handleErrors = handle $ \(UnexpectedExit cmd _ mmsg) -> do+    putStr $ "Command \"" ++ cmd ++ "\" exited unexpectedly"+    putStrLn $ case mmsg of+        Just msg -> " with error message: " ++ msg+        Nothing -> ""+    exitFailure+ -- | Like 'main', but run with a fake terminal for testing mainWithTerminal :: IO TermSize -> ([String] -> IO ()) -> IO () mainWithTerminal termSize termOutput =-    handle (\(UnexpectedExit cmd _) -> do putStrLn $ "Command \"" ++ cmd ++ "\" exited unexpectedly"; exitFailure) $+    handleErrors $         forever $ withWindowIcon $ withSession $ \session -> do             setVerbosity Normal -- undo any --verbose flags 
src/Language/Haskell/Ghcid.hs view
@@ -96,19 +96,20 @@                 syncReplay          -- Consume from a stream until EOF (return Nothing) or some predicate returns Just-        let consume :: Stream -> (String -> IO (Maybe a)) -> IO (Maybe a)+        let consume :: Stream -> (String -> IO (Maybe a)) -> IO (Either (Maybe String) a)             consume name finish = do                 let h = if name == Stdout then out else err-                fix $ \rec -> do+                flip fix Nothing $ \rec oldMsg -> do                     el <- tryBool isEOFError $ hGetLine h                     case el of-                        Left _ -> return Nothing+                        Left _ -> return $ Left oldMsg                         Right l -> do                             whenLoud $ outStrLn $ "%" ++ upper (show name) ++ ": " ++ l-                            res <- finish $ removePrefix l+                            let msg = removePrefix l+                            res <- finish msg                             case res of-                                Nothing -> rec-                                Just a -> return $ Just a+                                Nothing -> rec $ Just msg+                                Just a -> return $ Right a          let consume2 :: String -> (Stream -> String -> IO (Maybe a)) -> IO (a,a)             consume2 msg finish = do@@ -118,11 +119,13 @@                 res2 <- onceFork $ consume Stderr (finish Stderr)                 res1 <- res1                 res2 <- res2-                case liftM2 (,) res1 res2 of-                    Nothing -> case cmdspec process of-                        ShellCommand cmd -> throwIO $ UnexpectedExit cmd msg-                        RawCommand exe args -> throwIO $ UnexpectedExit (unwords (exe:args)) msg-                    Just v -> return v+                let raise msg err = throwIO $ case cmdspec process of+                        ShellCommand cmd -> UnexpectedExit cmd msg err+                        RawCommand exe args -> UnexpectedExit (unwords (exe:args)) msg err+                case (res1, res2) of+                    (Right v1, Right v2) -> return (v1, v2)+                    (_, Left err) -> raise msg err+                    (_, Right _) -> raise msg Nothing          -- held while interrupting, and briefly held when starting an exec         -- ensures exec values queue up behind an ongoing interrupt and no two interrupts run at once
src/Language/Haskell/Ghcid/Types.hs view
@@ -12,8 +12,12 @@ import Control.Exception.Base (Exception)  -- | GHCi shut down-data GhciError = UnexpectedExit String String-    deriving (Show,Eq,Ord,Typeable,Data)+data GhciError = UnexpectedExit+    {ghciErrorCmd :: String+    ,ghciErrorMsg :: String+    ,ghciErrorLastStdErr :: Maybe String+    }+    deriving (Show, Eq, Ord, Typeable, Data)  -- | Make GhciError an exception instance Exception GhciError