mirror of
https://github.com/IHaskell/IHaskell.git
synced 2025-04-16 19:36:06 +00:00
Fix incomplete pattern matches
Add `-Wincomplete-patterns` to the `ghc-options` field of the cabal file and fix all warnings.
This commit is contained in:
parent
dcd7d33043
commit
ca56a29d78
@ -49,6 +49,7 @@ data-files:
|
||||
library
|
||||
hs-source-dirs: src
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wincomplete-patterns
|
||||
build-depends:
|
||||
aeson >=1.0,
|
||||
base >=4.9,
|
||||
@ -124,6 +125,7 @@ executable ihaskell
|
||||
|
||||
-- Other library packages from which modules are imported.
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wincomplete-patterns
|
||||
build-depends:
|
||||
ihaskell -any,
|
||||
base >=4.9 && < 4.13,
|
||||
@ -150,6 +152,7 @@ Test-Suite hspec
|
||||
IHaskell.Test.Util
|
||||
IHaskell.Test.Parser
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wincomplete-patterns
|
||||
build-depends:
|
||||
base,
|
||||
ihaskell,
|
||||
|
@ -469,6 +469,9 @@ handleComm send kernelState req replyHeader = do
|
||||
pgrOut <- liftIO $ readMVar pagerOutput
|
||||
liftIO $ publish $ FinalResult disp (if toUsePager then pgrOut else []) []
|
||||
return kernelState { openComms = Map.delete uuid widgets }
|
||||
x ->
|
||||
-- Only sensible thing to do.
|
||||
return kernelState
|
||||
|
||||
-- Notify the frontend that the kernel is idle once again
|
||||
idleHeader <- liftIO $ dupHeader replyHeader StatusMessage
|
||||
|
@ -234,6 +234,7 @@ initializeImports = do
|
||||
|
||||
-- Generate import statements all Display modules.
|
||||
let capitalize :: String -> String
|
||||
capitalize [] = []
|
||||
capitalize (first:rest) = Char.toUpper first : rest
|
||||
|
||||
importFmt = "import IHaskell.Display.%s"
|
||||
@ -655,8 +656,9 @@ evalCommand _ (Directive LoadFile names) state = wrapExecution state $ do
|
||||
doLoadModule filename modName
|
||||
return (ManyDisplay displays)
|
||||
|
||||
evalCommand publish (Directive ShellCmd ('!':cmd)) state = wrapExecution state $
|
||||
case words cmd of
|
||||
evalCommand publish (Directive ShellCmd cmd) state = wrapExecution state $
|
||||
-- Assume the first character of 'cmd' is '!'.
|
||||
case words $ drop 1 cmd of
|
||||
"cd":dirs -> do
|
||||
-- Get home so we can replace '~` with it.
|
||||
homeEither <- liftIO (try $ getEnv "HOME" :: IO (Either SomeException String))
|
||||
|
@ -110,9 +110,8 @@ search string = do
|
||||
document :: String -> IO [HoogleResult]
|
||||
document string = do
|
||||
matchingResults <- filter matches <$> search string
|
||||
let results = map toDocResult matchingResults
|
||||
return $
|
||||
case results of
|
||||
case mapMaybe toDocResult matchingResults of
|
||||
[] -> [NoResult "no matching identifiers found."]
|
||||
res -> res
|
||||
|
||||
@ -123,7 +122,9 @@ document string = do
|
||||
_ -> False
|
||||
matches _ = False
|
||||
|
||||
toDocResult (SearchResult resp) = DocResult resp
|
||||
toDocResult (SearchResult resp) = Just $ DocResult resp
|
||||
toDocResult (DocResult _) = Nothing
|
||||
toDocResult (NoResult _) = Nothing
|
||||
|
||||
-- | Render a Hoogle search result into an output format.
|
||||
render :: OutputFormat -> HoogleResult -> String
|
||||
@ -233,7 +234,10 @@ renderDocs doc =
|
||||
bothAreCode s1 s2 =
|
||||
isPrefixOf ">" (strip s1) &&
|
||||
isPrefixOf ">" (strip s2)
|
||||
isCode (s:_) = isPrefixOf ">" $ strip s
|
||||
isCode xs =
|
||||
case xs of
|
||||
[] -> False
|
||||
(s:_) -> isPrefixOf ">" $ strip s
|
||||
makeBlock lines =
|
||||
if isCode lines
|
||||
then div' "hoogle-code" $ unlines $ nonull lines
|
||||
|
@ -115,6 +115,9 @@ createModule mode (Located line block) =
|
||||
Import impt -> impt
|
||||
Module mod -> mod
|
||||
|
||||
-- TODO: Properly handle the other constructors
|
||||
_ -> []
|
||||
|
||||
unparse :: ParseResult a -> Maybe a
|
||||
unparse (ParseOk a) = Just a
|
||||
unparse _ = Nothing
|
||||
|
@ -239,11 +239,11 @@ joinFunctions blocks =
|
||||
parsePragma :: String -- ^ Pragma string.
|
||||
-> Int -- ^ Line number at which the directive appears.
|
||||
-> CodeBlock -- ^ Pragma code block or a parse error.
|
||||
parsePragma ('{':'-':'#':pragma) line =
|
||||
parsePragma pragma line =
|
||||
let commaToSpace :: Char -> Char
|
||||
commaToSpace ',' = ' '
|
||||
commaToSpace x = x
|
||||
pragmas = words $ takeWhile (/= '#') $ map commaToSpace pragma
|
||||
pragmas = words $ takeWhile (/= '#') $ map commaToSpace $ drop 3 pragma
|
||||
in case pragmas of
|
||||
--empty string pragmas are unsupported
|
||||
[] -> Pragma (PragmaUnsupported "") []
|
||||
|
@ -246,6 +246,7 @@ doc sdoc = do
|
||||
string_txt (Pretty.Str s1) s2 = s1 ++ s2
|
||||
string_txt (Pretty.PStr s1) s2 = unpackFS s1 ++ s2
|
||||
string_txt (Pretty.LStr s1 _) s2 = unpackLitString s1 ++ s2
|
||||
string_txt (Pretty.ZStr s1) s2 = CBS.unpack (fastZStringToByteString s1) ++ s2
|
||||
#endif
|
||||
|
||||
-- | Initialize the GHC API. Run this as the first thing in the `runGhc`. This initializes some dyn
|
||||
|
@ -94,6 +94,7 @@ help mode = showText (Wrap 100) $ helpText [] HelpFormatAll $ chooseMode mode
|
||||
chooseMode InstallKernelSpec = installKernelSpec
|
||||
chooseMode (Kernel _) = kernel
|
||||
chooseMode ConvertLhs = convert
|
||||
chooseMode (ShowDefault _) = error "IHaskell.Flags.help: Should never happen."
|
||||
|
||||
ghcLibFlag :: Flag Args
|
||||
ghcLibFlag = flagReq ["ghclib", "l"] (store GhcLibDir) "<path>" "Library directory for GHC."
|
||||
|
@ -27,7 +27,7 @@ eval string = do
|
||||
let publish evalResult =
|
||||
case evalResult of
|
||||
IntermediateResult{} -> return ()
|
||||
FinalResult outs page [] -> do
|
||||
FinalResult outs page _ -> do
|
||||
modifyIORef outputAccum (outs :)
|
||||
modifyIORef pagerAccum (page :)
|
||||
noWidgetHandling s _ = return s
|
||||
|
Loading…
x
Reference in New Issue
Block a user