Skip to content
Browse files

eliminated compiler warnings by updating cabal file, underscoring unu…

…sed names, commenting out unused functions, and adding wild card patterns to silence non-exhaustive pattern match warnings.
  • Loading branch information...
1 parent 07529be commit 0885497b11006355f929663941a6c6d06d5822c6 Chris Moline committed Mar 23, 2012
Showing with 27 additions and 23 deletions.
  1. +14 −11 Setup.lhs
  2. +3 −3 src/Info.hs
  3. +0 −1 src/Main.hs
  4. +6 −5 src/NFA.hs
  5. +3 −3 src/Output.hs
  6. +1 −0 src/ParseMonad.hs
View
25 Setup.lhs
@@ -3,21 +3,22 @@
\begin{code}
module Main where
+import Distribution.Verbosity
import Distribution.PackageDescription (PackageDescription(..))
-import Distribution.Simple.Setup ( BuildFlags(..), buildVerbose )
-import Distribution.Simple ( defaultMainWithHooks, defaultUserHooks, UserHooks(..) )
+import Distribution.Simple.Setup ( BuildFlags(..), buildVerbosity, fromFlagOrDefault )
+import Distribution.Simple ( defaultMainWithHooks, simpleUserHooks, UserHooks(..) )
import Distribution.Simple.LocalBuildInfo ( LocalBuildInfo(..) )
import Distribution.Simple.Program
import System.FilePath ((</>))
-import System.IO.Error ( try )
+import Control.Exception ( IOException, try )
import System.Directory (removeFile)
main :: IO ()
-main = defaultMainWithHooks defaultUserHooks{ postBuild = myPostBuild,
- postClean = myPostClean,
- copyHook = myCopy,
- instHook = myInstall }
+main = defaultMainWithHooks simpleUserHooks{ postBuild = myPostBuild,
+ postClean = myPostClean,
+ copyHook = myCopy,
+ instHook = myInstall }
-- hack to turn cpp-style '# 27 "GenericTemplate.hs"' into
-- '{-# LINE 27 "GenericTemplate.hs" #-}'.
@@ -39,7 +40,8 @@ symbols cs = case lex cs of
_ -> []
myPostBuild _ flags _ lbi = do
- let runProgram p = rawSystemProgramConf (buildVerbose flags) p (withPrograms lbi)
+ let verbosity = fromFlagOrDefault normal (buildVerbosity flags)
+ runProgram p = rawSystemProgramConf verbosity p (withPrograms lbi)
cpp_template src dst opts = do
let tmp = dst ++ ".tmp"
runProgram ghcProgram (["-o", tmp, "-E", "-cpp", "templates" </> src] ++ opts)
@@ -49,16 +51,17 @@ myPostBuild _ flags _ lbi = do
sequence_ ([ cpp_template "GenericTemplate.hs" dst opts | (dst,opts) <- templates ] ++
[ cpp_template "wrappers.hs" dst opts | (dst,opts) <- wrappers ])
-myPostClean _ _ _ _ = mapM_ (try . removeFile) all_template_files
+myPostClean _ _ _ _ = let try' = try :: IO a -> IO (Either IOException a)
+ in mapM_ (try' . removeFile) all_template_files
myInstall pkg_descr lbi hooks flags =
- instHook defaultUserHooks pkg_descr' lbi hooks flags
+ instHook simpleUserHooks pkg_descr' lbi hooks flags
where pkg_descr' = pkg_descr {
dataFiles = dataFiles pkg_descr ++ all_template_files
}
myCopy pkg_descr lbi hooks copy_flags =
- copyHook defaultUserHooks pkg_descr' lbi hooks copy_flags
+ copyHook simpleUserHooks pkg_descr' lbi hooks copy_flags
where pkg_descr' = pkg_descr {
dataFiles = dataFiles pkg_descr ++ all_template_files
}
View
6 src/Info.hs
@@ -60,6 +60,6 @@ infoDFA _ func_nm dfa
outputLCtx (Just set)
= paren (show set ++) . char '^'
- outputArr arr
- = str "Array.array " . shows (bounds arr) . space
- . shows (assocs arr)
+ -- outputArr arr
+ -- = str "Array.array " . shows (bounds arr) . space
+ -- . shows (assocs arr)
View
1 src/Main.hs
@@ -40,7 +40,6 @@ import System.Directory ( removeFile )
import System.Environment ( getProgName, getArgs )
import System.Exit ( ExitCode(..), exitWith )
import System.IO ( stderr, Handle, IOMode(..), openFile, hClose, hPutStr, hPutStrLn )
-import System.IO ( hSetBuffering, BufferMode(..) )
#if __GLASGOW_HASKELL__ >= 612
import System.IO ( hGetContents, hSetEncoding, utf8 )
#endif
View
11 src/NFA.hs
@@ -163,7 +163,7 @@ type MapNFA = Map SNum NState
newtype NFAM a = N {unN :: SNum -> MapNFA -> Encoding -> (SNum, MapNFA, a)}
instance Monad NFAM where
- return a = N $ \s n e -> (s,n,a)
+ return a = N $ \s n _ -> (s,n,a)
m >>= k = N $ \s n e -> case unN m s n e of
(s', n', a) -> unN (k a) s' n' e
@@ -181,7 +181,7 @@ e_close ar = listArray bds
bds@(_,hi) = bounds ar
newState :: NFAM SNum
-newState = N $ \s n e -> (s+1,n,s)
+newState = N $ \s n _ -> (s+1,n,s)
getEncoding :: NFAM Encoding
getEncoding = N $ \s n e -> (s,n,e)
@@ -214,6 +214,7 @@ bytesEdge from (x:xs) (y:ys) to
u <- newState
byteEdge from (byteSetRange (x+1) (y-1)) u
anyBytes u (length xs) to
+bytesEdge _ _ _ _ = undefined -- hide compiler warning
charEdge :: SNum -> CharSet -> SNum -> NFAM ()
charEdge from charset to = do
@@ -225,7 +226,7 @@ charEdge from charset to = do
byteEdge :: SNum -> ByteSet -> SNum -> NFAM ()
-byteEdge from charset to = N $ \s n e -> (s, addEdge n, ())
+byteEdge from charset to = N $ \s n _ -> (s, addEdge n, ())
where
addEdge n =
case Map.lookup from n of
@@ -237,15 +238,15 @@ byteEdge from charset to = N $ \s n e -> (s, addEdge n, ())
epsilonEdge :: SNum -> SNum -> NFAM ()
epsilonEdge from to
| from == to = return ()
- | otherwise = N $ \s n e -> (s, addEdge n, ())
+ | otherwise = N $ \s n _ -> (s, addEdge n, ())
where
addEdge n =
case Map.lookup from n of
Nothing -> Map.insert from (NSt [] [to] []) n
Just (NSt acc eps trans) -> Map.insert from (NSt acc (to:eps) trans) n
accept :: SNum -> Accept Code -> NFAM ()
-accept state new_acc = N $ \s n e -> (s, addAccept n, ())
+accept state new_acc = N $ \s n _ -> (s, addAccept n, ())
where
addAccept n =
case Map.lookup state n of
View
6 src/Output.hs
@@ -103,9 +103,9 @@ outputDFA target _ _ dfa
outputRCtx (RightContextCode code)
= str code
- outputArr arr
- = str "array " . shows (bounds arr) . space
- . shows (assocs arr)
+ -- outputArr arr
+ -- = str "array " . shows (bounds arr) . space
+ -- . shows (assocs arr)
-- -----------------------------------------------------------------------------
-- Generating arrays.
View
1 src/ParseMonad.hs
@@ -39,6 +39,7 @@ alexGetChar :: AlexInput -> Maybe (Char,AlexInput)
alexGetChar (_,_,[],[]) = Nothing
alexGetChar (p,_,[],(c:s)) = let p' = alexMove p c in p' `seq`
Just (c, (p', c, [], s))
+alexGetChar (_, _ ,_ : _, _) = undefined -- hide compiler warning
alexGetByte :: AlexInput -> Maybe (Byte,AlexInput)
alexGetByte (p,c,(b:bs),s) = Just (b,(p,c,bs,s))

0 comments on commit 0885497

Please sign in to comment.
Something went wrong with that request. Please try again.